diff --git a/lib/allegro/allegro-htmldocs-4.2.1/Pictures - Shortcut.lnk b/lib/allegro/allegro-htmldocs-4.2.1/Pictures - Shortcut.lnk new file mode 100644 index 0000000..38ecf1c Binary files /dev/null and b/lib/allegro/allegro-htmldocs-4.2.1/Pictures - Shortcut.lnk differ diff --git a/lib/allegro/allegro-htmldocs-4.2.1/abi.html b/lib/allegro/allegro-htmldocs-4.2.1/abi.html new file mode 100644 index 0000000..42ee20c --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/abi.html @@ -0,0 +1,190 @@ + + +ABI compatibility information + + + + +
+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                ABI compatibility information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

Introduction

+ +

+ Once Allegro 4.2 is released, we plan to maintain backward compatibility + at the Application Binary Interface level for the subsequent releases of + the 4.2.x series. For example, that means you will be able to use an + executable compiled using version 4.2.0 with version 4.2.5 or 4.2.41 of + the dynamically linked library. + +

+ However, there are some guidelines (rules) you should (must) follow, + otherwise things will not work, and you will get angry emails from + users and from us. + +

+ Note: ABI compatibility will only be _actively_ maintained for: +

+ +

+ We will not be maintaining "forwards compatibility", meaning that + programs compiled with a newer release of Allegro may not necessarily + run on a target system which has an older release of Allegro installed. + You would have to upgrade the Allegro DLL on the target system. While + we will try to minimise these kinds of forced upgrades, it should give + us more flexibility within the stable series. + + + +


+

Windows notes

+ +

+ If you don't need a modified version of Allegro then just link your + program against an officially blessed non-WIP, non-CVS, non-dodgy + version. Don't disable any features (eg. colour depths, drivers) in + the DLL. + +

+ If you require a modified version of Allegro, then please either + statically link, or pick a non-standard name for the Allegro DLL. + For example, don't distribute a modified version of Allegro under a + name such as all42.dll or alleg42.dll. Instead, call it something + like alcustom.dll. Even better, statically link. + +

+ For the people who use vanilla Allegro, we will provide a set of + "reference" DLLs. If your binary works with those then everything is + fine. If you want to distribute Allegro DLLs with your program + (usually a good idea), we recommend you distribute our DLLs instead + of ones you compiled yourself. + + + +


+

Linux on x86 notes

+ +

+ To make sure an Allegro binary compiled on your machine will work on + another machine, do not disable any "features" with `configure'. Your + copy of Allegro must have assembly routines, threads, modules, all + colour depths and X11 support enabled, amongst other things. If in + doubt, leave it at the default setting. + +

+ When you are ready to distribute your binary, run "ldd <mybinary>". + It should say something like: + +

+ liballeg.so.4.2 => /usr/local/lib/liballeg.so.4.2 (0xdeadbeaf) + +

+ It should NOT say: + +

+ liballeg.so.4.2.0 => /usr/local/lib/liballeg.so.4.2.0 (0xdeadbeaf) + +

+ If you see the latter, that would mean users with later versions of + Allegro would not be able to run your binary. + +

+ See also the Windows section if you need to use a modified version of + Allegro. + +

+ For people packaging Allegro for redistribution: Drivers that are + built as dynamically loaded modules may be disabled or left out, but + all others should be left in. Examples of drivers that are _not_ + dynamically loaded include: OSS digital sound and OSS MIDI. In + short, if a program built against a copy of default-options Allegro + will work with your final library it should be fine. + + + +


+

Linux on x86-64 notes

+ +

+ The situation is basically the same as for Linux on x86, however + your copy of Allegro must NOT have assembly routines enabled (it + wouldn't work anyhow). + + + +


+

MacOS X notes

+ +

+ On OSX there are two 'styles' of linking - Unix style and Mac style. + For the Unix style linking, you would use `allegro-config --libs` + on the link line. For versioning, follow the advice given in the + 'Linux on x86' section above, using the command otool -L instead + of ldd. + +

+ For example, otool -L <mybinary> should give + +

+ liballeg-4.2.dylib (compatibility version 4.2.0, current version 4.2.0) + +

+ For the Mac style, use `allegro-config --frameworks` on the link + line, or add Allegro.framework to your project if you are using + XCode. In this case, the versioning is done inside the framework + itself. + +

+ Apple recommends that an application should be entirely self- + contained. To achieve this in Allegro, static-link the executable + and use fixbundle to bind all its resources together. In this + way, you will not need to worry about incompatible versions of + the library. This is useful if you are distributing an application. + +

+ There is a known compatibility problem when using gcc 4 on MacOS X 10.4 + that prevents binaries from working on older versions of MacOS X. While it + is anticipated that a future update from Apple will fix this problem, you + can use gcc 3 to work around it. + + + +


+

Final notes

+ +

+ Providing source is still better than not providing source. Binaries + are good, however, if your code sucks and only you (with the help of + witchcraft) can compile it. + +

+ If you provided binaries in the past using WIP versions of Allegro, + we politely request that you recompile your program using a stable + version of Allegro. + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/ahack.html b/lib/allegro/allegro-htmldocs-4.2.1/ahack.html new file mode 100644 index 0000000..f2e2e67 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/ahack.html @@ -0,0 +1,668 @@ + + +Allegro Hacker's Guide + + + + +

+The Allegro Hacker's Guide +

+
+ +This is a guide to some of the internal workings of Allegro, for people who +are interested in hacking on it. This document is far from complete, and may +not always be 100% accurate. Remember that when in doubt, the sources are +always the definitive reference. Suggestions for what to include in this +document will be very welcome: there is far too much code for me to go over +it all in any kind of detail, so I want to concentrate on the things that +people find most confusing... + + + +


+

Contents

+ +

+

+ + + +


+

Coding Style

+ +

+I'm not going to be a fascist about this, but it does make life easier if +all the code uses a consistent layout. If you are going to write and +maintain more than one complete source file of your own, I think you are +entitled to do that however you like, but for smaller contributions, I will +probably reformat your code to fit in with my existing style. It will +obviously save me time if you write it this way in the first place, hence +this description: + +

+Basic Allegro style: K&R, with 3 space indentation. On disk, though, tab stops +are 8 spaces, so if for example a line was indented by 12 spaces, this would be +saved out as either 12 space characters or 1 tab and 4 spaces, not as 4 tabs. +Because this format always will lead to code display looking broken in place or +another, new patches should now always use spaces only and no longer contain +tabs. The indent.pro file included with the Allegro distribution comes close to +getting this layout right, but doesn't quite manage it, so some things still +need to be cleaned up by hand. + +

+Preprocessor defines and structure names are UPPER_CASE. Function and +variable names are lower_case. MixedCaseNames are evil and should not be +used. That silly m_pHungarian notation is _really_ evil and should not even +be thought about. + +

+All symbols should be declared as static unless that is absolutely not +possible, in which case they should be prefixed with an underscore. + +

+Functions look like this: +

+/* foobar:
+ *  Description of what it does.
+ */
+void foobar(int foo, int bar)
+{
+   /* do some stuff */
+}
+
+Three blank lines between functions. + +

+Conditionals look like: +

+   if (foo) {
+      /* stuff */
+   }
+   else {
+      /* stuff */
+   }
+
+The only time when something comes on the same line after a closing brace is +at the end of a do/while loop, eg: +
+   do {
+      /* stuff */
+   } while (foo);
+
+Case statements look like this: +
+   switch (foo) {
+
+      case bar:
+         /* stuff */
+         break;
+
+      default:
+         /* stuff */
+         break;
+   }
+
+Examples of where to put spaces: +
+   char *p;
+   if (condition) { }
+   for (x=0; x<10; x++) { }
+   function(foo, bar);
+   (BITMAP *)data[id].dat;
+
+All sources should begin with the standard header: +
+/*         ______   ___    ___
+ *        /\  _  \ /\_ \  /\_ \
+ *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+ *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+ *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+ *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+ *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+ *                                           /\____/
+ *                                           \_/__/
+ *
+ *      Brief description of what this file does.
+ *
+ *      By Author.
+ *
+ *      Cool stuff added by Someone Else.
+ *
+ *      Stupid bug fixed by a Third Person.
+ *
+ *      See readme.txt for copyright information.
+ */
+
+Author credits should be added in chronological order, and email addresses +should not be included: those can be found in the main credits file, and if +they only exist in one place, it is easier to update them when people change +address. + +

+People only need to be listed in the source file header if they've made a +significant contribution to it (one-line fixes don't count), but no matter +how small their addition, they must be added to the docs/thanks._tx file. +This is sorted alphabetically by name. If they are already in it, update the +text to describe the new addition, otherwise make a new entry for the new +contributor. Also, anything more than very tiny modifications should be +added to the docs/changes._tx file, which grows from the top in reverse +chronological order. This file should briefly describe both the nature of +the modification and who did it. + + + +


+

Build Process

+ +

+This is very different depending on whether you are using autoconf or a +fixed makefile. For most platforms, though, the fixup script (eg. +fixdjgpp.bat), will create a small makefile, which defines MAKEFILE_INC to +the make of another file (eg. makefile.dj), and then includes makefile.all. +This contains a lot of generic rules, and includes the file named in +MAKEFILE_INC to provide additional platform-specific information. The actual +source files are listed in makefile.lst. + +

+There are three library targets: alleg (release), alld (debugging), and allp +(profiling). Objects go in obj/compiler/version/, where version is one of +alleg, alld, or allp. Libraries go in lib/compiler/. A few generated things +(asmdefs.inc, mmxtest.s, etc), go in the root of obj/compiler/. Dependencies +are generated by "make depend", and go in obj/compiler/version/makefile.dep, +which is included by makefile.all. + +

+When you run "make clean", this only deletes harmless generated files like +the objects. "make distclean" strips you right back to the original +distribution, including getting rid of the test executables and the library +itself. For the ultimate in personal hygene, run "make veryclean", which +will wipe absolutely all generated files. After doing this, you will have to +run "make depend" before you can build the library, and also "fixdll.bat" if +you are working on a Windows platform. + +

+To pass long commandlines to the MSVC and Watcom linkers, the program +runner.exe is compiled using gcc, so make can pass it a decent number of +arguments. This just saves the parameters into a temporary file, and then +invokes the real command using that as an argument file. + +

+All the makefiles currently use gcc for dependency generation, because this +is easier than trying to get MSVC or Watcom to output the right info. + +

+The symbol LIBRARY_VERSION, defined at the top of the makefile.ver, is used +for including a version number in things like the DLL filename. + + + +


+

Header Files

+ +

+allegro.h lives in the include/ directory. It is only a placeholder which +includes other headers which live in the include/allegro/ tree. The reason +for this slightly odd approach is that allegro.h can include things like +"allegro/keyboard.h", which will work both in-situ within the build +directory, and if we copy allegro.h to the system include directory and the +other headers into system_include/allegro/. This avoids cluttering the +system directories with lots of our headers, while still allowing programs +to just #include <allegro.h>, and also makes it possible for people to +access keyboard stuff with #include <allegro/keyboard.h>. + +

+base.h includes alconfig.h, which checks the current platform and includes +a helper header for this compiler (aldjgpp.h, almsvc.h, alwatcom.h, etc). +That helper header defines a bunch of macros describing the system, emulates +whatever things are needed to make the code compile properly, and optionally +defines ALLEGRO_EXTRA_HEADER and ALLEGRO_INTERNAL_HEADER if it is going to +need any other platform-specific includes. + +

+After including the platform header, the rest of alconfig.h defines a lot of +generic helper macros to their default values, but only if the platform +header hasn't already overridden these to something specific. + +

+Every module-specific header contains structure definitions and function +prototypes. At the end of the file, it may include a header from the +include/allegro/inline/ directory which defines related inline routines. +If inline asm is supported, this can include in turn asm.inl which imports +routines from one of the compiler-specific files al386gcc.h, al386vc.h and +al386wat.h; otherwise C versions are used instead. The header alinline.h +is a placeholder which includes all the headers defining inline functions. + +

+If ALLEGRO_EXTRA_HEADER is defined, allegro.h includes this at the very end. +This is used to include one of the files aldos.h, alwin.h, etc, which define +platform-specific things like ID values for the hardware drivers. Unlike the +platform files included from the top of allegro.h, these are specific per-OS +rather than per-compiler, so the same alwin.h can be used by both MSVC and +MinGW. They describe library functions that relate to this platform, while +the earlier header described the basic language syntax. + +

+aintern.h is like the internal.h in earlier Allegro versions, defining +routines that are shared between multiple sources, but that we don't +generally want user programs to see. + +

+On platforms which have specific, non-portable API routines of their own, +these should go in a special header in the root of the include directory, +eg. winalleg.h. This can be included by user programs that want to access +these routines, while making it very clear to them that by including this +header, they are writing non-portable code. + + + +


+

Definitions

+ +

+All header function prototypes should use the macro AL_FUNC(). Inline +routines use the macro AL_INLINE(). Global variables use AL_VAR() or +AL_ARRAY(). Global pointers to functions use AL_FUNCPTR(). Pointers to +functions which are passed as parameters to other routines or stored in a +structure typedef use AL_METHOD(). This may seem like something of an +overkill, but it gives us a lot of flexibility to add DLL import/export +specifiers, calling convention markers like __cdecl, and even to mangle +symbol names on some compilers. If you forget to use these macros, your code +won't work on some platforms. + +

+This only applies to header files, though: you can write normal code in the +C sources. + +

+The symbol ALLEGRO_SRC is defined while compiling library source files. If +you want to inline a function in one of your sources, use the INLINE macro. +To declare a zero-sized array in terminal position inside a structure, use +the ZERO_SIZE_ARRAY(type, name) macro. To use 64 bit integers, declare a +LONG_LONG variable (this won't be defined on all platforms). To do things +with filenames, check the macros ALLEGRO_LFN, OTHER_PATH_SEPARATOR, and +DEVICE_SEPARATOR. See the headers for details. + + + +


+

Unicode Support

+ +

+Do not assume that strings are ASCII. They aren't. If you assume they are, +your code might work for a while as long as people are only using it with +UTF-8 data, but it will die horribly as soon as someone tries to run it with +16 bit Unicode strings, or Chinese GB-code, or some strange MIME format, +etc. Whenever you see a char * being passed around, you must be aware that +this will actually contain text in whatever format is currently selected, so +you have to be damn careful when manipulating strings. Don't ever forget and +call a regular libc routine on them! + +

+Use the Unicode functions for all your text manipulation: see the docs for +details. When allocating a scratch string on the stack, assume that each +character will occupy at most four bytes: this will give you more than +enough space for any of the current encoding schemes. + +

+If you want to specify a constant string, use the function +uconvert_ascii("my string", buf) to obtain a copy of "my string" in the +current encoding format. If buf is NULL, this will use an internal static +buffer, but the converted string will be overwritten by the next call to any +format conversion routines, so you shouldn't pass it down into other library +functions. Normally you should provide the conversion space yourself, +allocating buf as a temporary object on the stack. + +

+To convert the other way (eg. before passing an Allegro string to an OS +routine that expects ASCII data), call uconvert_toascii(mystring, buf). + +

+For any messages that may be seen by the user, you can call +get_config_text("my ascii string") instead of uconvert_ascii(). This will +return a pointer to persistent memory (so it is ok to keep the string around +indefinitely), after converting into the current text encoding format. This +function is cool because it saves you having to bother allocating space for +the converted data, and because it allows the string to be replaced by the +translations in language.dat. You should be sure to always pass a constant +string to get_config_text(), rather than any generated text or data from +other string variables: this is so that the findtext.sh script can easily +locate all the strings that need to be translated. + +

+Hardware drivers should initialise their name and desc fields to the global +empty_string, and store an ASCII driver name in their ascii_name field. The +framework code will automatically translate and convert this value, storing +the result in both the name and desc fields. For most drivers this will be +enough, but if you want to provide a more detailed description, it is up to +your driver to set this up from their init routine, and take care of all the +required conversions. + + + +


+

Asm Routines

+ +

+Structure offsets are defined in asmdef.inc, which is generated by asmdef.c. +This allows the asm code to use human readable names for the structure +members, and to automatically adjust whenever new fields are added, so it +will always exactly match the layout of the C structures. + +

+Asm code should use the macro FUNC(name) to declare the start of a routine, +and GLOBL(name) whenever it wants to refer to an external symbol (eg. a C +variable or function). This is to handle name mangling in a portable way +(COFF requires an underscore prefix, ELF does not). + +

+You can modify %ds and %es from asm, as long as you put them back. If USE_FS +and FSEG are defined, you can also change %fs, otherwise this is not +required and you can safely use nearptr access for everything. + +

+Don't assume that the MMX opcodes will be supported: not every assembler +version knows about these. Check the ALLEGRO_MMX macro, and be sure to give +up gracefully if these instructions are not available. + + + +


+

Documentation

+ +

+One of the nicest features of Allegro is its excellent manual, that you can +read in several formats, ranging from plain text to compiled HTML. All API +functions of the library have to be documented in docs/src/allegro._tx in the +appropriate section. Note that, whatever you write in the file, you shouldn't +exceed a line width of 78 characters, except for lines which contain tags. +This rule is needed in order to produce correct plain text documentation that +doesn't extend beyond the standard 80 column screen/terminal. All the other +formats are less strict about line width and will probably reformat the text +anyway. + +

+If the function you are documenting returns a value, use the @retval command +to start the chunk of text that describes the return value or how it is used. +If the function takes parameters, document if they are required to follow a +specific format (e.g. string encoding), what they are for, and their range of +values (if any). The latter is particularly important for boolean parameters, +because there's no way to tell the user that an integer must be either `true' +or `false' in the C programming language. Parameters are always referred to +between single quotes, left and right. These are tt-ized in the HTML version, +but only if there are no space characters between the left and right quote. + +

+If it is possible to include a little fragment of code which demonstrates the +usage of the function, do it just before the @retval command if there is one, +or at the end of the block. This is very welcome for functions that don't have +example references (@eref). You don't need to include the declaration of the +variables unless you really think it can help newbies. + +

+Usually a single line will be enough, but don't hesitate to add whatever +comments you might think of as useful for newbies. Also, if you are writing +such a one liner, try to use verbose variable names to indicate where they +come from or what they should contain. Compare the following lines, where the +second is more likely to be found in `real life' code, but should be avoided +in these little code fragments taken out of context: +

+   blit(source_bitmap, destination_bitmap, source_x, source_y,
+      destination_x, destination_y, bitmap_width, bitmap_height);
+      ...
+   blit(spr[3]->bmp, screen, x, y, s_x, s_y, spr[3]->bmp->w, spr[3]->bmp->h);
+
+Whatever coding style applies to Allegro's code also applies to these examples +(e.g. 8 characters tab, 3 spaces indentation). If you are having trouble +documenting a particular function because you don't know how to approach the +task (this tends to happen when you have used the function so much that you +have learnt it by heart), here is a checklist you can follow: + +Don't bother about existing example references (@eref). These are generated +automatically by a script. The person in charge of releasing Allegro will +most surely do this for you. If you know how to run it, you are very welcome +to update these tags though, to avoid piling extra work on the maintainer's +shoulders. Of course, all said about documenting functions applies to macros +and variables too. + + + +


+

Debugging helpers

+ +

+As a developer you are encouraged to spill as many ASSERT and TRACE macros as +you consider necessary. ASSERT macros are a very good way of enforcing +documented limitations in input parameters which should never happen during a +perfect (ie. bugless) version of your game. They are good for things like +verifying some Allegro subsystem was initialised at the entry point of a +function which depends on it, or passing NULL pointers where the documentation +explicitly says the user is not allowed to do so. + +

+The TRACE macro is very good for things which are not very repetitive, mainly +initialisation functions. The problem with C code is that usually error +reporting to the user programmer layer is done through a simple integer or +NULL pointer, and the error description (if any) stored in allegro_error. This +is clearly insufficient for functions like set_gfx_mode() which test many +graphic drivers before bailing out. + +

+What should be the error code in such case? How could you preserve a coherent +error message to the user in driver A when driver B later overwrites it with +some other error which may not interest the user trying to run driver A? +Developers have made plans to include better logging facilities in future +Allegro releases. In the meantime, it is good if opaque systems like drivers +use TRACE both to indicate success and failure. + +

+For this reason there is a TRACE convention for Allegro code using this macro. +At the top of the source file you want to use TRACE define three macros: +PREFIX_I, PREFIX_W, PREFIX_E. Each of this should be a string in the format +"al-SYSTEM LEVEL: " where SYSTEM is usually the filename creating the TRACE +(but doesn't have to) and LEVEL is either INFO, WARNING or ERROR respectively. +Later you can use them like this: +

+   if (some_error_in_a_deep_obscure_function) {
+      TRACE(PREFIX_E "Couldn't init obscure driver because %s", something);
+      return -1;
+   }
+   TRACE(PREFIX_I "Obscure system initialised with option %s", switch);
+
+Thanks to this prefix convention a user can use the TRACE macro too and grep +Allegro's messages if there is no interest in them. + + + +


+

Other Stuff

+ +

+Any portable routines that run inside a timer handler or input callback must +be sure to lock all the code and data that they touch. This is done by +placing an END_OF_FUNCTION(x) or END_OF_STATIC_FUNCTION(x) after each +function definition (this is not required if you declare the function as +INLINE, though), and then calling LOCK_FUNCTION() somewhere in your init +code. Use LOCK_VARIABLE() to lock global variables, and LOCK_DATA() to lock +allocated memory. + +

+Any modules that have cleanup code should register their exit function by +calling _add_exit_func(). This will ensure that they are closed down +gracefully no matter whether the user calls allegro_exit(), falls off the +bottom of main(), or the program dies suddenly due to a runtime error. You +must call _remove_exit_func() from inside your shutdown routine, or you will +find yourself stuck in an endless loop. + + + +


+

How to contribute patches

+ +

+Once you are willing to contribute that beautiful hack which does what +everybody has been waiting for, the fix for that hideous bug which has been +driving you mad for several nights, the nice improved documentation you would +have liked to read in the manual for the first time, etc, you have already +done the hardest part. Now you only need a way to let the Allegro developers +merge your changes in the main distribution. + +

+You could probably send your patch to one of the people working on Allegro, +but this is not very safe, it depends on the person you chose being available +and willing to do the work for you. The best you can do is to send your patch +to the Allegro Developers mailing list. Read the readme.txt file for +information on how to subscribe to this list. Alternatively, updated +subscription instructions should always be available at +http://alleg.sourceforge.net/maillist.html. + +

+Sending your patches to the mailing list instead of a single person is good, +because all the subscribed developers can take a look at your modifications, +suggest improvements, or find problems, which you can discuss on the same +mailing list, letting other developers join the conversation when they +consider appropriate. If the modifications are good, they will probably be +accepted and merged in the WIP version for the next release. If you aren't +lucky, or your patch still needs some work, you will be told why it's not +accepted, or what you have to do to improve it. If you aren't subscribed to +the list, remember to say this in your message as, by default, replies are +irected to the list. + +

+You can also use SourceForge's issue web trackers, which you can find at +http://sourceforge.net/tracker/?group_id=5665. This doesn't require you to +subscribe to any mailing list and you can verify every now and then the +status of your contribution. + + + +


+

Building your patch against an existent release

+ +

+If you have obtained Allegro from an existent release, stable or unstable, +you will have all the source code contained in some archive format. You will +need it, because to create a patch you need two versions of each modified +file, the original version, and your modified version. You will also need +the diff tool, which is used to create the patches. This tool is usually +packaged as a standalone package in most GNU/Linux distributions with the +same name. For DOS, you can get a port from http://www.delorie.com/djgpp/. +Just choose a mirror from http://www.delorie.com/djgpp/getting.html, +enter the v2gnu directory and download the difxxb.zip package. While you are +at it, you can also get a tool named patch (patxxb.zip), which is used to +apply patches generated by diff, in case you have to apply the patches +somebody else sends to you. Install the binaries in some directory of your +path, so that you can use them from anywhere. + +

+If you are planing to modify only one file, you will usually copy this file +to the same name in the same directory with the appended extension '.old' +before starting to work on it. After you have made your modifications to the +file, and verified that they please you, go to the directory containing the +modified and original files and type at the prompt: +

+   diff -u file.c.old file.c > patch
+
+This command will generate a text file which contains the differences +between both files in unified output format. Open it with your prefered +editor and verify that it contains the modifications you wanted to do: lines +you have added will be marked with a plus sign '+', lines you have removed +will be marked with a minus sign '-'. If the file is bigger than a few +kilobytes, compress it before sending to the developers mailing list, and of +course remember to add an explanation of what the patch is meant to do, why +it's needed, and any other information you consider relevant. + +

+If the modifications you want to do are scattered through several files +and/or directories, this form of patch generation is very tiresome for both +ends (you, and the developers). So unpack a fresh copy of the Allegro source +somewhere and move it to the parent directory where your current version is, +after giving it another name of course, so as to obtain two complete sources +trees side by side. Modify the files you wish in your working +directory. Once you are finished, go back to the parent directory housing the +two source trees and type: +

+   diff -ur fresh_original_directory working_directory > patch
+
+The '-r' switch makes diff compare directories recursively. Again, do the +previous steps of verifying your patch, compressing and sending with correct +instructions. If your patch adds or removes files, you will have to add the +'-N' switch, because by default diff will ignore files which are only in one +of the trees. Of course, you might want to run a 'make clean' in your working +directory before running this command, or you will include lots of generated +files which have nothing to do with your patch. Or you could edit the +resulting patch, but that can be error prone. + + + +


+

Building your patch against a CVS version

+ +

+If you are working with the cvs version of Allegro which you can get from +Sourceforge (http://sourceforge.net/projects/alleg/), you won't need +to copy any files at all. Just modify the files you want, go to the root +directory of the cvs copy and type: +

+   cvs diff -u > patch
+
+Unlike the standalone diff, the cvs diff command will work recursively +through the Allegro source tree, comparing each file against the Sourceforge +repository. The patch will have slightly different headers, but that's ok, +once you have it follow the previous process to send it to the developers +mailing list. Of course, check cvs' manual for more information and options. + + + +


+

Online patch creation

+ +

+Sometimes you don't have the diff tool around, or don't have the cvs tool to +check out the bleeding edge version of Allegro, or you are too lazy to care +how to actually make the patch yourself. For any of those cases, you can use +the online Allegro patcher at http://www.allegro.cc/dev/make-diff.php. + +

+To use it, first you have to get one of the source files of Allegro and make +your changes to it. Then, go to that URL and supply the local path on your +computer to the modified file. Then, you write the path of this file relative +to Allegro's root. If everything goes well, you will end up with a +patch you can send to the Allegro developers mailing list or post on +SourceForge's patch submission page. + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg000.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg000.html new file mode 100644 index 0000000..263010d --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg000.html @@ -0,0 +1,577 @@ + + +Allegro Manual: Using Allegro + + + + +

Using Allegro

+ + + +

+See readme.txt for a general introduction, copyright details, and +information about how to install Allegro and link your program with it. + +


+

int install_allegro(int system_id, int *errno_ptr, int (*atexit_ptr)());

+ Initialises the Allegro library. You must call either this or + allegro_init() before doing anything other than using the Unicode + routines. If you want to use a text mode other than UTF-8, you can set + it with set_uformat() before you call this. The other functions that can + be called before this one will be marked explicitly in the documentation, + like set_config_file(). + +

+ The available system ID codes will vary from one platform to another, but + you will almost always want to pass SYSTEM_AUTODETECT. Alternatively, + SYSTEM_NONE installs a stripped down version of Allegro that won't even + try to touch your hardware or do anything platform specific: this can be + useful for situations where you only want to manipulate memory bitmaps, + such as the text mode datafile tools or the Windows GDI interfacing + functions. + +

+ The `errno_ptr' and `atexit_ptr' parameters should point to the errno + variable and atexit function from your libc: these are required because + when Allegro is linked as a DLL, it doesn't have direct access to your + local libc data. `atexit_ptr' may be NULL, in which case it is your + responsibility to call allegro_exit() manually. Example: +

+      install_allegro(SYSTEM_AUTODETECT, &errno, atexit);
+

Return value: + This function returns zero on success and non-zero on failure (e.g. no + system driver could be used). Note: in previous versions of Allegro this + function would abort on error. + + +

See also: +allegro_init, +allegro_exit, +set_uformat, +set_config_file.
+
int allegro_init();

+ Macro which initialises the Allegro library. This is the same thing as + calling install_allegro(SYSTEM_AUTODETECT, &errno, atexit). + + +
See also: +install_allegro, +allegro_exit.
+ +
Examples using this: +Available Allegro examples.
+
void allegro_exit();

+ Closes down the Allegro system. This includes returning the system to + text mode and removing whatever mouse, keyboard, and timer routines have + been installed. You don't normally need to bother making an explicit call + to this function, because allegro_init() installs it as an atexit() + routine so it will be called automatically when your program exits. + +

+ Note that after you call this function, other functions like + destroy_bitmap() will most likely crash. This is a problem for C++ global + destructors, which usually get called after atexit(), so don't put Allegro + calls in them. You can write the destructor code in another method which + you can manually call before your program exits, avoiding this problem. + + +

See also: +install_allegro, +allegro_init, +destroy_bitmap.
+ +
Examples using this: +ex3d, +exscn3d, +exswitch, +exxfade, +exzbuf.
+
Macro END_OF_MAIN()

+ In order to maintain cross-platform compatibility, you have to put this + macro at the very end of your main function. This macro uses some `magic' + to mangle your main procedure on platforms that need it like Windows, + some flavours of UNIX or MacOS X. On the other platforms this macro + compiles to nothing, so you don't have to #ifdef around it. Example: +
+      int main(void)
+      {
+         allegro_init();
+         /* more stuff goes here */
+         ...
+         return 0;
+      }
+      END_OF_MAIN()
+ + +
See also: +Windows specifics, +Unix specifics, +MacOS X specifics, +Differences between platforms.
+ +
Examples using this: +Available Allegro examples.
+
extern char allegro_id[];

+ Text string containing a date and version number for the library, in case + you want to display these somewhere. + +


+

extern char allegro_error[ALLEGRO_ERROR_SIZE];

+ Text string used by set_gfx_mode(), install_sound() and other functions to + report error messages. If they fail and you want to tell the user why, this + is the place to look for a description of the problem. Example: +
+      void abort_on_error(const char *message)
+      {
+         if (screen != NULL)
+            set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
+
+         allegro_message("%s.\nLast Allegro error `%s'\n",
+                         message, allegro_error);
+         exit(-1);
+      }
+      ...
+         if (some_allegro_function() == ERROR_CODE)
+            abort_on_error("Error calling some function!");
+ +
See also: +set_gfx_mode, +install_sound.
+ +
Examples using this: +Available Allegro examples.
+
#define ALLEGRO_VERSION

+ Defined to the major version of Allegro. From a version number like + 4.1.16, this would be defined to the integer 4. + +


+

#define ALLEGRO_SUB_VERSION

+ Defined to the middle version of Allegro. From a version number like + 4.1.16, this would be defined to the integer 1. + +


+

#define ALLEGRO_WIP_VERSION

+ Defined to the minor version of Allegro. From a version number like + 4.1.16, this would be defined to the integer 16. + +


+

#define ALLEGRO_VERSION_STR

+ Defined to a text string containing all version numbers and maybe some + additional text. This could be `4.1.16 (CVS)' for an Allegro version + obtained straight from the CVS repository. + +


+

#define ALLEGRO_DATE_STR

+ Defined to a text string containing the year this version of Allegro was + released, like `2004'. + +


+

#define ALLEGRO_DATE

+ Defined to an integer containing the release date of Allegro in the packed + format `yyyymmdd'. Example: +
+      const int year = ALLEGRO_DATE / 10000;
+      const int month = (ALLEGRO_DATE / 100) % 100;
+      const int day = ALLEGRO_DATE % 100;
+
+      allegro_message("Year %d, month %d, day %d\n",
+         year, month, day);
+ +


+

Macro AL_ID(a,b,c,d)

+ This macro can be used to create a packed 32 bit integer from 8 bit + characters, on both 32 and 64 bit machines. These can be used for various + things, like custom datafile objects or system IDs. Example: +
+      #define OSTYPE_LINUX       AL_ID('T','U','X',' ')
+ + +
See also: +DAT_ID.
+
Macro MAKE_VERSION(a, b, c)

+ This macro can be used to check if some Allegro version is (binary) + compatible with the current version. It is safe to use > and < to + check if one version is more recent than another. + The third number is ignored if the second number is even, so + MAKE_VERSION(4, 2, 0) is equivalent to MAKE_VERSION(4, 2, 1). + This is because of our version numbering policy since 4.0.0: + the second number is even for stable releases, which must be + ABI-compatible with earlier versions of the same series. + This macro is mainly useful for addon packages and libraries. See the + `ABI compatibility information' section of the manual for more detailed + information. Example: +
+      /* Check if the current version is compatible with Allegro 4.2.0 */
+      #if (MAKE_VERSION(4, 2, 0) <= MAKE_VERSION(ALLEGRO_VERSION, \
+                         ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION))
+         /* Allegro 4.2.0 compatibility */
+      #else
+         /* Work-around */
+      #endif
+ + +
See also: +ALLEGRO_VERSION, +ALLEGRO_SUB_VERSION, +ALLEGRO_WIP_VERSION.
+
extern int os_type;

+ Set by allegro_init() to one of the values: +
+      OSTYPE_UNKNOWN    - unknown, or regular MSDOS
+      OSTYPE_WIN3       - Windows 3.1 or earlier
+      OSTYPE_WIN95      - Windows 95
+      OSTYPE_WIN98      - Windows 98
+      OSTYPE_WINME      - Windows ME
+      OSTYPE_WINNT      - Windows NT
+      OSTYPE_WIN2000    - Windows 2000
+      OSTYPE_WINXP      - Windows XP
+      OSTYPE_WIN2003    - Windows 2003
+      OSTYPE_WINVISTA   - Windows Vista
+      OSTYPE_OS2        - OS/2
+      OSTYPE_WARP       - OS/2 Warp 3
+      OSTYPE_DOSEMU     - Linux DOSEMU
+      OSTYPE_OPENDOS    - Caldera OpenDOS
+      OSTYPE_LINUX      - Linux
+      OSTYPE_SUNOS      - SunOS/Solaris
+      OSTYPE_FREEBSD    - FreeBSD
+      OSTYPE_NETBSD     - NetBSD
+      OSTYPE_IRIX       - IRIX
+      OSTYPE_DARWIN     - Darwin
+      OSTYPE_QNX        - QNX
+      OSTYPE_UNIX       - Unknown Unix variant
+      OSTYPE_BEOS       - BeOS
+      OSTYPE_MACOS      - MacOS
+      OSTYPE_MACOSX     - MacOS X
+ + +
See also: +allegro_init, +os_version, +os_multitasking.
+
extern int os_version;

+
extern int os_revision;

+ The major and minor version of the Operating System currently running. + Set by allegro_init(). If Allegro for some reason was not able to + retrieve the version of the Operating System, os_version and + os_revision will be set to -1. For example: Under Win98 SE (v4.10.2222) + os_version will be set to 4 and os_revision to 10. + + +
See also: +os_type, +os_multitasking.
+
extern int os_multitasking;

+ Set by allegro_init() to either TRUE or FALSE depending on whether your + Operating System is multitasking or not. + + +
See also: +os_type, +os_version.
+
void allegro_message(const char *text_format, ...);

+ Outputs a message, using a printf() format string. Usually you want to + use this to report messages to the user in an OS independant way when some + Allegro subsystem cannot be initialised. But you must not use this function + if you are in a graphic mode, only before calling set_gfx_mode(), or after + a set_gfx_mode(GFX_TEXT). Also, this function depends on a system driver + being installed, which means that it won't display the message at all on + some platforms if Allegro has not been initialised correctly. + +

+ On platforms featuring a windowing system, it will bring up a blocking GUI + message box. If there is no windowing system, it will try to print the + string to a text console, attempting to work around codepage differences + by reducing any accented characters to 7-bit ASCII approximations. + Example: +

+      if (allegro_init() != 0)
+         exit(1);
+
+      if (init_my_data() != 0) {
+         allegro_message("Sorry, missing game data!\n");
+         exit(2);
+      }
+ + +
See also: +allegro_init, +install_allegro, +set_uformat.
+ +
Examples using this: +Available Allegro examples.
+
void set_window_title(const char *name);

+ On platforms that are capable of it, this routine alters the window title + for your Allegro program. Note that Allegro cannot set the window title + when running in a DOS box under Windows. Example: +
+      set_window_title("Allegro rules!");
+ + +
See also: +set_close_button_callback, +set_uformat.
+ +
Examples using this: +exunicod.
+
int set_close_button_callback(void (*proc)(void));

+ On platforms that have a close button, this routine installs a callback + function to handle the close event. In other words, when the user clicks + the close button on your program's window or any equivalent device, the + function you specify here will be called. + +

+ This function should not generally attempt to exit the program or save + any data itself. The function could be called at any time, and there is + usually a risk of conflict with the main thread of the program. Instead, + you should set a flag during this function, and test it on a regular + basis in the main loop of the program. + +

+ Pass NULL as the `proc' argument to this function to disable the close + button functionality, which is the default state. + +

+ Note that Allegro cannot intercept the close button of a DOS box in + Windows. + +

+ Also note that the supplied callback is also called under MacOS X when + the user hits Command-Q or selects "Quit" from the application menu. + Example: +

+      volatile int close_button_pressed = FALSE;
+
+      void close_button_handler(void)
+      {
+         close_button_pressed = TRUE;
+      }
+      END_OF_FUNCTION(close_button_handler)
+      ...
+      
+      allegro_init();
+      LOCK_FUNCTION(close_button_handler);
+      set_close_button_callback(close_button_handler);
+      ...
+         
+      while (!close_button_pressed)
+         do_stuff();
+

Return value: + Returns zero on success and non-zero on failure (e.g. the feature is not + supported by the platform). + + +

See also: +set_window_title.
+
int desktop_color_depth();

+ Finds out the currently selected desktop color depth. You can use this + information to make your program use the same color depth as the desktop, + which will likely make it run faster because the graphic driver won't be + doing unnecessary color conversions behind your back. + +

+ Under some OSes, switching to a full screen graphics mode may automatically + change the desktop color depth. You have, therefore, to call this function + before setting any graphics mode in order to retrieve the real desktop + color depth. Example: +

+      allegro_init();
+      ...
+      if ((depth = desktop_color_depth()) != 0) {
+         set_color_depth(depth);
+      }
+

Return value: + Returns the color depth or zero on platforms where this information is not + available or does not apply. + + +

See also: +get_desktop_resolution, +set_color_depth, +set_gfx_mode.
+
int get_desktop_resolution(int *width, int *height);

+ Finds out the currently selected desktop resolution. You can use this + information to avoid creating windows bigger than the current resolution. + This is especially important for some windowed drivers which are unable + to create windows bigger than the desktop. Each parameter is a pointer + to an integer where one dimension of the screen will be stored. + +

+ Under some OSes, switching to a full screen graphics mode may automatically + change the desktop resolution. You have, therefore, to call this function + before setting any graphics mode in order to retrieve the real desktop + resolution. Example: +

+      int width, height;
+      
+      allegro_init();
+      ...
+      if (get_desktop_resolution(&width, &height) == 0) {
+         /* Got the resolution correctly */
+      }
+

Return value: + Returns zero on success, or a negative number if this information is not + available or does not apply, in which case the values stored in the + variables you provided for `width' and `height' are undefined. + + +

See also: +desktop_color_depth, +set_gfx_mode.
+
void check_cpu();

+ Detects the CPU type, setting the following global variables. You don't + normally need to call this, because allegro_init() will do it for you. + + +
See also: +cpu_vendor, +cpu_family, +cpu_model, +cpu_capabilities, +allegro_init.
+
extern char cpu_vendor[];

+ On Intel PCs, contains the CPU vendor name if known. On Mac OSX systems + this contains the PPC subtype name. On other platforms, this may be an empty + string. You can read this variable after you have called check_cpu() + (which is automatically called by allegro_init()). + + +
See also: +check_cpu, +cpu_family, +cpu_model, +cpu_capabilities, +allegro_init.
+
extern int cpu_family;

+ Contains the Intel type, where applicable. Allegro defines the following + CPU family types: +
+      CPU_FAMILY_UNKNOWN  - The type of processor is unknown
+      CPU_FAMILY_I386     - The processor is an Intel-compatible 386
+      CPU_FAMILY_I486     - The processor is an Intel-compatible 486
+      CPU_FAMILY_I586     - The processor is a Pentium or equivalent
+      CPU_FAMILY_I686     - The processor is a Pentium Pro, II, III
+                            or equivalent
+      CPU_FAMILY_ITANIUM  - The processor is an Itanium processor
+      CPU_FAMILY_POWERPC  - The processor is a PowerPC processor
+      CPU_FAMILY_EXTENDED - The processor type needs to be read
+                            from the cpu_model
+
+ You can read this variable after you have called check_cpu() + (which is automatically called by allegro_init()). + + +
See also: +check_cpu, +cpu_vendor, +cpu_model, +cpu_capabilities, +allegro_init.
+
extern int cpu_model;

+ Contains the CPU submodel, where applicable. Allegro defines at least the + following CPU family types (see include/allegro/system.h for a more + complete list): +
+      CPU_FAMILY_I586:
+         CPU_MODEL_PENTIUM, CPU_MODEL_K5, CPU_MODEL_K6
+
+      CPU_FAMILY_I686:
+         CPU_MODEL_PENTIUMPRO, CPU_MODEL_PENTIUMII,
+         CPU_MODEL_PENTIUMIIIKATMAI, CPU_MODEL_PENTIUMIIICOPPERMINE,
+         CPU_MODEL_ATHLON, CPU_MODEL_DURON
+
+      CPU_FAMILY_EXTENDED:
+         CPU_MODEL_PENTIUMIV, CPU_MODEL_XEON,
+         CPU_MODEL_ATHLON64, CPU_MODEL_OPTERON
+
+      CPU_FAMILY_POWERPC:
+         CPU_MODEL_POWERPC_x, for x=601-604, 620, 750, 7400, 7450
+
+ You can read this variable after you have called check_cpu() (which is + automatically called by allegro_init()). Make sure you check the cpu_family + and cpu_vendor so you know which models make sense to check. + + +
See also: +check_cpu, +cpu_vendor, +cpu_family, +cpu_capabilities, +allegro_init.
+
extern int cpu_capabilities;

+ Contains CPU flags indicating what features are available on the current + CPU. The flags can be any combination of these: +
+      CPU_ID       - Indicates that the "cpuid" instruction is
+                     available. If this is set, then all Allegro CPU
+                     variables are 100% reliable, otherwise there
+                     may be some mistakes.
+      CPU_FPU      - An FPU is available.
+      CPU_IA64     - Running on Intel 64 bit CPU
+      CPU_AMD64    - Running on AMD 64 bit CPU
+      CPU_MMX      - Intel MMX  instruction set is available.
+      CPU_MMXPLUS  - Intel MMX+ instruction set is available.
+      CPU_SSE      - Intel SSE  instruction set is available.
+      CPU_SSE2     - Intel SSE2 instruction set is available.
+      CPU_SSE3     - Intel SSE3 instruction set is available.
+      CPU_3DNOW    - AMD 3DNow! instruction set is available.
+      CPU_ENH3DNOW - AMD Enhanced 3DNow! instruction set is
+                     available.
+      CPU_CMOV     - Pentium Pro "cmov" instruction is available.
+
+ You can check for multiple features by OR-ing the flags together. + For example, to check if the CPU has an FPU and MMX instructions + available, you'd do: +
+      if ((cpu_capabilities & (CPU_FPU | CPU_MMX)) ==
+          (CPU_FPU | CPU_MMX)) {
+         printf("CPU has both an FPU and MMX instructions!\n");
+      }
+
+ You can read this variable after you have called check_cpu() (which is + automatically called by allegro_init()). + + + + +
See also: +check_cpu, +cpu_vendor, +cpu_family, +cpu_model, +cpu_capabilities, +allegro_init.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg001.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg001.html new file mode 100644 index 0000000..538f335 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg001.html @@ -0,0 +1,656 @@ + + +Allegro Manual: Structures and types defined by Allegro + + + + +

Structures and types defined by Allegro

+ + + +

+There are several structures and types defined by Allegro which are used +in many functions (like the BITMAP structure). This section of the manual +describes their useful content from a user point of view when they don't fit +very well any of the existing manual sections, and redirects you to the +appropiate section when it's already described there. Note that unless stated +otherwise, the contents shown here are just for read only purposes, there +might be other internal flags, but you shouldn't depend on them being +available in past/future versions of Allegro. + +


+

typedef long fixed

+ This is a fixed point integer which can replace float with similar results + and is faster than float on low end machines. Read chapter "Fixed point + math routines" for the full explanation. + + +
See also: +Fixed point math routines.
+ +
Examples using this: +ex12bit, +ex3buf, +ex3d, +excustom, +exfixed, +exspline, +exsprite, +exstars, +exupdate.
+
typedef struct BITMAP

+
+   int w, h;               - size of the bitmap in pixels
+   int clip;               - non-zero if clipping is turned on
+   int cl, cr, ct, cb;     - clip rectangle left, right, top,
+                             and bottom
+   unsigned char *line[];  - pointers to the start of each line
+
+ There is some other stuff in the structure as well, but it is liable to + change and you shouldn't use anything except the above. The `w' and `h' + fields can be used to obtain the size of an existing bitmap: +
+      bmp = load_bitmap("file.bmp", pal);
+      allegro_message("Bitmap size: (%dx%d)\n", bmp->w, bmp->h);
+
+ The clipping rectangle is inclusive on the left and top (0 allows drawing + to position 0) but exclusive on the right and bottom (10 allows drawing + to position 9, but not to 10). Note this is not the same format as that of + the clipping API, which takes inclusive coordinates for all four corners. + All the values of this structure should be regarded as read-only, with the + exception of the line field, whose access is described in depth in the + "Direct access to video memory" section of the manual. If you want to + modify the clipping region, please refrain from changing this structure. + Use set_clip_rect() instead. + + +
See also: +create_bitmap, +set_clip_rect, +bitmap_color_depth, +RLE_SPRITE, +COMPILED_SPRITE, +Direct access to video memory.
+ +
Examples using this: +Available Allegro examples.
+
typedef struct RLE_SPRITE

+
+   int w, h;           - width and height in pixels
+   int color_depth;    - color depth of the image
+
+ RLE sprites store the image in a simple run-length encoded format, where + repeated zero pixels are replaced by a single length count, and strings of + non-zero pixels are preceded by a counter giving the length of the solid + run. Read chapter "RLE sprites" for a description of the restrictions and + how to obtain/use this structure. + + +
See also: +get_rle_sprite, +BITMAP, +COMPILED_SPRITE, +RLE sprites.
+
typedef struct COMPILED_SPRITE

+
+   short planar;        - set if it's a planar (mode-X) sprite
+   short color_depth;   - color depth of the image
+   short w, h;          - size of the sprite
+
+ Compiled sprites are stored as actual machine code instructions that draw + a specific image onto a bitmap, using mov instructions with immediate data + values. Read chapter "Compiled sprites" for a description of the + restrictions and how to obtain/use this structure. + + +
See also: +get_compiled_sprite, +BITMAP, +RLE_SPRITE, +Compiled sprites.
+
typedef struct JOYSTICK_INFO

+
+   int flags;                       - status flags for this
+                                      joystick
+   int num_sticks;                  - how many stick inputs?
+   int num_buttons;                 - how many buttons?
+   JOYSTICK_STICK_INFO stick[n];    - stick state information
+   JOYSTICK_BUTTON_INFO button[n];  - button state information
+
+ Read chapter "Joystick routines" for a description on how to obtain/use + this structure. + + +
See also: +joy, +Joystick routines.
+
typedef struct JOYSTICK_BUTTON_INFO

+
+   int b;                           - boolean on/off flag
+   char *name;                      - description of this
+                                      button
+
+ Read chapter "Joystick routines" for a description on how to obtain/use + this structure. + + +
See also: +joy, +Joystick routines.
+
typedef struct JOYSTICK_STICK_INFO

+
+   int flags;                       - status flags for this
+                                      input
+   int num_axis;                    - how many axes do we
+                                      have? (note the misspelling)
+   JOYSTICK_AXIS_INFO axis[n];      - axis state information
+   char *name;                      - description of this
+                                      input
+
+ Read chapter "Joystick routines" for a description on how to obtain/use + this structure. + + +
See also: +joy, +Joystick routines.
+
typedef struct JOYSTICK_AXIS_INFO

+
+   int pos;                         - analogue axis position
+   int d1, d2;                      - digital axis position
+   char *name;                      - description of this axis
+
+ Read chapter "Joystick routines" for a description on how to obtain/use + this structure. + + +
See also: +joy, +Joystick routines.
+
typedef struct GFX_MODE_LIST

+
+   int num_modes;
+   GFX_MODE *mode;
+
+ Structure returned by get_gfx_mode_list, which contains an array of + GFX_MODE structures. + + +
See also: +GFX_MODE, +get_gfx_mode_list.
+
typedef struct GFX_MODE

+
+   int width, height, bpp;
+
+ Structure contained in GFX_MODE_LIST. + + +
See also: +GFX_MODE_LIST, +get_gfx_mode_list.
+
#define PAL_SIZE

+ Preprocessor constant equal to 256. + + +
See also: +RGB, +PALETTE, +COLOR_MAP.
+
typedef PALETTE RGB[PAL_SIZE]

+ Allegro palettes are arrays of PAL_SIZE RGB entries. + + +
See also: +RGB, +Palette routines.
+ +
Examples using this: +Available Allegro examples.
+
typedef struct RGB

+
+   unsigned char r, g, b;
+
+ Palette entry. It contains an additional field for the purpose of padding + but you should not usually care about it. Read chapter "Palette routines" + for a description on how to obtain/use this structure. + + +
See also: +Palette routines, +PALETTE.
+ +
Examples using this: +ex12bit, +ex3d, +excolmap, +exconfig, +expal, +exrgbhsv, +exscroll, +exshade, +extrans, +extruec.
+
typedef struct V3D

+
+   fixed x, y, z;       - position
+   fixed u, v;          - texture map coordinates
+   int c;               - color
+
+ A vertex structure used by polygon3d and other polygon rendering + functions. Read the description of polygon3d() for a description on how + to obtain/use this structure. + + +
See also: +V3D_f, +polygon3d, +Fixed point trig.
+ +
Examples using this: +ex3d.
+
typedef struct V3D_f

+
+   float x, y, z;       - position
+   float u, v;          - texture map coordinates
+   int c;               - color
+
+ Like V3D but using float values instead of fixed ones. Read the + description of polygon3d_f() for a description on how to obtain/use this + structure. + + +
See also: +V3D, +polygon3d_f, +Fixed point trig.
+ +
Examples using this: +excamera, +exscn3d, +exzbuf.
+
typedef struct COLOR_MAP

+
+   unsigned char data[PAL_SIZE][PAL_SIZE];
+
+ Read chapter "Transparency and patterned drawing", section "256-color + transparency" for a description on how to obtain/use this structure. + + +
See also: +256-color transparency, +color_map.
+ +
Examples using this: +ex3d, +excolmap, +exlights, +exshade, +extrans.
+
typedef struct RGB_MAP

+
+   unsigned char data[32][32][32];
+
+ Read chapter "Converting between color formats" for a description on how + to obtain/use this structure. + + +
See also: +Converting between color formats, +create_rgb_table.
+ +
Examples using this: +ex3d, +excolmap, +exrgbhsv, +exshade, +extrans.
+
struct al_ffblk

+
+   int attrib;       - actual attributes of the file found
+   time_t time;      - modification time of file
+   char name[512];   - name of file
+
+ Read the description of al_findfirst for a description on how to + obtain/use this structure. + + +
See also: +al_findfirst, +al_ffblk_get_size.
+
typedef struct DATAFILE

+
+   void *dat;     - pointer to the actual data
+   int type;      - type of the data
+   long size;     - size of the data in bytes
+   void *prop;    - list of object properties
+
+ Read chapter "Datafile routines", section "Using datafiles" for a + description on how to obtain/use this structure. + + +
See also: +load_datafile, +Using datafiles.
+ +
Examples using this: +excustom, +exdata, +exexedat, +exgui, +exsprite, +exunicod.
+
typedef struct MATRIX

+
+   fixed v[3][3];           - 3x3 scaling and rotation component
+   fixed t[3];              - x/y/z translation component
+
+ Fixed point matrix structure. Read chapter "3D math routines" for a + description on how to obtain/use this structure. + + +
See also: +MATRIX_f, +3D math routines.
+ +
Examples using this: +ex12bit, +ex3d, +exstars.
+
typedef struct MATRIX_f

+
+   float v[3][3];           - 3x3 scaling and rotation component
+   float t[3];              - x/y/z translation component
+
+ Floating point matrix structure. Read chapter "3D math routines" for a + description on how to obtain/use this structure. + + +
See also: +MATRIX, +3D math routines.
+ +
Examples using this: +excamera, +exquat, +exscn3d, +exzbuf.
+
typedef struct QUAT

+
+   float w, x, y, z;
+
+ Read chapter "Quaternion math routines" for a description on how to + obtain/use this structure. + + +
See also: +Quaternion math routines.
+ +
Examples using this: +exquat.
+
typedef struct DIALOG

+
+   int (*proc)(int, DIALOG *, int); - dialog procedure
+                                      (message handler)
+   int x, y, w, h;       - position and size of the object
+   int fg, bg;           - foreground and background colors
+   int key;              - ASCII keyboard shortcut
+   int flags;            - flags about the status of the object
+   int d1, d2;           - whatever you want to use them for
+   void *dp, *dp2, *dp3; - pointers to more object-specific data
+
+ This is the structure which contains a GUI object. Read chapter "GUI + routines" for a description on how to obtain/use this structure. + + +
See also: +do_dialog, +GUI routines.
+ +
Examples using this: +excustom, +exgui, +exrgbhsv.
+
typedef struct MENU

+
+   char *text;          - the text to display for the menu item
+   int (*proc)(void);   - called when the menu item is clicked
+   struct MENU *child;  - nested child menu
+   int flags;           - disabled or checked state
+   void *dp;            - pointer to any data you need
+
+ Structure used to hold an entry of a menu. Read chapter "GUI routines", + section "GUI menus" for a description on how to obtain/use this structure. + + +
See also: +do_menu, +GUI menus.
+ +
Examples using this: +exgui.
+
typedef struct DIALOG_PLAYER

+ A structure which holds GUI data used internally by Allegro. Read the + documentation of init_dialog() for a description on how to obtain/use this + structure. + + +
See also: +init_dialog, +update_dialog, +shutdown_dialog, +GUI routines.
+
typedef struct MENU_PLAYER

+ A structure which holds GUI data used internally by Allegro. Read the + documentation of init_menu() for a description on how to obtain/use this + structure. + + +
See also: +init_menu, +update_menu, +shutdown_menu, +GUI menus.
+
typedef struct FONT

+ A structure holding an Allegro font, usually created beforehand with the + grabber tool or Allegro's default font. Read chapter "Fonts" for a + description on how to load/destroy fonts, and chapter "Text output" for a + description on how to show text. + + +
See also: +font.
+ +
Examples using this: +excustom, +exfont, +exunicod.
+
typedef struct BITMAP ZBUFFER

+ Structure used by Allegro's 3d zbuffered rendering functions. You are not + supposed to mix ZBUFFER with BITMAP even though it is currently possible + to do so. This is just an internal representation, and it may change in + the future. + + +
See also: +Zbuffered rendering, +BITMAP.
+ +
Examples using this: +exzbuf.
+
typedef struct SAMPLE

+
+   int bits;                   - 8 or 16
+   int stereo;                 - sample type flag
+   int freq;                   - sample frequency
+   int priority;               - 0-255
+   unsigned long len;          - length (in samples)
+   unsigned long loop_start;   - loop start position
+   unsigned long loop_end;     - loop finish position
+   void *data;                 - raw sample data
+
+ A sample structure, which holds sound data, used by the digital sample + routines. You can consider all of these fields as read only except + priority, loop_start and loop_end, which you can change them for example + after loading a sample from disk. + +

+ The priority is a value from 0 to 255 (by default set to 128) and controls + how hardware voices on the sound card are allocated if you attempt to play + more than the driver can handle. This may be used to ensure that the less + important sounds are cut off while the important ones are preserved. + +

+ The variables loop_start and loop_end specify the loop position in sample + units, and are set by default to the start and end of the sample. + +

+ If you are creating your own samples on the fly, you might also want to + modify the raw data of the sample pointed by the data field. The sample + data are always in unsigned format. This means that if you are loading a + PCM encoded sound file with signed 16-bit samples, you would have to XOR + every two bytes (i.e. every sample value) with 0x8000 to change the + signedness. + + +

See also: +load_sample, +Digital sample routines, +Voice control.
+ +
Examples using this: +exsample.
+
typedef struct MIDI

+ A structure holding MIDI data. Read chapter "Music routines (MIDI)" for a + description on how to obtain/use this structure. + + +
See also: +load_midi, +Music routines (MIDI).
+ +
Examples using this: +exmidi.
+
typedef struct AUDIOSTREAM

+
+   int voice;  - the hardware voice used for the sample
+
+ A structure holding an audiostream, which is a convenience wrapper around + a SAMPLE structure to double buffer sounds too big to fit into memory, or + do clever things like generating the sound wave real time. + +

+ While you shouldn't modify directly the value of the voice, you can use + all of the voice functions in chapter "Digital sample routines" to modify + the properties of the sound, like the frequency. + + +

See also: +play_audio_stream, +Audio stream routines, +Voice control.
+ +
Examples using this: +exstream.
+
typedef struct PACKFILE

+ A packfile structure, similar to the libc FILE structure. Read chapter + "File and compression routines" for a description on how to obtain/use + this structure. Note that prior to version 4.1.18, some internal fields + were accidentally documented - but PACKFILE should be treated as an + opaque structure, just like the libc FILE type. + + +
See also: +File and compression routines, +pack_fopen, +pack_fopen_chunk, +pack_fopen_vtable.
+ +
Examples using this: +expackf.
+
typedef struct PACKFILE_VTABLE

+
+   int pf_fclose(void *userdata);
+   int pf_getc(void *userdata);
+   int pf_ungetc(int c, void *userdata);
+   long pf_fread(void *p, long n, void *userdata);
+   int pf_putc(int c, void *userdata);
+   long pf_fwrite(const void *p, long n, void *userdata);
+   int pf_fseek(void *userdata, int offset);
+   int pf_feof(void *userdata);
+   int pf_ferror(void *userdata);
+
+ This is the vtable which must be provided for custom packfiles, which then + can read from and write to wherever you like (eg. files in memory). You + should provide all the entries of the vtable, even if they are empty stubs + doing nothing, to avoid Allegro (or you) calling a NULL method at some + point. + + +
See also: +File and compression routines, +pack_fopen_vtable.
+ +
Examples using this: +expackf.
+
typedef struct LZSS_PACK_DATA

+ Opaque structure for handling LZSS compression. Read chapter "File and + compression routines for a description on how to obtain/use this + structure. + + +
See also: +File and compression routines, +create_lzss_pack_data.
+
typedef struct LZSS_UNPACK_DATA

+ Opaque structure for handling LZSS decompression. Read chapter "File and + compression routines for a description on how to obtain/use this + structure. + + + + +
See also: +File and compression routines, +create_lzss_unpack_data.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg002.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg002.html new file mode 100644 index 0000000..276a4a3 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg002.html @@ -0,0 +1,1194 @@ + + +Allegro Manual: Unicode routines + + + + +

Unicode routines

+ + + +

+Allegro can manipulate and display text using any character values from 0 +right up to 2^32-1 (although the current implementation of the grabber can +only create fonts using characters up to 2^16-1). You can choose between a +number of different text encoding formats, which controls how strings are +stored and how Allegro interprets strings that you pass to it. This setting +affects all aspects of the system: whenever you see a function that returns +a char * type, or that takes a char * as an argument, that text will be in +whatever format you have told Allegro to use. + +

+By default, Allegro uses UTF-8 encoded text (U_UTF8). This is a +variable-width format, where characters can occupy anywhere from one to four +bytes. The nice thing about it is that characters ranging from 0-127 are +encoded directly as themselves, so UTF-8 is upwardly compatible with 7-bit +ASCII ("Hello, World!" means the same thing regardless of whether you +interpret it as ASCII or UTF-8 data). Any character values above 128, such +as accented vowels, the UK currency symbol, and Arabic or Chinese +characters, will be encoded as a sequence of two or more bytes, each in the +range 128-255. This means you will never get what looks like a 7-bit ASCII +character as part of the encoding of a different character value, which +makes it very easy to manipulate UTF-8 strings. + +

+There are a few editing programs that understand UTF-8 format text files. +Alternatively, you can write your strings in plain ASCII or 16-bit Unicode +formats, and then use the Allegro textconv program to convert them into +UTF-8. + +

+If you prefer to use some other text format, you can set Allegro to work +with normal 8-bit ASCII (U_ASCII), or 16-bit Unicode (U_UNICODE) instead, or +you can provide some handler functions to make it support whatever other +text encoding you like (for example it would be easy to add support for 32 +bit UCS-4 characters, or the Chinese GB-code format). + +

+There is some limited support for alternative 8-bit codepages, via the +U_ASCII_CP mode. This is very slow, so you shouldn't use it for serious +work, but it can be handy as an easy way to convert text between different +codepages. By default the U_ASCII_CP mode is set up to reduce text to a +clean 7-bit ASCII format, trying to replace any accented vowels with their +simpler equivalents (this is used by the allegro_message() function when it +needs to print an error report onto a text mode DOS screen). If you want to +work with other codepages, you can do this by passing a character mapping +table to the set_ucodepage() function. + +

+Note that you can use the Unicode routines before you call install_allegro() +or allegro_init(). If you want to work in a text mode other than UTF-8, it +is best to set it with set_uformat() just before you call these. + +


+

void set_uformat(int type);

+ Sets the current text encoding format. This will affect all parts of + Allegro, wherever you see a function that returns a char *, or takes a + char * as a parameter. `type' should be one of these values: +
+      U_ASCII     - fixed size, 8-bit ASCII characters
+      U_ASCII_CP  - alternative 8-bit codepage (see set_ucodepage())
+      U_UNICODE   - fixed size, 16-bit Unicode characters
+      U_UTF8      - variable size, UTF-8 format Unicode characters
+
+ Although you can change the text format on the fly, this is not a good + idea. Many strings, for example the names of your hardware drivers and + any language translations, are loaded when you call allegro_init(), so if + you change the encoding format after this, they will be in the wrong + format, and things will not work properly. Generally you should only call + set_uformat() once, before allegro_init(), and then leave it on the same + setting for the duration of your program. + + +
See also: +get_uformat, +register_uformat, +set_ucodepage, +set_uformat, +uconvert, +ustrsize, +ugetc, +ugetx, +usetc, +uwidth, +ucwidth, +uisok, +uoffset, +ugetat, +usetat, +uinsert, +uremove, +allegro_init.
+ +
Examples using this: +exunicod.
+
int get_uformat(void);

+ Finds out what text encoding format is currently selected. This function + is probably useful only if you are writing an Allegro addon dealing with + text strings and you use a different codepath for each possible format. + Example: +
+      switch(get_uformat()) {
+         case U_ASCII:
+            do_something();
+            break;
+         case U_UTF8:
+            do_something_else();
+            break;
+         ...
+      }
+

Return value: + Returns the currently selected text encoding format. See the documentation + of set_uformat() for a list of encoding formats. + + +

See also: +set_uformat.
+
void register_uformat(int type, + int (*u_getc)(const char *s), + int (*u_getx)(char **s), + int (*u_setc)(char *s, int c), + int (*u_width)(const char *s), + int (*u_cwidth)(int c), + int (*u_isok)(int c));

+ Installs a set of custom handler functions for a new text encoding + format. The `type' is the ID code for your new format, which should be a + 4-character string as produced by the AL_ID() macro, and which can later + be passed to functions like set_uformat() and uconvert(). The function + parameters are handlers that implement the character access for your new + type: see below for details of these. + + +
See also: +set_uformat, +uconvert, +ugetc, +ugetx, +usetc, +uwidth, +ucwidth, +uisok.
+
void set_ucodepage(const unsigned short *table, + const unsigned short *extras);

+ When you select the U_ASCII_CP encoding mode, a set of tables are used to + convert between 8-bit characters and their Unicode equivalents. You can + use this function to specify a custom set of mapping tables, which allows + you to support different 8-bit codepages. + +

+ The `table' parameter points to an array of 256 shorts, which contain the + Unicode value for each character in your codepage. The `extras' parameter, + if not NULL, points to a list of mapping pairs, which will be used when + reducing Unicode data to your codepage. Each pair consists of a Unicode + value, followed by the way it should be represented in your codepage. + The list is terminated by a zero Unicode value. This allows you to create + a many->one mapping, where many different Unicode characters can be + represented by a single codepage value (eg. for reducing accented vowels + to 7-bit ASCII). + +

+ Allegro will use the `table' parameter when it needs to convert an ASCII + string to an Unicode string. But when Allegro converts an Unicode string + to ASCII, it will use both parameters. First, it will loop through the + `table' parameter looking for an index position pointing at the unicode + value it is trying to convert (ie. the `table' parameter is also used for + reverse matching). If that fails, the `extras' list is used. If that fails + too, Allegro will put the character `^', giving up the conversion. + +

+ Note that Allegro comes with a default `table' and `extras' parameters + set internally. The default `table' will convert 8-bit characters to `^'. + The default `extras' list reduces Latin-1 and Extended-A characters to 7 + bits in a sensible way (eg. an accented vowel will be reduced to the same + vowel without the accent). + + +

See also: +set_uformat.
+
int need_uconvert(const char *s, int type, int newtype);

+ Given a pointer to a string (`s'), a description of the type of the string + (`type'), and the type that you would like this string to be converted into + (`newtype'), this function tells you whether any conversion is required. No + conversion will be needed if `type' and `newtype' are the same, or if one + type is ASCII, the other is UTF-8, and the string contains only character + values less than 128. As a convenience shortcut, you can pass the value + U_CURRENT as either of the type parameters, to represent whatever text + encoding format is currently selected. Example: +
+      if (need_uconvert(text, U_UTF8, U_CURRENT)) {
+         /* conversion is required */
+      }
+

Return value: + Returns non-zero if any conversion is required or zero otherwise. + + +

See also: +set_uformat, +get_uformat, +do_uconvert, +uconvert.
+
int uconvert_size(const char *s, int type, int newtype);

+ Finds out how many bytes are required to store the specified string `s' + after a conversion from `type' to `newtype', including the mandatory zero + terminator of the string. You can use U_CURRENT for either `type' or + `newtype' as a shortcut to represent whatever text encoding format is + currently selected. Example: +
+      length = uconvert_size(old_string, U_CURRENT, U_UNICODE);
+      new_string = malloc(length);
+      ustrcpy(new_string, old_string);
+

Return value: + Returns the number of bytes required to store the string after conversion. + + +

See also: +need_uconvert, +do_uconvert.
+
void do_uconvert(const char *s, int type, + char *buf, int newtype, int size);

+ Converts the specified string `s' from `type' to `newtype', storing at most + `size' bytes into the output `buf'. The type parameters can use the value + U_CURRENT as a shortcut to represent the currently selected encoding + format. Example: +
+      char temp_string[256];
+      do_uconvert(input_string, U_CURRENT, temp_string, U_ASCII, 256);
+
+ Note that, even for empty strings, your destination string must have at + least enough bytes to store the terminating null character of the string, + and your parameter size must reflect this. Otherwise, the debug version of + Allegro will abort at an assertion, and the release version of Allegro + will overrun the destination buffer. + + +
See also: +uconvert.
+
char *uconvert(const char *s, int type, + char *buf, int newtype, int size);

+ Higher level function running on top of do_uconvert(). This function + converts the specified string `s' from `type' to `newtype', storing at most + `size' bytes into the output `buf' (including the terminating null + character), but it checks before doing the conversion, and doesn't bother + if the string formats are already the same (either both types are equal, or + one is ASCII, the other is UTF-8, and the string contains only 7-bit ASCII + characters). + +

+ As a convenience, if `buf' is NULL it will convert the string into an + internal static buffer and the `size' parameter will be ignored. You should + be wary of using this feature, though, because that buffer will be + overwritten the next time this routine is called, so don't expect the data + to persist across any other library calls. The static buffer may hold less + than 1024 characters, so you won't be able to convert large chunks of text. + Example: +

+      char *p = uconvert(input_string, U_CURRENT, buffer, U_ASCII, 256);
+

Return value: + Returns a pointer to `buf' (or the static buffer if you used NULL) if a + conversion was performed. Otherwise returns a copy of `s'. In any cases, + you should use the return value rather than assuming that the string will + always be moved to `buf'. + + +

See also: +set_uformat, +need_uconvert, +uconvert, +uconvert_ascii, +uconvert_toascii, +do_uconvert.
+
char *uconvert_ascii(const char *s, char buf[]);

+ Helper macro for converting strings from ASCII into the current encoding + format. Expands to uconvert(s, U_ASCII, buf, U_CURRENT, sizeof(buf)). + + +
See also: +uconvert.
+ +
Examples using this: +exunicod.
+
char *uconvert_toascii(const char *s, char buf[]);

+ Helper macro for converting strings from the current encoding format into + ASCII. Expands to uconvert(s, U_CURRENT, buf, U_ASCII, sizeof(buf)). + + +
See also: +uconvert.
+
extern char empty_string[];

+ You can't just rely on "" to be a valid empty string in any encoding + format. This global buffer contains a number of consecutive zeros, so it + will be a valid empty string no matter whether the program is running in + ASCII, Unicode, or UTF-8 mode. + +


+

int ugetc(const char *s);

+ Low level helper function for reading Unicode text data. Example: +
+      int first_unicode_letter = ugetc(text_string);
+

Return value: + Returns the character pointed to by `s' in the current encoding format. + + +

See also: +ugetx, +usetc, +uwidth, +ucwidth, +uisok.
+
int ugetx(char **s);

+
int ugetxc(const char **s);

+ Low level helper function for reading Unicode text data. ugetxc is provided + for working with pointer-to-pointer-to-const char data. Example: +
+      char *p = string;
+      int first_letter, second_letter, third_letter;
+      first_letter = ugetx(&p);
+      second_letter = ugetx(&p);
+      third_letter = ugetx(&p);
+

Return value: + Returns the character pointed to by `s' in the current encoding format, and + advances the pointer to the next character after the one just returned. + + +

See also: +ugetc, +usetc, +uwidth, +ucwidth, +uisok.
+
int usetc(char *s, int c);

+ Low level helper function for writing Unicode text data. Writes the + character `c' to the address pointed to by `s'. +

Return value: + Returns the number of bytes written, which is equal to the width of the + character in the current encoding format. + + +

See also: +ugetc, +ugetx, +uwidth, +ucwidth, +uisok.
+
int uwidth(const char *s);

+ Low level helper function for testing Unicode text data. +

Return value: + Returns the number of bytes occupied by the first character of the + specified string, in the current encoding format. + + +

See also: +uwidth_max, +ugetc, +ugetx, +usetc, +ucwidth, +uisok.
+
int ucwidth(int c);

+ Low level helper function for testing Unicode text data. +

Return value: + Returns the number of bytes that would be occupied by the specified + character value, when encoded in the current format. + + +

See also: +uwidth_max, +ugetc, +ugetx, +usetc, +uwidth, +uisok.
+
int uisok(int c);

+ Low level helper function for testing Unicode text data. Finds out if the + character value `c' can be encoded correctly in the current format, which + can be useful if you are converting from Unicode to ASCII or another + encoding format where the range of valid characters is limited. +

Return value: + Returns non-zero if the value can be correctly encoded, zero otherwise. + + +

See also: +ugetc, +ugetx, +usetc, +uwidth, +ucwidth.
+
int uoffset(const char *s, int index);

+ Finds out the offset (in bytes from the start of the string) of the + character at the specified `index' in the string `s'. A zero `index' + parameter will return the first character of the string. If `index' is + negative, it counts backward from the end of the string, so an `index' of + `-1' will return an offset to the last character. Example: +
+      int from_third_letter = uoffset(text_string, 2);
+

Return value: + Returns the offset in bytes to the specified character. + + +

See also: +ugetat, +usetat, +uinsert, +uremove.
+
int ugetat(const char *s, int index);

+ Finds out the character value at the specified `index' in the string. A + zero `index' parameter will return the first character of the string. If + `index' is negative, it counts backward from the end of the string, so an + `index' of `-1' will return the last character of the string. Example: +
+      int third_letter = ugetat(text_string, 2);
+

Return value: + Returns the character value at the specified index in the string. + + +

See also: +uoffset, +usetat, +uinsert, +uremove.
+
int usetat(char *s, int index, int c);

+ Replaces the character at the specified index in the string with value `c', + handling any adjustments for variable width data (ie. if `c' encodes to a + different width than the previous value at that location). If `index' is + negative, it counts backward from the end of the string. Example: +
+      usetat(text_string, 2, letter_a);
+

Return value: + Returns the number of bytes by which the trailing part of the string was + moved. This is of interest only with text encoding formats where + characters have a variable length, like UTF-8. + + +

See also: +uoffset, +ugetat, +uinsert, +uremove.
+
int uinsert(char *s, int index, int c);

+ Inserts the character `c' at the specified `index' in the string, sliding + the rest of the data along to make room. If `index' is negative, it counts + backward from the end of the string. Example: +
+      uinsert(text_string, 0, prefix_letter);
+

Return value: + Returns the number of bytes by which the trailing part of the string was + moved. + + +

See also: +uoffset, +ugetat, +usetat, +uremove.
+
int uremove(char *s, int index);

+ Removes the character at the specified `index' within the string, sliding + the rest of the data back to fill the gap. If `index' is negative, it + counts backward from the end of the string. Example: +
+      int length_in_bytes = ustrsizez(text_string);
+      ...
+      length_in_bytes -= uremove(text_string, -1);
+

Return value: + Returns the number of bytes by which the trailing part of the string was + moved. + + +

See also: +uoffset, +ugetat, +usetat, +uinsert.
+
int ustrsize(const char *s);

+ Returns the size of the specified string in bytes, not including the + trailing null character. + + +
See also: +ustrsizez, +empty_string.
+ +
Examples using this: +exunicod.
+
int ustrsizez(const char *s);

+ Returns the size of the specified string in bytes, including the trailing + null character. + + +
See also: +ustrsize, +empty_string.
+ +
Examples using this: +exunicod.
+
int uwidth_max(int type);

+ Low level helper function for working with Unicode text data. Returns the + largest number of bytes that one character can occupy in the given + encoding format. Pass U_CURRENT to represent the current format. Example: +
+      char *temp_buffer = malloc(256 * uwidth_max(U_UTF8));
+ + +
See also: +uwidth, +ucwidth.
+
int utolower(int c);

+ This function returns `c', converting it to lower case if it is upper case. + + +
See also: +utoupper, +ugetc, +ugetx, +usetc, +uwidth, +ucwidth, +uisok.
+
int utoupper(int c);

+ This function returns `c', converting it to upper case if it is lower case. + + +
See also: +utolower, +ugetc, +ugetx, +usetc, +uwidth, +ucwidth, +uisok.
+
int uisspace(int c);

+ Returns nonzero if `c' is whitespace, that is, carriage return, newline, + form feed, tab, vertical tab, or space. Example: +
+      for (counter = 0; counter < ustrlen(text_string); counter++) {
+         if (uisspace(ugetat(text_string, counter)))
+            usetat(text_string, counter, '_');
+      }
+ + +
See also: +uisdigit, +ugetc, +usetc, +uwidth, +ucwidth, +uisok.
+
int uisdigit(int c);

+ Returns nonzero if `c' is a digit. +
+      for (counter = 0; counter < ustrlen(text_string); counter++) {
+         if (uisdigit(ugetat(text_string, counter)))
+            usetat(text_string, counter, '*');
+      }
+ + +
See also: +uisspace, +ugetc, +usetc, +uwidth, +ucwidth, +uisok.
+
char *ustrdup(const char *src)

+ This functions copies the null-terminated string `src' into a newly + allocated area of memory, effectively duplicating it. Example: +
+      void manipulate_string(const char *input_string)
+      {
+         char *temp_buffer = ustrdup(input_string);
+         /* Now we can modify temp_buffer */
+         ...
+

Return value: + Returns the newly allocated string. This memory must be freed by the + caller. Returns NULL if it cannot allocate space for the duplicated string. + + +

See also: +_ustrdup, +uconvert, +ustrsize, +ustrsizez.
+ +
Examples using this: +exconfig.
+
char *_ustrdup(const char *src, void* (*malloc_func)(size_t))

+ Does the same as ustrdup(), but allows the user to specify a custom memory + allocator function. + + +
See also: +ustrdup, +uconvert, +ustrsize, +ustrsizez.
+
char *ustrcpy(char *dest, const char *src);

+ This function copies `src' (including the terminating null character into + `dest'. You should try to avoid this function because it is very easy to + overflow the destination buffer. Use ustrzcpy instead. +

Return value: + Returns the value of dest. + + +

See also: +uconvert, +ustrzcpy, +ustrncpy.
+ +
Examples using this: +exunicod.
+
char *ustrzcpy(char *dest, int size, const char *src);

+ This function copies `src' (including the terminating NULL character into + `dest', whose length in bytes is specified by `size' and which is + guaranteed to be null-terminated even if `src' is bigger than `size'. + +

+ Note that, even for empty strings, your destination string must have at + least enough bytes to store the terminating null character of the string, + and your parameter size must reflect this. Otherwise, the debug version of + Allegro will abort at an assertion, and the release version of Allegro + will overrun the destination buffer. +

Return value: + Returns the value of `dest'. + + +

See also: +uconvert, +ustrcpy, +ustrzncpy.
+ +
Examples using this: +ex3buf, +exgui.
+
char *ustrcat(char *dest, const char *src);

+ This function concatenates `src' to the end of `dest`'. You should try to + avoid this function because it is very easy to overflow the destination + buffer, use ustrzcat instead. +

Return value: + Returns the value of `dest'. + + +

See also: +uconvert, +ustrzcat, +ustrncat.
+ +
Examples using this: +exunicod.
+
char *ustrzcat(char *dest, int size, const char *src);

+ This function concatenates `src' to the end of `dest', whose length in + bytes is specified by `size' and which is guaranteed to be null-terminated + even when `src' is bigger than `size'. + +

+ Note that, even for empty strings, your destination string must have at + least enough bytes to store the terminating null character of the string, + and your parameter size must reflect this. Otherwise, the debug version of + Allegro will abort at an assertion, and the release version of Allegro + will overrun the destination buffer. +

Return value: + Returns the value of `dest'. + + +

See also: +uconvert, +ustrcat, +ustrzncat.
+ +
Examples using this: +exgui.
+
int ustrlen(const char *s);

+ This function returns the number of characters in `s'. Note that this + doesn't have to equal the string's size in bytes. + + +
See also: +uconvert, +ustrsize, +ustrsizez.
+
int ustrcmp(const char *s1, const char *s2);

+ This function compares `s1' and `s2'. +

Return value: + Returns zero if the strings are equal, a positive number if `s1' comes + after `s2' in the ASCII collating sequence, else a negative number. + + +

See also: +uconvert, +ustrsize, +ustrsizez, +ustrncmp, +ustricmp, +ustrnicmp.
+
char *ustrncpy(char *dest, const char *src, int n);

+ This function is like ustrcpy() except that no more than `n' characters + from `src' are copied into `dest'. If `src' is shorter than `n' characters, + null characters are appended to `dest' as padding until `n' characters have + been written. + +

+ Note that if `src' is longer than `n' characters, `dest' will not be + null-terminated. +

Return value: + The return value is the value of `dest'. + + +

See also: +uconvert, +ustrcpy, +ustrzncpy.
+
char *ustrzncpy(char *dest, int size, const char *src, int n);

+ This function is like ustrzcpy() except that no more than `n' characters + from `src' are copied into `dest'. If `src' is shorter than `n' characters, + null characters are appended to `dest' as padding until `n' characters have + been written. In any case, `dest' is guaranteed to be null-terminated. + +

+ Note that, even for empty strings, your destination string must have at + least enough bytes to store the terminating null character of the string, + and your parameter `size' must reflect this. Otherwise, the debug version + of Allegro will abort at an assertion, and the release version of Allegro + will overrun the destination buffer. +

Return value: + The return value is the value of `dest'. + + +

See also: +uconvert, +ustrzcpy, +ustrncpy.
+ +
Examples using this: +exkeys.
+
char *ustrncat(char *dest, const char *src, int n);

+ This function is like ustrcat() except that no more than `n' characters + from `src' are appended to the end of `dest'. If the terminating null + character in `src' is reached before `n' characters have been written, the + null character is copied, but no other characters are written. If `n' + characters are written before a terminating null is encountered, the + function appends its own null character to `dest', so that `n+1' characters + are written. You should try to avoid this function because it is very + easy to overflow the destination buffer. Use ustrzncat instead. +

Return value: + The return value is the value of `dest'. + + +

See also: +uconvert, +ustrcat, +ustrzncat.
+
char *ustrzncat(char *dest, int size, const char *src, int n);

+ This function is like ustrzcat() except that no more than `n' characters + from `src' are appended to the end of `dest'. If the terminating null + character in `src' is reached before `n' characters have been written, the + null character is copied, but no other characters are written. Note that + `dest' is guaranteed to be null-terminated. +

Return value: + The return value is the value of `dest'. + + +

See also: +uconvert, +ustrzcat, +ustrncat.
+
int ustrncmp(const char *s1, const char *s2, int n);

+ This function compares up to `n' characters of `s1' and `s2'. Example: +
+      if (ustrncmp(prefix, long_string, ustrlen(prefix)) == 0) {
+         /* long_string starts with prefix */
+      }
+

Return value: + Returns zero if the substrings are equal, a positive number if `s1' comes + after `s2' in the ASCII collating sequence, else a negative number. + + +

See also: +uconvert, +ustrsize, +ustrsizez, +ustrcmp, +ustricmp, +ustrnicmp.
+
int ustricmp(const char *s1, const char *s2);

+ This function compares `s1' and `s2', ignoring case. Example: +
+      if (ustricmp(string, user_input) == 0) {
+         /* string and user_input are equal (ignoring case) */
+      }
+

Return value: + Returns zero if the strings are equal, a positive number if `s1' comes + after `s2' in the ASCII collating sequence, else a negative number. + + +

See also: +uconvert, +ustrsize, +ustrsizez, +ustrnicmp, +ustrcmp, +ustrncmp.
+ +
Examples using this: +exconfig.
+
int ustrnicmp(const char *s1, const char *s2, int n);

+ This function compares up to `n' characters of `s1' and `s2', ignoring + case. Example: +
+      if (ustrnicmp(prefix, long_string, ustrlen(prefix)) == 0) {
+         /* long_string starts with prefix (ignoring case) */
+      }
+

Return value: + Returns zero if the strings are equal, a positive number if `s1' comes + after `s2' in the ASCII collating sequence, else a negative number. + + +

See also: +uconvert, +ustrsize, +ustrsizez, +ustricmp, +ustrcmp, +ustrncmp.
+
char *ustrlwr(char *s);

+ This function replaces all upper case letters in `s' with lower case + letters. Example: +
+      char buffer[] = "UPPER CASE STRING";
+      allegro_message(ustrlwr(buffer));
+

Return value: + The return value is the value of `s'. + + +

See also: +uconvert, +utolower, +ustrupr.
+
char *ustrupr(char *s);

+ This function replaces all lower case letters in `s' with upper case + letters. Example: +
+      char buffer[] = "lower case string";
+      allegro_message(ustrupr(buffer));
+

Return value: + The return value is the value of `s'. + + +

See also: +uconvert, +utolower, +ustrlwr.
+
char *ustrchr(const char *s, int c);

+ Finds the first occurrence of the character `c' in the string `s'. Example: +
+      char *p = ustrchr("one,two,three,four", ',');
+

Return value: + Returns a pointer to the first occurrence of `c' in `s', or NULL if no + match was found. Note that if `c' is NULL, this will return a pointer to + the end of the string. + + +

See also: +uconvert, +ustrrchr, +ustrstr, +ustrpbrk, +ustrtok.
+
char *ustrrchr(const char *s, int c);

+ Finds the last occurrence of the character `c' in the string `s'. Example: +
+      char *p = ustrrchr("one,two,three,four", ',');
+

Return value: + Returns a pointer fo the last occurrence of `c' in `s', or NULL if no + match was found. + + +

See also: +uconvert, +ustrchr, +ustrstr, +ustrpbrk, +ustrtok.
+
char *ustrstr(const char *s1, const char *s2);

+ This function finds the first occurence of string `s2' in string `s1'. + Example: +
+      char *p = ustrstr("hello world", "world");
+

Return value: + Returns a pointer within `s1', or NULL if `s2' wasn't found. + + +

See also: +uconvert, +ustrchr, +ustrrchr, +ustrpbrk, +ustrtok.
+
char *ustrpbrk(const char *s, const char *set);

+ This function finds the first character in `s' that matches any character + in `set'. Example: +
+      char *p = ustrpbrk("one,two-three.four", "-. ");
+

Return value: + Returns a pointer to the first match, or NULL if none are found. + + +

See also: +uconvert, +ustrchr, +ustrrchr, +ustrstr, +ustrtok.
+
char *ustrtok(char *s, const char *set);

+ This function retrieves tokens from `s' which are delimited by characters + from `set'. To initiate the search, pass the string to be searched as `s'. + For the remaining tokens, pass NULL instead. Warning: Since ustrtok alters + the string it is parsing, you should always copy the string to a temporary + buffer before parsing it. Also, this function is not reentrant (ie. you + cannot parse two strings at the same time). Example: +
+      char *word;
+      char string[]="some-words with dashes";
+      char *temp = ustrdup(string);
+      word = ustrtok(temp, " -");
+      while (word) {
+         allegro_message("Found `%s'\n", word);
+         word = ustrtok(NULL, " -");
+      }
+      free(temp);
+

Return value: + Returns a pointer to the token, or NULL if no more are found. + + +

See also: +uconvert, +ustrchr, +ustrrchr, +ustrstr, +ustrpbrk, +ustrtok_r, +allegro_message, +ustrncpy.
+ +
Examples using this: +exgui.
+
char *ustrtok_r(char *s, const char *set, char **last);

+ Reentrant version of ustrtok. The `last' parameter is used to keep track + of where the parsing is up to and must be a pointer to a char * variable + allocated by the user that remains the same while parsing the same + string. Example: +
+      char *word, *last;
+      char string[]="some-words with dashes";
+      char *temp = ustrdup(string);
+      word = ustrtok_r(string, " -", &last);
+      while (word) {
+         allegro_message("Found `%s'\n", word);
+         word = ustrtok_r(NULL, " -", &last);
+      }
+      free(temp);
+

Return value: + Returns a pointer to the token, or NULL if no more are found. You can free + the memory pointed to by `last' once NULL is returned. + + +

See also: +ustrtok.
+
double uatof(const char *s);

+ Convert as much of the string as possible to an equivalent double + precision real number. This function is almost like `ustrtod(s, NULL)'. +

Return value: + Returns the equivalent value, or zero if the string does not represent a + number. + + +

See also: +uconvert, +ustrtol, +ustrtod.
+
long ustrtol(const char *s, char **endp, int base);

+ This function converts the initial part of `s' to a signed integer, setting + `*endp' to point to the first unused character, if `endp' is not a NULL + pointer. The `base' argument indicates what base the digits (or letters) + should be treated as. If `base' is zero, the base is determined by looking + for `0x', `0X', or `0' as the first part of the string, and sets the base + used to 16, 16, or 8 if it finds one. The default base is 10 if none of + those prefixes are found. Example: +
+      char *endp, *string = "456.203 askdfg";
+      int number = ustrtol(string, &endp, 10);
+

Return value: + Returns the string converted as a value of type `long int'. If nothing was + converted, returns zero with `*endp' pointing to the beginning of `s'. + + +

See also: +uconvert, +ustrtod, +uatof.
+
double ustrtod(const char *s, char **endp);

+ This function converts as many characters of `s' that look like a floating + point number into one, and sets `*endp' to point to the first unused + character, if `endp' is not a NULL pointer. Example: +
+      char *endp, *string = "456.203 askdfg";
+      double number = ustrtod(string, &endp);
+

Return value: + Returns the string converted as a value of type `double'. If nothing was + converted, returns zero with *endp pointing to the beginning of s. + + +

See also: +uconvert, +ustrtol, +uatof.
+
const char *ustrerror(int err);

+ This function returns a string that describes the error code `err', which + normally comes from the variable `errno'. Example: +
+      PACKFILE *input_file = pack_fopen("badname", "r");
+      if (input_file == NULL)
+         allegro_message("%s\nSorry!\n", ustrerror(errno));
+

Return value: + Returns a pointer to a static string that should not be modified or + freed. If you make subsequent calls to ustrerror(), the string will be + overwritten. + + +

See also: +uconvert, +allegro_error.
+
int usprintf(char *buf, const char *format, ...);

+ This function writes formatted data into the output buffer. A NULL + character is written to mark the end of the string. You should try to avoid + this function because it is very easy to overflow the destination buffer. + Use uszprintf instead. +

Return value: + Returns the number of characters written, not including the terminating + null character. + + +

See also: +uconvert, +uszprintf, +uvsprintf.
+ +
Examples using this: +exkeys.
+
int uszprintf(char *buf, int size, const char *format, ...);

+ This function writes formatted data into the output buffer, whose length + in bytes is specified by `size' and which is guaranteed to be NULL + terminated. Example: +
+      char buffer[10];
+      int player_score;
+      ...
+      uszprintf(buffer, sizeof(buffer), "Your score is: %d", player_score);
+

Return value: + Returns the number of characters that would have been written without + eventual truncation (like with usprintf), not including the terminating + null character. + + +

See also: +uconvert, +usprintf, +uvszprintf.
+ +
Examples using this: +exgui.
+
int uvsprintf(char *buf, const char *format, va_list args);

+ This is like usprintf(), but you pass the variable argument list directly, + instead of the arguments themselves. You can use this function to implement + printf like functions, also called variadic functions. You should try to + avoid this function because it is very easy to overflow the destination + buffer. Use uvszprintf instead. +

Return value: + Returns the number of characters written, not including the terminating + null character. + + +

See also: +uconvert, +usprintf, +uvszprintf.
+
int uvszprintf(char *buf, int size, const char *format, va_list args);

+ This is like uszprintf(), but you pass the variable argument list + directly, instead of the arguments themselves. Example: +
+      #include <stdarg.h>
+
+      void log_message(const char *format, ...)
+      {
+         char buffer[100];
+         va_list parameters;
+         
+         va_start(parameters, format);
+         uvszprintf(buffer, sizeof(buffer), format, parameters);
+         va_end(parameters);
+         
+         append_buffer_to_logfile(log_name, buffer);
+         send_buffer_to_other_networked_players(multicast_ip, buffer);
+         and_also_print_it_on_the_screen(cool_font, buffer);
+      }
+      
+      void some_other_function(void)
+      {
+         log_message("Hello %s, are you %d years old?\n", "Dave", 25);
+      }
+

Return value: + Returns the number of characters that would have been written without + eventual truncation (like with uvsprintf), not including the terminating + null character. + + + + +

See also: +uconvert, +uszprintf, +uvsprintf.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg003.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg003.html new file mode 100644 index 0000000..9b266ce --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg003.html @@ -0,0 +1,979 @@ + + +Allegro Manual: Configuration routines + + + + +

Configuration routines

+ + + +

+Various parts of Allegro, such as the sound routines and the +load_joystick_data() function, require some configuration information. This +data is stored in text files as a collection of `variable=value' lines, +along with comments that begin with a `#' character and continue to the end +of the line. The configuration file may optionally be divided into sections, +which begin with a `[sectionname]' line. Each section has a unique +namespace, to prevent variable name conflicts, but any variables that aren't +in a section are considered to belong to all the sections simultaneously. + +

+By default the configuration data is read from a file called `allegro.cfg', +which can be located either in the same directory as the program executable, +or the directory pointed to by the ALLEGRO environment variable. Under Unix, +it also checks for `~/allegro.cfg', `~/.allegrorc', `/etc/allegro.cfg', and +`/etc/allegrorc', in that order; under BeOS only the last two are also +checked. MacOS X also checks in the Contents/Resources directory of the +application bundle, if any, before doing the checks above. + +

+If you don't like this approach, you can specify any filename you like, or +use a block of binary configuration data provided by your program (which +could for example be loaded from a datafile). You can also extend the paths +searched for allegro resources with set_allegro_resource_path(). + +

+You can store whatever custom information you like in the config file, along +with the standard variables that are used by Allegro (see below). Allegro +comes with a setup directory where you can find configuration programs. The +standalone setup program is likely to be of interest to final users. It +allows any user to create an `allegro.cfg' file without the need to touch a +text editor and enter values by hand. It also provides a few basic tests like +sound playing for soundcard testing. You are welcome to include the setup +program with your game, either as is or with modified graphics to fit better +your game. + +


+

void set_config_file(const char *filename);

+ Sets the configuration file to be used by all subsequent config + functions. If you don't call this function, Allegro will use the default + `allegro.cfg' file, looking first in the same directory as your program + and then in the directory pointed to by the ALLEGRO environment variable + and the usual platform-specific paths for configuration files. For example + it will look for `/etc/allegro.cfg' under Unix. + +

+ All pointers returned by previous calls to get_config_string() and + other related functions are invalidated when you call this function! + You can call this function before install_allegro() to change the + configuration file, but after set_uformat() if you want to use a text + encoding format other than the default. + + +

See also: +set_config_data, +override_config_file, +push_config_state, +set_uformat, +Standard config variables, +set_config_string, +get_config_string.
+ +
Examples using this: +exconfig.
+
void set_config_data(const char *data, int length);

+ Specifies a block of data to be used by all subsequent config functions, + which you have already loaded from disk (eg. as part of some more + complicated format of your own, or in a grabber datafile). This routine + makes a copy of the information, so you can safely free the data after + calling it. + + +
See also: +set_config_file, +override_config_data, +push_config_state, +Standard config variables, +set_config_string, +get_config_string.
+
void override_config_file(const char *filename);

+ Specifies a file containing config overrides. These settings will be used + in addition to the parameters in the main config file, and where a + variable is present in both files this version will take priority. This + can be used by application programmers to override some of the config + settings from their code, while still leaving the main config file free + for the end user to customise. For example, you could specify a + particular sample frequency and IBK instrument file, but the user could + still use an `allegro.cfg' file to specify the port settings and irq + numbers. + +

+ The override config file will not only take precedence when reading, but + will also be used for storing values. When you are done with using the + override config file, you can call override_config_file with a NULL + parameter, so config data will be directly read from the current config + file again. + +

+ Note: The override file is completely independent from the current + configuration. You can e.g. call set_config_file, and the override file + will still be active. Also the flush_config_file function will only affect + the current config file (which can be changed with set_config_file), never + the overriding one specified with this function. The modified override + config is written back to disk whenever you call override_config_file. + +

+ Example: +

+      override_config_file("my.cfg");
+      /* This will read from my.cfg, and if it doesn't find a
+       * setting, will read from the current config file instead.
+       */
+      language = get_config_string("system", "language", NULL);
+      /* This will always write to my.cfg, no matter if the
+       * settings is already present or not.
+       */
+      set_config_string("system", "language", "RU");
+      /* This forces the changed setting to be written back to
+       * disk. Else it is written back at the next call to
+       * override_config_file, or when Allegro shuts down.
+       */
+      override_config_file(NULL);
+ +

+ Note that this function and override_config_data() are mutually exclusive, + i.e. calling one will cancel the effects of the other. + + +

See also: +override_config_data, +set_config_file.
+
void override_config_data(const char *data, int length);

+ Version of override_config_file() which uses a block of data that has + already been read into memory. The length of the block has to be specified + in bytes. Example: +
+      /* Force German as system language, Spanish keyboard map. */
+      const char *override_data = "[system]\n"
+         "language=DE\n"
+         "keyboard=ES";
+      override_config_data(override_data, ustrsize(override_data));
+ +

+ Note that this function and override_config_file() are mutually exclusive, + i.e. calling one will cancel the effects of the other. + + +

See also: +override_config_file, +set_config_data.
+
void push_config_state();

+ Pushes the current configuration state (filename, variable values, etc). + onto an internal stack, allowing you to select some other config source + and later restore the current settings by calling pop_config_state(). + This function is mostly intended for internal use by other library + functions, for example when you specify a config filename to the + save_joystick_data() function, it pushes the config state before + switching to the file you specified. + + +
See also: +pop_config_state, +set_config_file, +save_joystick_data.
+ +
Examples using this: +exconfig.
+
void pop_config_state();

+ Pops a configuration state previously stored by push_config_state(), + replacing the current config source with it. + + +
See also: +push_config_state.
+ +
Examples using this: +exconfig.
+
void flush_config_file();

+ Writes the current config file to disk if the contents have changed + since it was loaded or since the latest call to the function. + + +
See also: +set_config_file, +override_config_file, +push_config_state.
+
void reload_config_texts(const char *new_language);

+ Reloads the translated strings returned by get_config_text(). This is + useful to switch to another language in your program at runtime. If you + want to modify the `[system]' language configuration variable yourself, or + you have switched configuration files, you will want to pass NULL to + just reload whatever language is currently selected. Or you can pass a + string containing the two letter code of the language you desire to + switch to, and the function will modify the language variable. After you + call this function, the previously returned pointers of get_config_text() + will be invalid. Example: +
+      ...
+      /* The user selects French from a language choice menu. */
+      reload_config_texts("FR");
+ + +
See also: +get_config_text, +get_config_string, +Standard config variables.
+
void hook_config_section(const char *section, + int (*intgetter)(const char *name, int def), + const char *(*stringgetter)(const char *name, const char *def), + void (*stringsetter)(const char *name, const char *value));

+ Takes control of the specified config file section, so that your hook + functions will be used to manipulate it instead of the normal disk file + access. If both the getter and setter functions are NULL, a currently + present hook will be unhooked. Hooked functions have the highest + priority. If a section is hooked, the hook will always be called, so you + can also hook a '#' section: even override_config_file() cannot override + a hooked section. Example: +
+      int decode_encrypted_int(const char *name, int def)
+      {
+         ...
+      }
+      
+      const char *decode_encrypted_string(const char *name, const char *def)
+      {
+         ...
+      }
+      
+      void encode_plaintext_string(const char *name, const char *value)
+      {
+         ...
+      }
+      
+      int main(int argc, char *argv[])
+      {
+         ...
+         /* Make it harder for users to tinker with the high scores. */
+         hook_config_section("high_scores", decode_encrypted_int,
+            decode_encrypted_string, encode_plaintext_string);
+         ...
+      } END_OF_MAIN()
+ + +
See also: +config_is_hooked.
+
int config_is_hooked(const char *section);

+ Returns TRUE if the specified config section has been hooked. Example: +
+      if (config_is_hooked("high_scores")) {
+         hook_config_section("high_scores, NULL, NULL, NULL);
+      }
+ + +
See also: +hook_config_section.
+
const char *get_config_string(const char *section, + const char *name, const char *def);

+ Retrieves a string variable from the current config file. The section name + may be set to NULL to read variables from the root of the file, or used to + control which set of parameters (eg. sound or joystick) you are interested + in reading. Example: +
+      const char *lang = get_config_string("system", "language", "EN");
+
+

Return value: + Returns a pointer to the constant string found in the configuration file. + If the named variable cannot be found, or its entry in the config file is + empty, the value of `def' is returned. + + +

See also: +set_config_file, +set_config_string, +get_config_argv, +get_config_float, +get_config_hex, +get_config_int, +get_config_id, +get_config_text.
+ +
Examples using this: +exconfig.
+
int get_config_int(const char *section, const char *name, int def);

+ Reads an integer variable from the current config file. See the comments + about get_config_string(). + + +
See also: +set_config_file, +set_config_int, +get_config_string, +get_config_argv, +get_config_float, +get_config_hex, +get_config_id.
+ +
Examples using this: +exconfig.
+
int get_config_hex(const char *section, const char *name, int def);

+ Reads an integer variable from the current config file, in hexadecimal + format. See the comments about get_config_string(). + + +
See also: +set_config_file, +set_config_hex, +get_config_string, +get_config_argv, +get_config_float, +get_config_int, +get_config_id.
+
float get_config_float(const char *section, const char *name, float def);

+ Reads a floating point variable from the current config file. See the + comments about get_config_string(). + + +
See also: +set_config_file, +set_config_float, +get_config_string, +get_config_argv, +get_config_hex, +get_config_int, +get_config_id.
+
int get_config_id(const char *section, const char *name, int def);

+ Reads a 4-letter driver ID variable from the current config file. See the + comments about get_config_string(). + + +
See also: +set_config_file, +set_config_id, +get_config_string, +get_config_argv, +get_config_float, +get_config_hex, +get_config_int.
+
char **get_config_argv(const char *section, const char *name, int *argc);

+ Reads a token list (words separated by spaces) from the current config + file. The token list is stored in a temporary buffer that will be clobbered + by the next call to get_config_argv(), so the data should not be expected + to persist. +

Return value: + Returns an argv style argument list and sets `argc' to the number of + retrieved tokens. If the variable is not present, returns NULL and sets + argc to zero. + + +

See also: +set_config_file, +get_config_string, +get_config_float, +get_config_hex, +get_config_int, +get_config_id.
+ +
Examples using this: +exconfig.
+
const char *get_config_text(const char *msg);

+ This function is primarily intended for use by internal library code, but + it may perhaps be helpful to application programmers as well. It uses the + `language.dat' or `XXtext.cfg' files (where XX is a language code) to look + up a translated version of the parameter in the currently selected + language. + +

+ This is basically the same thing as calling get_config_string() with + `[language]' as the section, `msg' as the variable name, and `msg' as the + default value, but it contains some special code to handle Unicode format + conversions. The `msg' parameter is always given in ASCII format, but the + returned string will be converted into the current text encoding, with + memory being allocated as required, so you can assume that this pointer + will persist without having to manually allocate storage space for each + string. + +

+ Note that if you are planning on distributing your game on the Unix + platform there is a special issue with how to deal with the `language.dat' + file. Read section "Files shared by Allegro" of the chapter "Unix + specifics" to learn more about this. +

Return value: + Returns a suitable translation if one can be found or a copy of the + parameter if nothing else is available. + + +

See also: +get_config_string, +reload_config_texts, +Standard config variables.
+
void set_config_string(const char *section, const char *name, + const char *val);

+ Writes a string variable to the current config file, replacing any + existing value it may have, or removes the variable if `val' is NULL. The + section name may be set to NULL to write the variable to the root of the + file, or used to control which section the variable is inserted into. The + altered file will be cached in memory, and not actually written to disk + until you call allegro_exit(). Note that you can only write to files in + this way, so the function will have no effect if the current config + source was specified with set_config_data() rather than set_config_file(). + +

+ As a special case, variable or section names that begin with a '#' + character are treated specially and will not be read from or written to + the disk. Addon packages can use this to store version info or other + status information into the config module, from where it can be read with + the get_config_string() function. + + +

See also: +set_config_file, +get_config_string, +set_config_float, +set_config_hex, +set_config_int, +set_config_id.
+
void set_config_int(const char *section, const char *name, int val);

+ Writes an integer variable to the current config file. See the comments + about set_config_string(). + + +
See also: +set_config_file, +get_config_int, +set_config_string, +set_config_float, +set_config_hex, +set_config_id.
+
void set_config_hex(const char *section, const char *name, int val);

+ Writes an integer variable to the current config file, in hexadecimal + format. See the comments about set_config_string(). + + +
See also: +set_config_file, +get_config_hex, +set_config_string, +set_config_float, +set_config_int, +set_config_id.
+
void set_config_float(const char *section, const char *name, float val);

+ Writes a floating point variable to the current config file. See the + comments about set_config_string(). + + +
See also: +set_config_file, +get_config_float, +set_config_string, +set_config_hex, +set_config_int, +set_config_id.
+
void set_config_id(const char *section, const char *name, int val);

+ Writes a 4-letter driver ID variable to the current config file. See the + comments about set_config_string(). + + +
See also: +set_config_file, +get_config_id, +set_config_string, +set_config_float, +set_config_hex, +set_config_int.
+
int list_config_entries(const char *section, const char ***names);

+ This function can be used to get a list of all entries in the given config + section. The names parameter is a pointer to an array of strings. If it + points to a NULL pointer, the list will be allocated, else it will be + re-allocated. You should free the list again with free_config_entries if you + don't need it anymore, or you can pass it again to list_config_entries and + the memory will be re-used. See the following example for how you can use it, + it will print out the complete contents of the current configuration: +
+   int i, n;
+   char const **sections = NULL;
+   char const **entries = NULL;
+
+   n = list_config_sections(&sections);
+   /* loop through all section names */
+   for (i = 0; i < n; i++)
+   {
+      int j, m;
+      printf("%s\n", sections[i]);
+      m = list_config_entries(sections[i], &entries);
+      /* loop through all entries in the section */
+      for (j = 0; j < m; j++)
+      {
+          printf(" %s=\"%s\"\n", entries[j], get_config_string(
+             sections[i], entries[j], "-"));
+      }
+   }
+   free_config_entries(&sections);
+   free_config_entries(&entries);
+

Return value: + Returns the number of valid strings in the names array. + + +

See also: +set_config_file, +get_config_string, +list_config_sections, +free_config_entries.
+
int list_config_sections(const char ***names);

+ The names parameter is a pointer to an array of strings. If it points to a + NULL pointer, the list will be allocated, else it will be re-allocated. After + the function returns, it will contain the names of all sections in the + current configuration. Use free_config_entries to free the allocated memory + again. See list_config_entries for more information and an example how to use + it. +

Return value: + Returns the number of valid strings in the names array. + + +

See also: +list_config_entries, +set_config_file, +get_config_string, +free_config_entries.
+
int free_config_entries(const char ***names);

+ +

+ Once you are done with the string arrays filled in by list_config_entries and + list_config_sections, you can free them again with this function. The passed + array pointer will be set to NULL, and you directly can pass the same pointer + again to list_config_entries or list_config_sections later - but you also + could pass them again without freeing first, since the memory is re-allocated + when the pointer is not NULL. + +

+ See list_config_entries for an example of how to use it. + + +

See also: +list_config_entries, +list_config_sections.
+

Standard config variables

+Allegro uses these standard variables from the configuration file: +

+ + + +
See also: +set_config_file, +set_config_string, +get_config_string.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg004.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg004.html new file mode 100644 index 0000000..b77126b --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg004.html @@ -0,0 +1,579 @@ + + +Allegro Manual: Mouse routines + + + + +

Mouse routines

+ + + +

+Allegro provides functions for reading the mouse state and displaying a mouse +cursor on-screen. You can read the absolute position of the mouse and the +state of the mouse buttons from global variables. Additionally, you can read +the mouse position difference as mouse mickeys, which is the number of pixels +the cursor moved since the last time this information was read. + +

+Allegro offers three ways to display the mouse cursor: +

+Not all drivers will support all functionality. See the platform specific +information for more details. + +


+

int install_mouse();

+ Installs the Allegro mouse handler. You must do this before using any + other mouse functions. +

Return value: + Returns -1 on failure, zero if the mouse handler is already installed (in + which case this function does nothing) and the number of buttons on the + mouse if the mouse handler has successfully been installed (ie. this is + the first time a handler is installed or you have removed the previous + one). + +

+ Note that the number of mouse buttons returned by this function is more + an indication than a physical reality. With most devices there is no way + of telling how many buttons there are, and any user can override the + number of mouse buttons returned by this function with a custom + configuration file and the variable num_buttons. Even if this value is + overriden by the user, the global mouse variables will still report + whatever the hardware is sending. + + +

See also: +remove_mouse, +poll_mouse, +mouse_x, +show_mouse, +get_mouse_mickeys, +position_mouse, +set_mouse_range, +set_mouse_speed, +Standard config variables.
+ +
Examples using this: +Available Allegro examples.
+
void remove_mouse();

+ Removes the mouse handler. You don't normally need to bother calling + this, because allegro_exit() will do it for you. + + +
See also: +install_mouse, +allegro_exit.
+
int poll_mouse();

+ Wherever possible, Allegro will read the mouse input asynchronously (ie. + from inside an interrupt handler), but on some platforms that may not be + possible, in which case you must call this routine at regular intervals + to update the mouse state variables. To help you test your mouse polling + code even if you are programming on a platform that doesn't require it, + after the first time that you call this function Allegro will switch into + polling mode, so from that point onwards you will have to call this + routine in order to get any mouse input at all, regardless of whether the + current driver actually needs to be polled or not. +

Return value: + Returns zero on success, or a negative number on failure (ie. no mouse + driver installed). + + +

See also: +mouse_needs_poll, +install_mouse, +mouse_x.
+ +
Examples using this: +exlights, +exmouse, +exshade, +exspline, +extrans.
+
int mouse_needs_poll();

+ Returns TRUE if the current mouse driver is operating in polling mode. + + +
See also: +poll_mouse, +install_mouse, +mouse_x.
+
void enable_hardware_cursor(void);

+ After calling this function, Allegro will let the operating system draw the + mouse cursor instead of doing it itself. This is not possible with all + graphics drivers though: you'll need to check the gfx_capabilities flags + after calling show_mouse() to see if this works. On some platforms, enabling + the hardware cursor causes get_mouse_mickeys() to return only a limited + range of values, so you should not call this function if you need mouse + mickeys. + + +
See also: +install_mouse, +show_mouse, +set_mouse_sprite, +get_mouse_mickeys, +gfx_capabilities, +disable_hardware_cursor, +show_os_cursor.
+ +
Examples using this: +exsyscur.
+
void disable_hardware_cursor(void);

+ After calling this function, Allegro will be responsible for drawing the + mouse cursor rather than the operating system. On some platforms calling + enable_hardware_cursor() makes the return values of get_mouse_mickeys() + unreliable. After calling this function, get_mouse_mickeys() returns + reliable results again. + + +
See also: +install_mouse, +show_mouse, +set_mouse_sprite, +get_mouse_mickeys, +gfx_capabilities, +enable_hardware_cursor.
+
void select_mouse_cursor(int cursor);

+ This function allows you to use the operating system's native mouse + cursors rather than some custom cursor. You will need to enable this + functionality by calling enable_hardware_cursor() beforehand. If the + operating system does not support this functionality, or if it has + not been enabled, then Allegro will substitute its own cursor images. + You can change these substitute images using set_mouse_cursor_bitmap(). + +

+ Note that the effects of this function are not apparent until show_mouse() + is called. + +

+ To know whether the operating system's native cursor is being used, + or if Allegro has made a substitution, you can check the GFX_SYSTEM_CURSOR + flag in gfx_capabilities after calling show_mouse(). + +

+ The cursor argument selects the type of cursor to be displayed: + +

+ MOUSE_CURSOR_NONE
+ Selects an invisible mouse cursor. In that sense, it is similar to calling + show_mouse(NULL); + +

+ MOUSE_CURSOR_ALLEGRO
+ Selects the custom Allegro cursor, i.e. the one that you set with + set_mouse_sprite(). + +

+ MOUSE_CURSOR_ARROW
+ The operating system default arrow cursor. + +

+ MOUSE_CURSOR_BUSY
+ The operating system default `busy' cursor (hourglass). + +

+ MOUSE_CURSOR_QUESTION
+ The operating system default `question' cursor (arrow with question mark). + +

+ MOUSE_CURSOR_EDIT
+ The operating system default `edit' cursor (vertical bar). + +

+ Example: +

+   /* initialize mouse sub-system */
+   install_mouse();
+   enable_hardware_cursor();
+   
+   /* Set busy pointer */
+   select_mouse_cursor(MOUSE_CURSOR_BUSY);
+   show_mouse(screen);
+   
+   /* Initialize stuff */
+   ...
+   
+   /* Set normal arrow pointer */
+   select_mouse_cursor(MOUSE_CURSOR_ARROW);
+
+ + +
See also: +install_mouse, +show_mouse, +set_mouse_sprite, +gfx_capabilities, +enable_hardware_cursor, +set_mouse_cursor_bitmap, +show_os_cursor.
+ +
Examples using this: +exsyscur.
+
void set_mouse_cursor_bitmap(int cursor, BITMAP *bmp);

+ This function changes the cursor image Allegro uses if + select_mouse_cursor() is called but no native operating system cursor + can be used, e.g. because you did not call enable_hardware_cursor(). + +

+ The cursor argument can be one of:
+ MOUSE_CURSOR_ALLEGRO
+ MOUSE_CURSOR_ARROW
+ MOUSE_CURSOR_BUSY
+ MOUSE_CURSOR_QUESTION
+ MOUSE_CURSOR_EDIT
+ +

+ but not MOUSE_CURSOR_NONE. + +

+ The bmp argument can either point to a valid bitmap or it can be NULL. + Passing a bitmap makes Allegro use that image in place of its own + default substition (should the operating system's native cursor + be unavailable). The bitmap must remain available for the duration + in which it could be used. Passing NULL lets Allegro revert to its + default substitutions. + +

+ The effect of this function will not be apparent until show_mouse() is + called. + + +

See also: +install_mouse, +show_mouse, +set_mouse_sprite, +gfx_capabilities, +enable_hardware_cursor, +show_os_cursor.
+
extern volatile int mouse_x;

+
extern volatile int mouse_y;

+
extern volatile int mouse_z;

+
extern volatile int mouse_b;

+
extern volatile int mouse_pos;

+ Global variables containing the current mouse position and button state. + Wherever possible these values will be updated asynchronously, but if + mouse_needs_poll() returns TRUE, you must manually call poll_mouse() to + update them with the current input state. The `mouse_x' and `mouse_y' + positions are integers ranging from zero to the bottom right corner of + the screen. The `mouse_z' variable holds the current wheel position, when + using an input driver that supports wheel mice. The `mouse_b' variable is + a bitfield indicating the state of each button: bit 0 is the left button, + bit 1 the right, and bit 2 the middle button. Additional non standard + mouse buttons might be available as higher bits in this variable. Usage + example: +
+      if (mouse_b & 1)
+         printf("Left button is pressed\n");
+
+      if (!(mouse_b & 2))
+         printf("Right button is not pressed\n");
+
+ The `mouse_pos' variable has the current X coordinate in the upper 16 bits + and the Y in the lower 16 bits. This may be useful in tight polling loops + where a mouse interrupt could occur between your reading of the two + separate variables, since you can copy this value into a local variable + with a single instruction and then split it up at your leisure. Example: +
+   int pos, x, y;
+   
+   pos = mouse_pos;
+   x = pos >> 16;
+   y = pos & 0x0000ffff;
+
+ + + +
See also: +install_mouse, +poll_mouse, +mouse_needs_poll.
+ +
Examples using this: +exalpha, +exlights, +exmouse, +exshade, +exspline, +extrans.
+
extern BITMAP *mouse_sprite;

+
extern int mouse_x_focus;

+
extern int mouse_y_focus;

+ Global variables containing the current mouse sprite and the focus + point. These are read-only, and only to be modified using the + set_mouse_sprite() and set_mouse_sprite_focus() functions. + + +
See also: +set_mouse_sprite, +set_mouse_sprite_focus.
+
void show_mouse(BITMAP *bmp);

+ Tells Allegro to display a mouse pointer on the screen. This will only + work if the timer module has been installed. The mouse pointer will be + drawn onto the specified bitmap, which should normally be `screen' (see + later for information about bitmaps). To hide the mouse pointer, call + show_mouse(NULL). + +

+ Warning: if you draw anything onto the screen while the pointer is + visible, a mouse movement interrupt could occur in the middle of your + drawing operation. If this happens the mouse buffering and graphics drawing + code will get confused and will leave 'mouse droppings' all over the + screen. To prevent this, you must make sure you turn off the mouse + pointer whenever you draw onto the screen. This is not needed if you are + using a hardware cursor. + +

+ Note: you must not be showing a mouse pointer on a bitmap at the time that + the bitmap is destroyed with destroy_bitmap(), e.g. call show_mouse(NULL); + before destroying the bitmap. This does not apply to `screen' since you + never destroy `screen' with destroy_bitmap(). + + +

See also: +install_mouse, +install_timer, +set_mouse_sprite, +scare_mouse, +freeze_mouse_flag, +show_os_cursor.
+ +
Examples using this: +exmouse, +expal, +exshade, +exspline, +exsyscur.
+
void scare_mouse();

+ Helper for hiding the mouse pointer prior to a drawing operation. This + will temporarily get rid of the pointer, but only if that is really + required (ie. the mouse is visible, and is displayed on the physical + screen rather than some other memory surface, and it is not a hardware + or OS cursor). The previous mouse state is stored for subsequent calls to + unscare_mouse(). + + +
See also: +unscare_mouse, +scare_mouse_area, +show_mouse.
+
void scare_mouse_area(int x, int y, int w, int h);

+ Like scare_mouse(), but will only hide the cursor if it is inside the + specified rectangle. Otherwise the cursor will simply be frozen in place + until you call unscare_mouse(), so it cannot interfere with your drawing. + + +
See also: +unscare_mouse, +scare_mouse, +show_mouse.
+
void unscare_mouse();

+ Undoes the effect of a previous call to scare_mouse() or + scare_mouse_area(), restoring the original pointer state. + + +
See also: +scare_mouse, +scare_mouse_area.
+
int show_os_cursor(int cursor);

+ In case you do not need Allegro's mouse cursor API, which automatically + emulates a cursor in software if no other cursor is available, you can + use this low level function to try to display or hide the system cursor + directly. The cursor parameter takes the same values as + select_mouse_cursor. This function is very similar to calling + enable_hardware_cursor, select_mouse_cursor and show_mouse, but will + not try to do anything if no system cursor is available. + +

+ The most common use for this function is to just call it once at the + beginning of the program to tell it to display the system cursor inside + the Allegro window. The return value can be used to see if this + suceeded or not. On some systems (e.g. DirectX fullscreen) this is not + supported and the function will always fail, and in other cases only + some of the cursors will work, or in the case of MOUSE_CURSOR_ALLEGRO, + only certain bitmap sizes may be supported. + +

+ You never should use show_os_cursor together with the function + show_mouse and other functions affecting it (select_mouse_cursor, + enable_hardware_cursor, disable_hardware_cursor, scare_mouse, + unscare_mouse). They implement the standard high level mouse API, and + don't work together with this low level function. +

Return value: + Returns 0 if a system cursor is being displayed after the function + returns, or -1 otherwise. + + +

See also: +show_mouse, +set_mouse_cursor_bitmap, +select_mouse_cursor.
+
extern volatile int freeze_mouse_flag;

+ If this flag is set, the mouse pointer won't be redrawn when the mouse + moves. This can avoid the need to hide the pointer every time you draw to + the screen, as long as you make sure your drawing doesn't overlap with + the current pointer position. + + +
See also: +show_mouse.
+
void position_mouse(int x, int y);

+ Moves the mouse to the specified screen position. It is safe to call even + when a mouse pointer is being displayed. + + +
See also: +install_mouse, +position_mouse_z, +set_mouse_range, +set_mouse_speed.
+
void position_mouse_z(int z);

+ Sets the mouse wheel position variable to the specified value. + + +
See also: +install_mouse, +position_mouse.
+
void set_mouse_range(int x1, int y1, int x2, int y2);

+ Sets the area of the screen within which the mouse can move. Pass the top + left corner and the bottom right corner (inclusive). If you don't call + this function the range defaults to (0, 0, SCREEN_W-1, SCREEN_H-1). + + +
See also: +install_mouse, +set_mouse_speed, +position_mouse.
+
void set_mouse_speed(int xspeed, int yspeed);

+ Sets the mouse speed. Larger values of xspeed and yspeed represent slower + mouse movement: the default for both is 2. + + +
See also: +install_mouse, +set_mouse_range, +position_mouse.
+
void set_mouse_sprite(BITMAP *sprite);

+ You don't like Allegro's mouse pointer? No problem. Use this function to + supply an alternative of your own. If you change the pointer and then want + to get Allegro's lovely arrow back again, call set_mouse_sprite(NULL). + +

+ As a bonus, set_mouse_sprite(NULL) uses the current palette in choosing + colors for the arrow. So if your arrow mouse sprite looks ugly after + changing the palette, call set_mouse_sprite(NULL). + + +

See also: +install_mouse, +show_mouse, +set_mouse_sprite_focus.
+ +
Examples using this: +exmouse.
+
void set_mouse_sprite_focus(int x, int y);

+ The mouse focus is the bit of the pointer that represents the actual + mouse position, ie. the (mouse_x, mouse_y) position. By default this is + the top left corner of the arrow, but if you are using a different mouse + pointer you might need to alter it. + + +
See also: +set_mouse_sprite.
+ +
Examples using this: +exmouse.
+
void get_mouse_mickeys(int *mickeyx, int *mickeyy);

+ Measures how far the mouse has moved since the last call to this + function. The values of mickeyx and mickeyy will become negative if the + mouse is moved left or up, respectively. The mouse will continue to + generate movement mickeys even when it reaches the edge of the screen, so + this form of input can be useful for games that require an infinite range + of mouse movement. + +

+ Note that the infinite movement may not work in windowed mode, since under + some platforms the mouse would leave the window, and may not work at all + if the hardware cursor is in use. + + +

See also: +install_mouse.
+ +
Examples using this: +exmouse.
+
extern void (*mouse_callback)(int flags);

+ Called by the interrupt handler whenever the mouse moves or one of the + buttons changes state. This function must be in locked memory, and must + execute _very_ quickly! It is passed the event flags that triggered the + call, which is a bitmask containing any of the values MOUSE_FLAG_MOVE, + MOUSE_FLAG_LEFT_DOWN, MOUSE_FLAG_LEFT_UP, MOUSE_FLAG_RIGHT_DOWN, + MOUSE_FLAG_RIGHT_UP, MOUSE_FLAG_MIDDLE_DOWN, MOUSE_FLAG_MIDDLE_UP, and + MOUSE_FLAG_MOVE_Z. Note that even if the mouse has more than three buttons, + only the first three can be trapped using a callback. + + + + +
See also: +install_mouse.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg005.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg005.html new file mode 100644 index 0000000..5cbfb5a --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg005.html @@ -0,0 +1,334 @@ + + +Allegro Manual: Timer routines + + + + +

Timer routines

+ + + +

+Allegro can set up several virtual timer functions, all going at different +speeds. + +

+Under DOS it will constantly reprogram the clock to make sure they are all +called at the correct times. Because they alter the low level timer chip +settings, these routines should not be used together with other DOS timer +functions like the DJGPP uclock() routine. Moreover, the FPU state is not +preserved across Allegro interrupts so you ought not to use floating point +or MMX code inside timer interrupt handlers. + +

+Under other platforms, they are usually implemented using threads, which run +parallel to the main thread. Therefore timer callbacks on such platforms +will not block the main thread when called, so you may need to use +appropriate synchronisation devices (eg. mutexes, semaphores, etc.) when +accessing data that is shared by a callback and the main thread. (Currently +Allegro does not provide such devices.) + +


+

int install_timer();

+ Installs the Allegro timer interrupt handler. You must do this before + installing any user timer routines, and also before displaying a mouse + pointer, playing FLI animations or MIDI music, and using any of the GUI + routines. +

Return value: + Returns zero on success, or a negative number on failure (but you may + decide not to check the return value as this function is very unlikely to + fail). + + +

See also: +remove_timer, +install_int.
+ +
Examples using this: +Available Allegro examples.
+
void remove_timer();

+ Removes the Allegro timer handler (and, under DOS, passes control of the + clock back to the operating system). You don't normally need to bother + calling this, because allegro_exit() will do it for you. + + +
See also: +install_timer, +allegro_exit.
+
int install_int(void (*proc)(), int speed);

+ Installs a user timer handler, with the speed given as the number of + milliseconds between ticks. This is the same thing as + install_int_ex(proc, MSEC_TO_TIMER(speed)). If you call this routine + without having first installed the timer module, install_timer() will be + called automatically. Calling again this routine with the same timer + handler as parameter allows you to adjust its speed. +

Return value: + Returns zero on success, or a negative number if there is no room to add + a new user timer. + + +

See also: +install_timer, +remove_int, +install_int_ex, +install_param_int.
+ +
Examples using this: +exscn3d, +exswitch, +extimer, +exzbuf.
+
int install_int_ex(void (*proc)(), int speed);

+ Adds a function to the list of user timer handlers or, if it is already + installed, retroactively adjusts its speed (i.e makes as though the speed + change occured precisely at the last tick). The speed is given in hardware + clock ticks, of which there are 1193181 a second. You can convert from + other time formats to hardware clock ticks with the macros: +
+      SECS_TO_TIMER(secs)  - give the number of seconds between
+                             each tick
+      MSEC_TO_TIMER(msec)  - give the number of milliseconds
+                             between ticks
+      BPS_TO_TIMER(bps)    - give the number of ticks each second
+      BPM_TO_TIMER(bpm)    - give the number of ticks per minute
+
+ There can only be sixteen timers in use at a time, and some other parts of + Allegro (the GUI code, the mouse pointer display routines, rest(), the FLI + player, and the MIDI player) need to install handlers of their own, so you + should avoid using too many at the same time. If you call this routine + without having first installed the timer module, install_timer() will be + called automatically. + +

+ Your function will be called by the Allegro interrupt handler and not + directly by the processor, so it can be a normal C function and does not + need a special wrapper. You should be aware, however, that it will be + called in an interrupt context, which imposes a lot of restrictions on + what you can do in it. It should not use large amounts of stack, it must + not make any calls to the operating system, use C library functions, or + contain any floating point code, and it must execute very quickly. Don't + try to do lots of complicated code in a timer handler: as a general rule + you should just set some flags and respond to these later in your main + control loop. + +

+ In a DOS protected mode environment like DJGPP, memory is virtualised and + can be swapped to disk. Due to the non-reentrancy of DOS, if a disk swap + occurs inside an interrupt handler the system will die a painful death, + so you need to make sure you lock all the memory (both code and data) + that is touched inside timer routines. Allegro will lock everything it + uses, but you are responsible for locking your handler functions. The + macros LOCK_VARIABLE (variable), END_OF_FUNCTION (function_name), + END_OF_STATIC_FUNCTION (function_name), and LOCK_FUNCTION (function_name) + can be used to simplify this task. For example, if you want an interrupt + handler that increments a counter variable, you should write: +

+      volatile int counter;
+
+      void my_timer_handler()
+      {
+         counter++;
+      }
+
+      END_OF_FUNCTION(my_timer_handler)
+
+ and in your initialisation code you should lock the memory: +
+      LOCK_VARIABLE(counter);
+      LOCK_FUNCTION(my_timer_handler);
+
+ Obviously this can get awkward if you use complicated data structures and + call other functions from within your handler, so you should try to keep + your interrupt routines as simple as possible. +

Return value: + Returns zero on success, or a negative number if there is no room to add + a new user timer. + + +

See also: +install_timer, +remove_int, +install_int, +install_param_int_ex.
+ +
Examples using this: +excamera, +exsprite, +extimer, +exunicod, +exupdate.
+
Macro LOCK_VARIABLE(variable_name);

+ Due to interrupts, you are required to lock all the memory used by your + timer routines. See the description of install_int_ex() for a more + detailed explanation and usage example. + + +
See also: +install_int, +install_int_ex.
+ +
Examples using this: +exscn3d, +exsprite, +exswitch, +extimer, +exupdate, +exzbuf.
+
Macro LOCK_FUNCTION(function_name);

+ Due to interrupts, you are required to lock all the memory used by your + timer routines. See the description of install_int_ex() for a more + detailed explanation and usage example. + + +
See also: +install_int, +install_int_ex.
+ +
Examples using this: +exkeys, +exscn3d, +exsprite, +exswitch, +extimer, +exupdate, +exzbuf.
+
Macro END_OF_FUNCTION(function_name);

+ Due to interrupts, you are required to lock all the code used by your + timer routines. See the description of install_int_ex() for a more + detailed explanation and usage example. + + +
See also: +install_int, +install_int_ex.
+ +
Examples using this: +exkeys, +exscn3d, +exsprite, +exswitch, +extimer, +exupdate, +exzbuf.
+
void remove_int(void (*proc)());

+ Removes a function from the list of user interrupt routines. At program + termination, allegro_exit() does this automatically. + + +
See also: +install_int, +install_int_ex, +remove_param_int.
+
int install_param_int(void (*proc)(void *), void *param, int speed);

+ Like install_int(), but the callback routine will be passed a copy of the + specified void pointer parameter. To disable the handler, use + remove_param_int() instead of remove_int(). + + +
See also: +install_timer, +remove_param_int, +install_param_int_ex, +install_int.
+
int install_param_int_ex(void (*proc)(void *), void *param, int speed);

+ Like install_int_ex(), but the callback routine will be passed a copy of + the specified void pointer parameter. To disable the handler, use + remove_param_int() instead of remove_int(). + + +
See also: +install_timer, +remove_param_int, +install_param_int, +install_int_ex.
+
void remove_param_int(void (*proc)(void *), void *param);

+ Like remove_int(), but for use with timer callbacks that have parameter + values. If there is more than one copy of the same callback active at a + time, it identifies which one to remove by checking the parameter value + (so you can't have more than one copy of a handler using an identical + parameter). + + +
See also: +install_param_int, +install_param_int_ex, +remove_int.
+
extern volatile int retrace_count;

+ If the retrace simulator is installed, this count is incremented on each + vertical retrace; otherwise, if the refresh rate is known, the count is + incremented at the same rate (ignoring retraces); otherwise, it is + incremented 70 times a second. This provides a way of controlling + the speed of your program without installing user timer functions. + + +
Examples using this: +ex3d, +exblend, +exdbuf, +exflip, +exlights.
+
void rest(unsigned int time);

+ This function waits for the specified number of milliseconds. + +

+ Passing 0 as parameter will not wait, but just yield. This can be useful + in order to "play nice" with other processes. Other values will cause + CPU time to be dropped on most platforms. This will look better to + users, and also does things like saving battery power and making fans + less noisy. + +

+ Note that calling this inside your active game loop is a bad idea, as + you never know when the OS will give you the CPU back, so you could end + up missing the vertical retrace and skipping frames. On the other hand, + on multitasking operating systems it is good form to give up the CPU for + a while if you will not be using it. + + +

See also: +install_timer, +rest_callback, +vsync, +d_yield_proc.
+ +
Examples using this: +exkeys, +exmidi, +exquat, +exsample, +exsprite, +extimer, +extrans, +exunicod.
+
void rest_callback(long time, void (*callback)())

+ Like rest(), but for non-zero values continually calls the specified + function while it is waiting for the required time to elapse. If the + provided `callback' parameter is NULL, this function does exactly the + same thing as calling rest(). + + + + +
See also: +install_timer, +rest.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg006.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg006.html new file mode 100644 index 0000000..a55dd84 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg006.html @@ -0,0 +1,636 @@ + + +Allegro Manual: Keyboard routines + + + + +

Keyboard routines

+ + + +

+The Allegro keyboard handler provides both buffered input and a set of flags +storing the current state of each key. Note that it is not possible to +correctly detect every combination of keys, due to the design of the PC +keyboard. Up to two or three keys at a time will work fine, but if you press +more than that the extras are likely to be ignored (exactly which +combinations are possible seems to vary from one keyboard to another). + +

+On DOS, Allegro requires the user to specify the language of the keyboard +mapping because it is impossible to obtain this information from the OS, +otherwise the default US keyboard mapping will be used. Allegro comes with a +prepackaged `keyboard.dat' file which you can put along with your binary. If +this file is present, Allegro will be able to extract the keyboard mapping +information stored there. However, the end user still needs to select which +keyboard mapping to use. This can be acomplished through the keyboard variable +of the system section in a standard `allegro.cfg' configuration file. Read +chapter "Configuration routines" for more information about this. + +


+

int install_keyboard();

+ Installs the Allegro keyboard interrupt handler. You must call this + before using any of the keyboard input routines. Once you have set up the + Allegro handler, you can no longer use operating system calls or C + library functions to access the keyboard. + +

+ Note that on some platforms the keyboard won't work unless you have set a + graphics mode, even if this function returns a success value before + calling set_gfx_mode. This can happen in environments with graphic + windowed modes, since Allegro usually reads the keyboard through the + graphical window (which appears after the set_gfx_call). Example: +

+      allegro_init();
+      install_timer();
+      install_keyboard();
+      /* We are not 100% sure we can read the keyboard yet! */
+      if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0)
+         abort_on_error("Couldn't set graphic mode!")
+
+      /* Now we are guaranteed to be able to read the keyboard. */
+      readkey();
+

Return value: + Returns zero on success, or a negative number on failure (but you may + decide not to check the return value as this function is very unlikely to + fail). + + +

See also: +remove_keyboard, +poll_keyboard, +key, +keypressed, +readkey, +ureadkey, +keyboard_callback, +keyboard_ucallback, +keyboard_lowlevel_callback, +three_finger_flag, +key_led_flag, +set_leds, +set_keyboard_rate, +set_gfx_mode, +Standard config variables.
+ +
Examples using this: +Available Allegro examples.
+
void remove_keyboard();

+ Removes the keyboard handler, returning control to the operating system. + You don't normally need to bother calling this, because allegro_exit() + will do it for you. However, you might want to call this during runtime if + you want to change the keyboard mapping on those platforms were keyboard + mappings are needed. You would first modify the configuration variable + holding the keyboard mapping and then reinstall the keyboard handler. + Example: +
+      remove_keyboard();
+      /* Switch to Spanish keyboard mapping. */
+      set_config_string("system", "keyboard", "es");
+      install_keyboard();
+ + +
See also: +install_keyboard, +allegro_exit, +set_config_string.
+
void install_keyboard_hooks(int (*keypressed)(), int (*readkey)());

+ You should only use this function if you *aren't* using the rest of the + keyboard handler. It should be called in the place of install_keyboard(), + and lets you provide callback routines to detect and read keypresses, + which will be used by the main keypressed() and readkey() functions. This + can be useful if you want to use Allegro's GUI code with a custom + keyboard handler, as it provides a way for the GUI to get keyboard input + from your own code, bypassing the normal Allegro input system. + + +
See also: +install_keyboard, +keypressed, +readkey.
+
int poll_keyboard();

+ Wherever possible, Allegro will read the keyboard input asynchronously + (ie. from inside an interrupt handler), but on some platforms that may + not be possible, in which case you must call this routine at regular + intervals to update the keyboard state variables. + +

+ To help you test your keyboard polling code even if you are programming + on a platform that doesn't require it, after the first time that you + call this function Allegro will switch into polling mode, so from that + point onwards you will have to call this routine in order to get any + keyboard input at all, regardless of whether the current driver actually + needs to be polled or not. + +

+ The keypressed(), readkey(), and ureadkey() functions call poll_keyboard() + automatically, so you only need to use this function when accessing the + key[] array and key_shifts variable. +

Return value: + Returns zero on success, or a negative number on failure (ie. no keyboard + driver installed). + + +

See also: +keyboard_needs_poll, +install_keyboard, +key, +key_shifts.
+ +
Examples using this: +excamera, +exsample, +exstars.
+
int keyboard_needs_poll();

+ Returns TRUE if the current keyboard driver is operating in polling mode. + + +
See also: +poll_keyboard, +install_keyboard, +key.
+
extern volatile char key[KEY_MAX];

+ Array of flags indicating the state of each key, ordered by scancode. + Wherever possible these values will be updated asynchronously, but if + keyboard_needs_poll() returns TRUE, you must manually call + poll_keyboard() to update them with the current input state. The + scancodes are defined in allegro/keyboard.h as a series of KEY_* + constants (and are also listed below). For example, you could write: +
+      if (key[KEY_SPACE])
+         printf("Space is pressed\n");
+ +

+ Note that the array is supposed to represent which keys are physically + held down and which keys are not, so it is semantically read-only. + +

+ These are the keyboard scancodes: +

+      KEY_A ... KEY_Z,
+      KEY_0 ... KEY_9,
+      KEY_0_PAD ... KEY_9_PAD,
+      KEY_F1 ... KEY_F12,
+
+      KEY_ESC, KEY_TILDE, KEY_MINUS, KEY_EQUALS,
+      KEY_BACKSPACE, KEY_TAB, KEY_OPENBRACE, KEY_CLOSEBRACE,
+      KEY_ENTER, KEY_COLON, KEY_QUOTE, KEY_BACKSLASH,
+      KEY_BACKSLASH2, KEY_COMMA, KEY_STOP, KEY_SLASH,
+      KEY_SPACE,
+
+      KEY_INSERT, KEY_DEL, KEY_HOME, KEY_END, KEY_PGUP,
+      KEY_PGDN, KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN,
+
+      KEY_SLASH_PAD, KEY_ASTERISK, KEY_MINUS_PAD,
+      KEY_PLUS_PAD, KEY_DEL_PAD, KEY_ENTER_PAD,
+
+      KEY_PRTSCR, KEY_PAUSE,
+
+      KEY_ABNT_C1, KEY_YEN, KEY_KANA, KEY_CONVERT, KEY_NOCONVERT,
+      KEY_AT, KEY_CIRCUMFLEX, KEY_COLON2, KEY_KANJI,
+
+      KEY_LSHIFT, KEY_RSHIFT,
+      KEY_LCONTROL, KEY_RCONTROL,
+      KEY_ALT, KEY_ALTGR,
+      KEY_LWIN, KEY_RWIN, KEY_MENU,
+      KEY_SCRLOCK, KEY_NUMLOCK, KEY_CAPSLOCK
+
+      KEY_EQUALS_PAD, KEY_BACKQUOTE, KEY_SEMICOLON, KEY_COMMAND
+ +

+ Finally, you may notice an `odd' behaviour of the KEY_PAUSE key. This key + only generates an interrupt when it is pressed, not when it is released. + For this reason, Allegro pretends the pause key is a `state' key, which + is the only way to make it usable. + + +

See also: +install_keyboard, +poll_keyboard, +key_shifts.
+ +
Examples using this: +Available Allegro examples.
+
extern volatile int key_shifts;

+ Bitmask containing the current state of shift/ctrl/alt, the special + Windows keys, and the accent escape characters. Wherever possible this + value will be updated asynchronously, but if keyboard_needs_poll() + returns TRUE, you must manually call poll_keyboard() to update it with + the current input state. This can contain any of the flags: +
+      KB_SHIFT_FLAG
+      KB_CTRL_FLAG
+      KB_ALT_FLAG
+      KB_LWIN_FLAG
+      KB_RWIN_FLAG
+      KB_MENU_FLAG
+      KB_COMMAND_FLAG
+      KB_SCROLOCK_FLAG
+      KB_NUMLOCK_FLAG
+      KB_CAPSLOCK_FLAG
+      KB_INALTSEQ_FLAG
+      KB_ACCENT1_FLAG
+      KB_ACCENT2_FLAG
+      KB_ACCENT3_FLAG
+      KB_ACCENT4_FLAG
+ +

+ Example: +

+      if (key[KEY_W]) {
+         if (key_shifts & KB_SHIFT_FLAG) {
+            /* User is pressing shift + W. */
+         } else {
+            /* Hmmm... lower case W then. */
+         }
+      }
+ + +
See also: +install_keyboard, +poll_keyboard, +key.
+ +
Examples using this: +excamera, +exkeys.
+
int keypressed();

+ Returns TRUE if there are keypresses waiting in the input buffer. You can + use this to see if the next call to readkey() is going to block or to + simply wait for the user to press a key while you still update the screen + possibly drawing some animation. Example: +
+      while (!keypressed()) {
+         /* Show cool animated logo. */
+      }
+      /* So he skipped our title screen. */
+ + +
See also: +install_keyboard, +readkey, +ureadkey, +clear_keybuf, +simulate_keypress, +simulate_ukeypress.
+ +
Examples using this: +Available Allegro examples.
+
int readkey();

+ Returns the next character from the keyboard buffer, in ASCII format. If + the buffer is empty, it waits until a key is pressed. You can see if there + are queued keypresses with keypressed(). + +

+ The low byte of the return value contains the ASCII code of the key, and + the high byte the scancode. The scancode remains the same whatever the + state of the shift, ctrl and alt keys, while the ASCII code is affected by + shift and ctrl in the normal way (shift changes case, ctrl+letter gives + the position of that letter in the alphabet, eg. ctrl+A = 1, ctrl+B = 2, + etc). Pressing alt+key returns only the scancode, with a zero ASCII code + in the low byte. For example: +

+      int val;
+      ...
+      val = readkey();
+      if ((val & 0xff) == 'd')     /* by ASCII code */
+         allegro_message("You pressed 'd'\n");
+
+      if ((val >> 8) == KEY_SPACE) /* by scancode */
+         allegro_message("You pressed Space\n");
+
+      if ((val & 0xff) == 3)       /* ctrl+letter */
+         allegro_message("You pressed Control+C\n");
+
+      if (val == (KEY_X << 8))     /* alt+letter */
+         allegro_message("You pressed Alt+X\n");
+
+ This function cannot return character values greater than 255. If you + need to read Unicode input, use ureadkey() instead. + + +
See also: +install_keyboard, +ureadkey, +keypressed, +clear_keybuf, +simulate_keypress.
+ +
Examples using this: +Available Allegro examples.
+
int ureadkey(int *scancode);

+ Returns the next character from the keyboard buffer, in Unicode format. + If the buffer is empty, it waits until a key is pressed. You can see if + there are queued keypresses with keypressed(). The return value contains + the Unicode value of the key, and if not NULL, the pointer argument will + be set to the scancode. Unlike readkey(), this function is able to return + character values greater than 255. Example: +
+      int val, scancode;
+      ...
+      val = ureadkey(&scancode);
+      if (val == 0x00F1)
+         allegro_message("You pressed n with tilde\n");
+
+      if (val == 0x00DF)
+         allegro_message("You pressed sharp s\n");
+
+ You should be able to find Unicode character maps at + http://www.unicode.org/. Remember that on DOS you must specify a custom + keyboard map (like those found in `keyboard.dat') usually with the help of + a configuration file specifying the language mapping (keyboard variable in + system section of `allegro.cfg'), or you will get the default US keyboard + mapping. + + +
See also: +install_keyboard, +readkey, +keypressed, +clear_keybuf, +simulate_ukeypress.
+ +
Examples using this: +exkeys.
+
int scancode_to_ascii(int scancode);

+ Converts the given scancode to an ASCII character for that key (mangling + Unicode values), returning the unshifted uncapslocked result of pressing + the key, or zero if the key isn't a character-generating key or the lookup + can't be done. The lookup cannot be done for keys like the F1-F12 keys or the + cursor keys, and some drivers will only return approximate values. Generally, + if you want to display the name of a key to the user, you should use the + scancode_to_name function. + +

+ Example: +

+      int ascii;
+      ...
+      ascii = scancode_to_ascii(scancode);
+      allegro_message("You pressed '%c'\n", ascii);
+ + +
See also: +scancode_to_name.
+
const char *scancode_to_name(int scancode);

+ This function returns a string pointer containing the name of they key with + the given scancode. This is useful if you e.g. let the user choose a key for + some action, and want to display something more meaningful than just the + scancode. Example: +
+      char const *keyname = scancode_to_name(scancode);
+      allegro_message("You pressed the %s key.", keyname);
+ + +
See also: +scancode_to_ascii.
+ +
Examples using this: +exkeys.
+
void simulate_keypress(int key);

+ Stuffs a key into the keyboard buffer, just as if the user had pressed + it. The parameter is in the same format returned by readkey(). Example: +
+      simulate_keypress(KEY_SPACE << 8);
+      if (readkey() == (KEY_SPACE << 8))
+         allegro_message("You simulated Alt+Space\n");
+ + +
See also: +install_keyboard, +simulate_ukeypress, +keypressed, +readkey.
+
void simulate_ukeypress(int key, int scancode);

+ Stuffs a key into the keyboard buffer, just as if the user had pressed + it. The parameter is in the same format returned by ureadkey(). Example: +
+      /* We ignore the scancode simulation. */
+      simulate_ukeypress(0x00DF, 0);
+      if (ureadkey(&scancode) == 0x00DF)
+         allegro_message("You simulated sharp s\n");
+ + +
See also: +install_keyboard, +simulate_keypress, +keypressed, +ureadkey.
+
extern int (*keyboard_callback)(int key);

+ If set, this function is called by the keyboard handler in response to + every keypress. It is passed a copy of the value that is about to be + added into the input buffer, and can either return this value unchanged, + return zero to cause the key to be ignored, or return a modified value to + change what readkey() will later return. This routine executes in an + interrupt context, so it must be in locked memory. Example: +
+      int enigma_scrambler(int key)
+      {
+         /* Add one to both the scancode and ascii values. */
+         return (((key >> 8) + 1) << 8) | ((key & 0xff) + 1);
+      }
+      END_OF_FUNCTION(enigma_scrambler)
+      
+      ...
+      
+         install_timer();
+         LOCK_FUNCTION(enigma_scrambler);
+         install_keyboard();
+         keyboard_callback = enigma_scrambler;
+ +

+ Note that this callback will be ignored if you also set the unicode + keyboard callback. + + +

See also: +install_keyboard, +readkey, +ureadkey, +keyboard_ucallback, +keyboard_lowlevel_callback.
+
extern int (*keyboard_ucallback)(int key, int *scancode);

+ Unicode-aware version of keyboard_callback(). If set, this function is + called by the keyboard handler in response to every keypress. It is + passed the character value and scancode that are about to be added into + the input buffer, can modify the scancode value, and returns a new or + modified key code. If it both sets the scancode to zero and returns zero, + the keypress will be ignored. This routine executes in an interrupt + context, so it must be in locked memory. Example: +
+      int silence_g_key(int key, int *scancode)
+      {
+         if (key == 'g') {
+            *scancode = 0;
+            return 0;
+         }
+         return key;
+      } END_OF_FUNCTION(silence_g_key)
+
+      ...
+      
+         install_timer();
+         LOCK_FUNCTION(silence_g_key);
+         install_keyboard();
+         keyboard_ucallback = silence_g_key;
+ +

+ Note that this keyboard callback has priority over the non unicode + callback. If you set both, only the unicode one will work. + + +

See also: +install_keyboard, +readkey, +ureadkey, +keyboard_callback, +keyboard_lowlevel_callback.
+
extern void (*keyboard_lowlevel_callback)(int scancode);

+ If set, this function is called by the keyboard handler in response to + every keyboard event, both presses (including keyboard repeat rate) and + releases. It will be passed a raw keyboard scancode byte (scancodes are + 7 bits long), with the top bit (8th bit) clear if the key has been + pressed or set if it was released. This routine executes in an interrupt + context, so it must be in locked memory. Example: +
+      volatile int key_down, key_up;
+      
+      void keypress_watcher(int scancode)
+      {
+         if (scancode & 0x80) {
+            key_up = 1;
+         } else {
+            key_down = 1;
+         }
+      } END_OF_FUNCTION(keypress_watcher)
+
+      ...
+
+         install_timer();
+         LOCK_FUNCTION(silence_g_key);
+         LOCK_VARIABLE(key_down);
+         LOCK_VARIABLE(key_up);
+         install_keyboard();
+         keyboard_lowlevel_callback = keypress_watcher;
+         /* Disable keyboard repeat to get typewriter effect. */
+         set_keyboard_rate(0, 0);
+
+      ...
+
+         while (game_loop) {
+            if (key_down) {
+               key_down = 0;
+               /* Play sample of typewriter key press. */
+            }
+            if (key_up) {
+               key_up = 0;
+               /* Play sample of typewriter key release. */
+            }
+         }
+ + +
See also: +install_keyboard, +keyboard_callback, +keyboard_ucallback.
+ +
Examples using this: +exkeys.
+
void set_leds(int leds);

+ Overrides the state of the keyboard LED indicators. The parameter is a + bitmask containing any of the values KB_SCROLOCK_FLAG, KB_NUMLOCK_FLAG, + and KB_CAPSLOCK_FLAG, or -1 to restore the default behavior. Example: +
+      /* Cycle led indicators. */
+      set_leds(KB_SCROLOCK_FLAG);
+      rest(1000);
+      set_leds(KB_CAPSLOCK_FLAG);
+      rest(1000);
+      set_leds(KB_NUMLOCK_FLAG);
+      rest(1000);
+      set_leds(-1);
+
+ Note that the led behaviour cannot be guaranteed on some platforms, some + leds might not react, or none at all. Therefore you shouldn't rely only on + them to communicate information to the user, just in case it doesn't get + through. + + +
See also: +install_keyboard, +key_led_flag.
+
void set_keyboard_rate(int delay, int repeat);

+ Sets the keyboard repeat rate. Times are given in milliseconds. Passing + zero times will disable the key repeat. + + +
See also: +install_keyboard, +readkey, +ureadkey.
+
void clear_keybuf();

+ Empties the keyboard buffer. Usually you want to use this in your program + before reading keys to avoid previously buffered keys to be returned by + calls to readkey() or ureadkey(). + + +
See also: +install_keyboard, +keypressed, +readkey, +ureadkey.
+ +
Examples using this: +Available Allegro examples.
+
extern int three_finger_flag;

+ The DJGPP keyboard handler provides an 'emergency exit' sequence which + you can use to kill off your program. If you are running under DOS this + is the three finger salute, ctrl+alt+del. Most multitasking OS's will + trap this combination before it reaches the Allegro handler, in which + case you can use the alternative ctrl+alt+end. If you want to disable + this behaviour in release versions of your program, set this flag to + FALSE. + + +
See also: +install_keyboard.
+
extern int key_led_flag;

+ By default, the capslock, numlock, and scroll-lock keys toggle the + keyboard LED indicators when they are pressed. If you are using these + keys for input in your game (eg. capslock to fire) this may not be + desirable, so you can clear this flag to prevent the LED's being updated. + + + + +
See also: +install_keyboard, +set_leds.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg007.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg007.html new file mode 100644 index 0000000..2463148 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg007.html @@ -0,0 +1,337 @@ + + +Allegro Manual: Joystick routines + + + + +

Joystick routines

+ + + +

+Unlike keyboard or mouse input, which are usually read through hardware +interrupts by Allegro, joystick input functions have to be polled because +there are no hardware interrupts for them on most platforms. This doesn't +mean that you have to poll the joysticks on each line of code you want to +read their values, but you should make sure to poll them at least once per +frame in your game loop. Otherwise you face the possibility of reading stale +incorrect data. + +


+

int install_joystick(int type);

+ Installs Allegro's joystick handler, and calibrates the centre position + values. The type parameter should usually be JOY_TYPE_AUTODETECT, or see + the platform specific documentation for a list of the available drivers. + You must call this routine before using any other joystick functions, and + you should make sure that all joysticks are in the middle position at the + time. Example: +
+      textout_centre_ex(screen, font,
+                        "Center the joystick and press a key",
+                        SCREEN_W/2, SCREEN_H/2, red_color, -1);
+      readkey();
+      if (install_joystick(JOY_TYPE_AUTODETECT) != 0)
+         abort_on_error("Error initialising joystick!");
+

Return value: + Returns zero on success. As soon as you have installed the joystick + module, you will be able to read the button state and digital (on/off + toggle) direction information, which may be enough for some games. If you + want to get full analogue input, though, you need to use the + calibrate_joystick() functions to measure the exact range of the inputs: + see below. + + +

See also: +remove_joystick, +num_joysticks, +load_joystick_data, +calibrate_joystick, +calibrate_joystick_name, +poll_joystick, +Standard config variables, +JOY_TYPE_*/DOS, +JOY_TYPE_*/Windows, +JOY_TYPE_*/Linux.
+ +
Examples using this: +exjoy.
+
void remove_joystick();

+ Removes the joystick handler. You don't normally need to bother calling + this, because allegro_exit() will do it for you. + + +
See also: +install_joystick, +allegro_exit.
+
int poll_joystick();

+ The joystick handler is not interrupt driven, so you need to call this + function every now and again to update the global position values. Example: +
+   do {
+      /* Get joystick input */
+      poll_joystick();
+      
+      /* Process input for the first joystick */
+      if (joy[0].button[0].b)
+         first_button_pressed();
+
+      if (joy[0].button[1].b)
+         second_button_pressed();
+      ...
+   } while(!done);
+

Return value: + Returns zero on success or a negative number on failure (usually because + no joystick driver was installed). + + +

See also: +install_joystick, +joy, +num_joysticks.
+ +
Examples using this: +exjoy.
+
extern int num_joysticks;

+ Global variable containing the number of active joystick devices. The + current drivers support a maximum of eight controllers. + + +
See also: +install_joystick, +joy.
+ +
Examples using this: +exjoy.
+
extern JOYSTICK_INFO joy[n];

+ Global array of joystick state information, which is updated by the + poll_joystick() function. Only the first num_joysticks elements will + contain meaningful information. The JOYSTICK_INFO structure is defined as: +
+      typedef struct JOYSTICK_INFO
+      {
+         int flags;                       - status flags for this
+                                            joystick
+         int num_sticks;                  - how many stick inputs?
+         int num_buttons;                 - how many buttons?
+         JOYSTICK_STICK_INFO stick[n];    - stick state information
+         JOYSTICK_BUTTON_INFO button[n];  - button state information
+      } JOYSTICK_INFO;
+
+ The button status is stored in the structure: +
+      typedef struct JOYSTICK_BUTTON_INFO
+      {
+         int b;                           - boolean on/off flag
+         char *name;                      - description of this
+                                            button
+      } JOYSTICK_BUTTON_INFO;
+
+ You may wish to display the button names as part of an input + configuration screen to let the user choose what game function will be + performed by each button, but in simpler situations you can safely assume + that the first two elements in the button array will always be the main + trigger controls. + +

+ Each joystick will provide one or more stick inputs, of varying types. + These can be digital controls which snap to specific positions (eg. a + gamepad controller, the coolie hat on a Flightstick Pro or Wingman + Extreme, or a normal joystick which hasn't yet been calibrated), or they + can be full analogue inputs with a smooth range of motion. Sticks may + also have different numbers of axes, for example a normal directional + control has two, but the Flightstick Pro throttle is only a single axis, + and it is possible that the system could be extended in the future to + support full 3d controllers. A stick input is described by the structure: +

+      typedef struct JOYSTICK_STICK_INFO
+      {
+         int flags;                       - status flags for this
+                                            input
+         int num_axis;                    - how many axes do we
+                                            have? (note the misspelling)
+         JOYSTICK_AXIS_INFO axis[n];      - axis state information
+         char *name;                      - description of this
+                                            input
+      } JOYSTICK_STICK_INFO;
+
+ A single joystick may provide several different stick inputs, but you can + safely assume that the first element in the stick array will always be + the main directional controller. + +

+ Information about each of the stick axis is stored in the substructure: +

+      typedef struct JOYSTICK_AXIS_INFO
+      {
+         int pos;                         - analogue axis position
+         int d1, d2;                      - digital axis position
+         char *name;                      - description of this axis
+      } JOYSTICK_AXIS_INFO;
+
+ This provides both analogue input in the pos field (ranging from -128 to + 128 or from 0 to 255, depending on the type of the control), and digital + values in the d1 and d2 fields. For example, when describing the X-axis + position, the pos field will hold the horizontal position of the + joystick, d1 will be set if it is moved left, and d2 will be set if it is + moved right. Allegro will fill in all these values regardless of whether + it is using a digital or analogue joystick, emulating the pos field for + digital inputs by snapping it to the min, middle, and maximum positions, + and emulating the d1 and d2 values for an analogue stick by comparing the + current position with the centre point. + +

+ The joystick flags field may contain any combination of the bit flags: + +

+ JOYFLAG_DIGITAL
+ This control is currently providing digital input. + +

+ JOYFLAG_ANALOGUE
+ This control is currently providing analogue input. + +

+ JOYFLAG_CALIB_DIGITAL
+ This control will be capable of providing digital input once it has + been calibrated, but is not doing this at the moment. + +

+ JOYFLAG_CALIB_ANALOGUE
+ This control will be capable of providing analogue input once it has + been calibrated, but is not doing this at the moment. + +

+ JOYFLAG_CALIBRATE
+ Indicates that this control needs to be calibrated. Many devices + require multiple calibration steps, so you should call the + calibrate_joystick() function from a loop until this flag is cleared. + +

+ JOYFLAG_SIGNED
+ Indicates that the analogue axis position is in signed format, ranging + from -128 to 128. This is the case for all 2d directional controls. + +

+ JOYFLAG_UNSIGNED
+ Indicates that the analogue axis position is in unsigned format, + ranging from 0 to 255. This is the case for all 1d throttle controls. + +

+ Note for people who spell funny: in case you don't like having to type + "analogue", there are some #define aliases in allegro/joystick.h that + will allow you to write "analog" instead. + + +

See also: +install_joystick, +poll_joystick, +num_joysticks, +calibrate_joystick, +calibrate_joystick_name.
+ +
Examples using this: +exjoy.
+
const char *calibrate_joystick_name(int n);

+ Pass the number of the joystick you want to calibrate as the parameter. +

Return value: + Returns a text description for the next type of calibration that will be + done on the specified joystick, or NULL if no more calibration is + required. + + +

See also: +install_joystick, +calibrate_joystick, +joy, +num_joysticks.
+ +
Examples using this: +exjoy.
+
int calibrate_joystick(int n);

+ Most joysticks need to be calibrated before they can provide full + analogue input. This function performs the next operation in the + calibration series for the specified stick, assuming that the joystick + has been positioned in the manner described by a previous call to + calibrate_joystick_name(), returning zero on success. For example, a + simple routine to fully calibrate all the joysticks might look like: +
+      int i;
+
+      for (i=0; i<;num_joysticks; i++) {
+         while (joy[i].flags & JOYFLAG_CALIBRATE) {
+            char *msg = calibrate_joystick_name(i);
+            textprintf_ex(..., "%s, and press a key\n", msg);
+            readkey();
+            if (calibrate_joystick(i) != 0) {
+               textprintf_ex(..., "oops!\n");
+               readkey();
+               exit(1);
+            }
+         }
+      }
+

Return value: + Returns zero on success, non-zero if the calibration could not be + performed successfully. + + +

See also: +install_joystick, +calibrate_joystick_name, +joy, +num_joysticks.
+ +
Examples using this: +exjoy.
+
int save_joystick_data(const char *filename);

+ After all the headache of calibrating the joystick, you may not want to + make your poor users repeat the process every time they run your program. + Call this function to save the joystick calibration data into the + specified configuration file, from which it can later be read by + load_joystick_data(). Pass a NULL filename to write the data to the + currently selected configuration file. +

Return value: + Returns zero on success, non-zero if the data could not be saved. + + +

See also: +load_joystick_data, +set_config_file.
+
int load_joystick_data(const char *filename);

+ Restores calibration data previously stored by save_joystick_data() or + the setup utility. This sets up all aspects of the joystick code: you + don't even need to call install_joystick() if you are using this + function. Pass a NULL filename to read the data from the currently + selected configuration file. +

Return value: + Returns zero on success: if it fails the joystick state is undefined and + you must reinitialise it from scratch. + + +

See also: +install_joystick, +save_joystick_data, +set_config_file.
+
int initialise_joystick();

+ Deprecated. Use install_joystick() instead. + + + + +
See also: +install_joystick.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg008.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg008.html new file mode 100644 index 0000000..c93265c --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg008.html @@ -0,0 +1,876 @@ + + +Allegro Manual: Graphics modes + + + + +

Graphics modes

+ + + +

+Graphics modes are the common denominator for most Allegro programs. While it +is possible to write platform specific programs using Allegro which don't set +a graphic mode through the routines provided in this chapter, these are not +very common. + +

+The first thing to note is that due to the wide range of supported platforms, +a graphic mode is the only way to safely communicate with the user. When +Allegro was a DOS only library (versions 3.x and previous), it was frequent +for programmers to use functions from the C standard library to communicate +with the user, like calling printf() before setting a graphic mode or maybe +scanf() to read the user's input. However, what would happen for such a game +running under Windows where there is no default console output or it may be +hidden from the user? Even if the game compiled successfully, it would be +unplayable, especially if there was vital information for the user in those +text only messages. + +

+Allegro provides the allegro_message() function to deal with this problem, +but this is not a very user friendly method of communicating with the user +and its main purpose is displaying small error like messages when no graphic +mode is available. Therefore, the first thing your Allegro program should do +is set a graphic mode, and from there on, use Allegro's text output routines +to display messages to the user, just like `allegro/examples/exhello.c' does. + +

+Setting a graphic mode involves deciding how to allocate the memory of the +video card for your program. On some platforms this means creating a virtual +screen bigger than the physical resolution to do hardware scrolling or page +flipping. Virtual screens can cause a lot of confusion, but they are really +quite simple. Warning: patronising explanation coming up, so you may wish to +skip the rest of this paragraph. Think of video memory as a rectangular piece +of paper which is being viewed through a small hole (your monitor) in a bit of +cardboard. Since the paper is bigger than the hole you can only see part of it +at any one time, but by sliding the cardboard around you can alter which +portion of the image is visible. You could just leave the hole in one position +and ignore the parts of video memory that aren't visible, but you can get all +sorts of useful effects by sliding the screen window around, or by drawing +images in a hidden part of video memory and then flipping across to display +them. + +

+For example, you could select a 640x480 mode in which the monitor acts as a +window onto a 1024x1024 virtual screen, and then move the visible screen +around in this larger area (hardware scrolling). Initially, with the visible +screen positioned at the top left corner of video memory, this setup would +look like: +

+      (0,0)------------(640,0)----(1024,0)
+        |                  |           |
+        |  visible screen  |           |
+        |                  |           |
+      (0,480)----------(640,480)       |
+        |                              |
+        |   the rest of video memory   |
+        |                              |
+      (0,1024)--------------------(1024,1024)
+
+With a virtual screen bigger than the visible screen you can perform smooth +CPU inexpensive scrolling: you draw your graphics once, and then only tell +the video card to show a different portion of the screen. However, virtual +screens are not supported on all platforms, and on some they might be +emulated through software, losing any performance. On top of that, many video +cards only allow horizontal scrolling in steps of 32 bytes. This is not a +problem if your game runs in 24 or 32 bit, but it tends to mean jerky +scrolling for other color depths. + +

+The other reason you could use virtual screens for is page flipping. This +means showing one portion of the virtual screen while your program draws to +the hidden one. When you finish, you show the part you have been drawing to +and repeat the process with the area now hidden. The result is a perfectly +smooth screen update without flickering or other graphical artifacts. + +

+Scrolling manually to one part of the video memory is one non portable way to +accomplish this. The portable way is to use functions like +create_system_bitmap(), create_video_bitmap(), show_video_bitmap(), etc. These +functions divide the memory of the video card in areas and switch between +them, a feature supported on all platforms and video cards (given that they +have enough memory for the screen resolutions you asked for). + +

+The last thing you need to know about setting a graphic mode are drivers. +Each platform has a number of graphic drivers wich support a different range +of hardware or behave in different ways. To avoid cluttering your own code +with #ifdefs and dealing with drivers added after you release your program, +Allegro provides several so called magic drivers. These magic drivers don't +really exists, they wrap around a specific kind of functionality. + +

+The magic drivers you can use are: +

+ +


+

void set_color_depth(int depth);

+ Sets the pixel format to be used by subsequent calls to set_gfx_mode() + and create_bitmap(). Valid depths are 8 (the default), 15, 16, 24, and 32 + bits. Example: +
+      set_color_depth(32);
+      if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
+         abort_on_error("Couldn't set a 32 bit color resolution");
+      }
+
+ Note that the screen color depth won't change until the next successful + call to set_gfx_mode(). + + +
See also: +get_color_depth, +set_gfx_mode, +set_color_conversion, +makecol, +getr, +desktop_color_depth.
+ +
Examples using this: +Available Allegro examples.
+
int get_color_depth(void);

+ Returns the current pixel format. This can be very useful to know in order + to write generic functions which select a different code path internally + depending on the color depth being used. + +

+ Note that the function returns whatever value you may have set previously + with set_color_depth(), which can be different from the current color + depth of the screen global variable. If you really need to know the color + depth of the screen, use bitmap_color_depth(). + + +

See also: +set_color_depth, +bitmap_color_depth.
+ +
Examples using this: +exrgbhsv.
+
void request_refresh_rate(int rate);

+ Requests that the next call to set_gfx_mode() try to use the specified + refresh rate, if possible. Not all drivers are able to control this at + all, and even when they can, not all rates will be possible on all + hardware, so the actual settings may differ from what you requested. + After you call set_gfx_mode(), you can use get_refresh_rate() to find out + what was actually selected. At the moment only the DOS VESA 3.0, X DGA 2.0 + and some Windows DirectX drivers support this function. The speed is + specified in Hz, eg. 60, 70. To return to the normal default selection, + pass a rate value of zero. Example: +
+      request_refresh_rate(60);
+      if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0)
+         abort_on_error("Couldn't set graphic mode!");
+      if (get_refresh_rate() != 60)
+         abort_on_error("Couldn't set refresh rate to 60Hz!");
+ + +
See also: +set_gfx_mode, +get_refresh_rate.
+
int get_refresh_rate(void);

+ Returns the current refresh rate, if known (not all drivers are able to + report this information). Returns zero if the actual rate is unknown. + + +
See also: +request_refresh_rate.
+
GFX_MODE_LIST *get_gfx_mode_list(int card);

+ Attempts to create a list of all the supported video modes for a certain + graphics driver, made up from the GFX_MODE_LIST structure, which has the + following definition: +
+      typedef struct GFX_MODE_LIST
+      {
+         int num_modes;
+         GFX_MODE *mode;
+      } GFX_MODE_LIST;
+
+ The mode entry points to the actual list of video modes. +
+      typedef struct GFX_MODE
+      {
+         int width, height, bpp;
+      } GFX_MODE;
+
+ This list of video modes is terminated with an { 0, 0, 0 } entry. + +

+ Note that the card parameter must refer to a _real_ driver. This function + fails if you pass GFX_SAFE, GFX_AUTODETECT, or any other "magic" driver. +

Return value: + Returns a pointer to a list structure of the type GFX_MODE_LIST or NULL + if the request could not be satisfied. + + +

See also: +destroy_gfx_mode_list, +set_gfx_mode, +set_color_depth.
+
void destroy_gfx_mode_list(GFX_MODE_LIST *mode_list);

+ Removes the mode list created by get_gfx_mode_list() from memory. Use this + once you are done with the generated mode list to avoid memory leaks in + your program. + + +
See also: +get_gfx_mode_list, +set_gfx_mode, +set_color_depth.
+
int set_gfx_mode(int card, int w, int h, int v_w, int v_h);

+ Switches into graphics mode. The card parameter should usually be one of + the Allegro magic drivers (read introduction of chapter "Graphics modes") + or see the platform specific documentation for a list of the available + drivers. The w and h parameters specify what screen resolution you want. + The color depth of the graphic mode has to be specified before calling + this function with set_color_depth(). + +

+ The v_w and v_h parameters specify the minimum virtual screen size, in + case you need a large virtual screen for hardware scrolling or page + flipping. You should set them to zero if you don't care about the virtual + screen size. + +

+ When you call set_gfx_mode(), the v_w and v_h parameters represent the + minimum size of virtual screen that is acceptable for your program. The + range of possible sizes is usually very restricted, and Allegro may + end up creating a virtual screen much larger than the one you request. + Allowed sizes are driver dependent and some drivers do not allow virtual + screens that are larger than the visible screen at all: don't assume + that whatever you pass will always work. + +

+ In mode-X the virtual width can be any multiple of eight greater than or + equal to the physical screen width, and the virtual height will be set + accordingly (the VGA has 256k of vram, so the virtual height will be + 256*1024/virtual_width). + +

+ Currently, using a big virtual screen for page flipping is considered bad + practice. There are platforms which don't support virtual screens bigger + than the physical screen but can create different video pages to flip back + and forth. This means that, if you want page flipping and aren't going to + use hardware scrolling, you should call set_gfx_mode() with (0,0) as the + virtual screen size and later create the different video pages with + create_video_bitmap(). Otherwise your program will be limited to the + platforms supporting hardware scrolling. + +

+ After you select a graphics mode, the physical and virtual screen sizes + can be checked with the macros SCREEN_W, SCREEN_H, VIRTUAL_W, and + VIRTUAL_H. +

Return value: + Returns zero on success. On failure returns a negative number and stores a + description of the problem in allegro_error. + + +

See also: +set_color_depth, +request_refresh_rate, +screen, +gfx_capabilities, +allegro_error, +Standard config variables, +GFX_*/DOS, +GFX_*/Windows, +GFX_*/X, +GFX_*/Linux, +GFX_*/BeOS, +GFX_*/MacOSX, +create_video_bitmap, +get_desktop_resolution, +SCREEN_W, +SCREEN_H, +VIRTUAL_W, +VIRTUAL_H.
+ +
Examples using this: +Available Allegro examples.
+
int set_display_switch_mode(int mode);

+ Sets how the program should handle being switched into the background, + if the user tabs away from it. Not all of the possible modes will be + supported by every graphics driver on every platform. The available modes + are: + + Note that you should be very careful when you are using graphics routines + in the switching context: you must always call acquire_screen() before the + start of any drawing code onto the screen and not release it until you are + completely finished, because the automatic locking mechanism may not be + good enough to work when the program runs in the background or has just + been raised in the foreground. +

Return value: + Returns zero on success, invalidating at the same time all callbacks + previously registered with set_display_switch_callback(). Returns -1 if + the requested mode is not currently possible. + + +

See also: +set_display_switch_callback, +get_display_switch_mode.
+ +
Examples using this: +exmidi, +exswitch.
+
int set_display_switch_callback(int dir, void (*cb)());

+ Installs a notification callback for the switching mode that was + previously selected by calling set_display_switch_mode(). The direction + parameter can either be SWITCH_IN or SWITCH_OUT, depending whether you + want to be notified about switches away from your program or back to your + program. You can sometimes install callbacks for both directions at the + same time, but not every platform supports this. You can install several + switch callbacks, but no more than eight on any platform. +

Return value: + Returns zero on success, decreasing the number of empty callback slots by + one. Returns -1 if the request is impossible for the current platform or + you have reached the maximum number of allowed callbacks. + + +

See also: +remove_display_switch_callback, +set_display_switch_mode.
+ +
Examples using this: +exswitch.
+
void remove_display_switch_callback(void (*cb)());

+ Removes a notification callback that was previously installed by calling + set_display_switch_callback(). All the callbacks will automatically be + removed when you call set_display_switch_mode(). You can safely call this + function even if the callback you want to remove is not installed. + + +
See also: +set_display_switch_callback.
+
int get_display_switch_mode();

+ Returns the current display switching mode, in the same format passed to + set_display_switch_mode(). + + +
See also: +set_display_switch_mode.
+ +
Examples using this: +exswitch.
+
int is_windowed_mode(void);

+ This function can be used to detect wether or not set_gfx_mode() selected + a windowed mode. Example: +
+      if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0)
+         abort_on_error("Couldn't set graphic mode!");
+      if (is_windowed_mode()) {
+         /* Windowed mode stuff. */
+      } else {
+         /* Fullscreen mode stuff. */
+      }
+

Return value: + Returns true if the current graphics mode is a windowed mode, or zero if + it is a fullscreen mode. You should not call this function if you are not + in graphics mode. + + +

See also: +set_gfx_mode.
+
extern int gfx_capabilities;

+ Bitfield describing the capabilities of the current graphics driver and + video hardware. This may contain combination any of the flags: + +

+ GFX_CAN_SCROLL:
+ Indicates that the scroll_screen() function may be used with this + driver. + +

+ GFX_CAN_TRIPLE_BUFFER:
+ Indicates that the request_scroll() and poll_scroll() functions may be + used with this driver. If this flag is not set, it is possible that + the enable_triple_buffer() function may be able to activate it. + +

+ GFX_HW_CURSOR:
+ Indicates that a hardware mouse cursor is in use. When this flag is + set, it is safe to draw onto the screen without hiding the mouse + pointer first. Note that not every cursor graphic can be implemented + in hardware: in particular VBE/AF only supports 2-color images up to + 32x32 in size, where the second color is an exact inverse of the + first. This means that Allegro may need to switch between hardware and + software cursors at any point during the execution of your program, so + you should not assume that this flag will remain constant for long + periods of time. It only tells you whether a hardware cursor is in use + at the current time, and may change whenever you hide/redisplay the + pointer. + +

+ GFX_SYSTEM_CURSOR
+ Indicates that the mouse cursor is the default system cursor, not + Allegro's custom cursor. + +

+ GFX_HW_HLINE:
+ Indicates that the normal opaque version of the hline() function is + implemented using a hardware accelerator. This will improve the + performance not only of hline() itself, but also of many other + functions that use it as a workhorse, for example circlefill(), + triangle(), and floodfill(). + +

+ GFX_HW_HLINE_XOR:
+ Indicates that the XOR version of the hline() function, and any other + functions that use it as a workhorse, are implemented using a hardware + accelerator. + +

+ GFX_HW_HLINE_SOLID_PATTERN:
+ Indicates that the solid and masked pattern modes of the hline() + function, and any other functions that use it as a workhorse, are + implemented using a hardware accelerator (see note below). + +

+ GFX_HW_HLINE_COPY_PATTERN:
+ Indicates that the copy pattern mode of the hline() function, and any + other functions that use it as a workhorse, are implemented using a + hardware accelerator (see note below). + +

+ GFX_HW_FILL:
+ Indicates that the opaque version of the rectfill() function, the + clear_bitmap() routine, and clear_to_color(), are implemented using a + hardware accelerator. + +

+ GFX_HW_FILL_XOR:
+ Indicates that the XOR version of the rectfill() function is + implemented using a hardware accelerator. + +

+ GFX_HW_FILL_SOLID_PATTERN:
+ Indicates that the solid and masked pattern modes of the rectfill() + function are implemented using a hardware accelerator (see note below). + +

+ GFX_HW_FILL_COPY_PATTERN:
+ Indicates that the copy pattern mode of the rectfill() function is + implemented using a hardware accelerator (see note below). + +

+ GFX_HW_LINE:
+ Indicates that the opaque mode line() and vline() functions are + implemented using a hardware accelerator. + +

+ GFX_HW_LINE_XOR:
+ Indicates that the XOR version of the line() and vline() functions are + implemented using a hardware accelerator. + +

+ GFX_HW_TRIANGLE:
+ Indicates that the opaque mode triangle() function is implemented + using a hardware accelerator. + +

+ GFX_HW_TRIANGLE_XOR:
+ Indicates that the XOR version of the triangle() function is + implemented using a hardware accelerator. + +

+ GFX_HW_GLYPH:
+ Indicates that monochrome character expansion (for text drawing) is + implemented using a hardware accelerator. + +

+ GFX_HW_VRAM_BLIT:
+ Indicates that blitting from one part of the screen to another is + implemented using a hardware accelerator. If this flag is set, + blitting within the video memory will almost certainly be the fastest + possible way to display an image, so it may be worth storing some of + your more frequently used graphics in an offscreen portion of the + video memory. + +

+ GFX_HW_VRAM_BLIT_MASKED:
+ Indicates that the masked_blit() routine is capable of a hardware + accelerated copy from one part of video memory to another, and that + draw_sprite() will use a hardware copy when given a sub-bitmap of the + screen or a video memory bitmap as the source image. If this flag is + set, copying within the video memory will almost certainly be the + fastest possible way to display an image, so it may be worth storing + some of your more frequently used sprites in an offscreen portion of + the video memory. + +

+ Warning: if this flag is not set, masked_blit() and draw_sprite() will + not work correctly when used with a video memory source image! You + must only try to use these functions to copy within the video memory + if they are supported in hardware. + +

+ GFX_HW_MEM_BLIT:
+ Indicates that blitting from a memory bitmap onto the screen is being + accelerated in hardware. + +

+ GFX_HW_MEM_BLIT_MASKED:
+ Indicates that the masked_blit() and draw_sprite() functions are being + accelerated in hardware when the source image is a memory bitmap and + the destination is the physical screen. + +

+ GFX_HW_SYS_TO_VRAM_BLIT:
+ Indicates that blitting from a system bitmap onto the screen is being + accelerated in hardware. Note that some acceleration may be present + even if this flag is not set, because system bitmaps can benefit from + normal memory to screen blitting as well. This flag will only be set + if system bitmaps have further acceleration above and beyond what is + provided by GFX_HW_MEM_BLIT. + +

+ GFX_HW_SYS_TO_VRAM_BLIT_MASKED:
+ Indicates that the masked_blit() and draw_sprite() functions are being + accelerated in hardware when the source image is a system bitmap and + the destination is the physical screen. Note that some acceleration + may be present even if this flag is not set, because system bitmaps + can benefit from normal memory to screen blitting as well. This flag + will only be set if system bitmaps have further acceleration above and + beyond what is provided by GFX_HW_MEM_BLIT_MASKED. + +

+ GFX_HW_VRAM_STRETCH_BLIT:
+ Indicates that stretched blitting of video bitmaps onto the screen is + implemented using hardware acceleration. + +

+ GFX_HW_SYS_STRETCH_BLIT:
+ Indicates that stretched blitting of system bitmaps onto the screen is + implemented using hardware acceleration. + +

+ GFX_HW_VRAM_STRETCH_BLIT_MASKED:
+ Indicates that masked stretched blitting (including stretch_sprite) of + video bitmaps onto the screen is implemented using hardware acceleration. + NOTE: some display drivers may show artefacts when this function is used. + If the image does not look correct try updating your video drivers. + +

+ GFX_HW_SYS_STRETCH_BLIT_MASKED:
+ Indicates that masked stretched blitting (including stretch_sprite) of + system bitmaps onto the screen is implemented using hardware acceleration. + NOTE: some display drivers may show artefacts when this function is used. + If the image does not look correct try updating your video drivers. + +

+ Note: even if the capabilities information says that patterned drawing is + supported by the hardware, it will not be possible for every size of + pattern. VBE/AF only supports patterns up to 8x8 in size, so Allegro will + fall back on the original non-accelerated drawing routines whenever you + use a pattern larger than this. + +

+ Note2: these hardware acceleration features will only take effect when + you are drawing directly onto the screen bitmap, a video memory bitmap, + or a sub-bitmap thereof. Accelerated hardware is most useful in a page + flipping or triple buffering setup, and is unlikely to make any + difference to the classic "draw onto a memory bitmap, then blit to the + screen" system. + + +

See also: +screen, +create_video_bitmap, +scroll_screen, +request_scroll, +show_mouse, +enable_triple_buffer.
+ +
Examples using this: +ex3buf, +exaccel, +exsyscur, +exupdate.
+
int enable_triple_buffer();

+ If the GFX_CAN_TRIPLE_BUFFER bit of the gfx_capabilities field is not + set, you can attempt to enable it by calling this function. In particular + if you are running in mode-X in a clean DOS environment, this routine + will enable the timer retrace simulator, which will activate the triple + buffering functions. +

Return value: + Returns zero if triple buffering is enabled, -1 otherwise. + + +

See also: +gfx_capabilities, +request_scroll, +request_video_bitmap.
+ +
Examples using this: +ex3buf, +exupdate.
+
int scroll_screen(int x, int y);

+ Attempts to scroll the hardware screen to display a different part of the + virtual screen (initially it will be positioned at 0, 0, which is the top + left corner). You can use this to move the screen display around in a + large virtual screen space, or to page flip back and forth between two + non-overlapping areas of the virtual screen. Note that to draw outside the + original position in the screen bitmap you will have to alter the clipping + rectangle with set_clip_rect(). + +

+ Mode-X scrolling is reliable and will work on any card, other drivers may + not work or not work reliably. See the platform-specific section of the docs + for more information. + +

+ Allegro will handle any necessary vertical retrace synchronisation when + scrolling the screen, so you don't need to call vsync() before it. This + means that scroll_screen() has the same time delay effects as vsync(). +

Return value: + Returns zero on success. Returns non-zero if the graphics driver can't + handle hardware scrolling or the virtual screen is not large enough. + + +

See also: +set_gfx_mode, +show_video_bitmap, +request_scroll, +request_video_bitmap.
+ +
Examples using this: +exscroll.
+
int request_scroll(int x, int y);

+ This function is used for triple buffering. It requests a hardware scroll + to the specified position, but returns immediately rather than waiting + for a retrace. The scroll will then take place during the next vertical + retrace, but you can carry on running other code in the meantime and use + the poll_scroll() routine to detect when the flip has actually taken + place. + +

+ Triple buffering is only possible with certain drivers: you can look at the + GFX_CAN_TRIPLE_BUFFER bit in the gfx_capabilities flag to see if it will + work with the current driver. +

Return value: + This function returns zero on success, non-zero otherwise. + + +

See also: +poll_scroll, +request_video_bitmap, +gfx_capabilities, +scroll_screen.
+
int poll_scroll();

+ This function is used for triple buffering. It checks the status of a + hardware scroll previously initiated by the request_scroll() routine. +

Return value: + Returns non-zero if it is still waiting to take place, and zero if the + requested scroll has already happened. + + +

See also: +request_scroll, +request_video_bitmap.
+ +
Examples using this: +ex3buf, +exupdate.
+
int show_video_bitmap(BITMAP *bitmap);

+ Attempts to page flip the hardware screen to display the specified video + bitmap object, which must be the same size as the physical screen, and + should have been obtained by calling the create_video_bitmap() function. + +

+ Allegro will handle any necessary vertical retrace synchronisation when + page flipping, so you don't need to call vsync() before it. This means + that show_video_bitmap() has the same time delay effects as vsync() by + default. This can be adjusted with the "disable_vsync" config key in the + [graphics] section of allegro.cfg. Example: +

+      int current_page;
+      BITMAP *video_page[2];
+      ...
+      /* Create pages for page flipping */
+      video_page[0] = create_video_bitmap(SCREEN_W, SCREEN_H);
+      video_page[1] = create_video_bitmap(SCREEN_W, SCREEN_H);
+      current_page = 0;
+      ...
+      /* draw the screen and flip pages */
+      draw_screen(video_page[current_page]);
+      show_video_bitmap(video_page[current_page]);
+      current_page = (current_page+1)%2;
+      ...
+

Return value: + Returns zero on success and non-zero on failure. + + +

See also: +scroll_screen, +create_video_bitmap, +Standard config variables.
+ +
Examples using this: +exaccel, +exflip, +exupdate.
+
int request_video_bitmap(BITMAP *bitmap);

+ This function is used for triple buffering. It requests a page flip to + display the specified video bitmap object, but returns immediately rather + than waiting for a retrace. The flip will then take place during the next + vertical retrace, but you can carry on running other code in the meantime + and use the poll_scroll() routine to detect when the flip has actually + taken place. Triple buffering is only possible on certain hardware: see + the comments about request_scroll(). Example: +
+      int current_page;
+      BITMAP *video_page[3];
+      ...
+      /* Create pages for page flipping */
+      video_page[0] = create_video_bitmap(SCREEN_W, SCREEN_H);
+      video_page[1] = create_video_bitmap(SCREEN_W, SCREEN_H);
+      video_page[2] = create_video_bitmap(SCREEN_W, SCREEN_H);
+      current_page = 0;
+      ...
+      /* draw the screen and flip pages */
+      draw_screen(video_page[current_page]);
+      do {
+      } while (poll_scroll());
+      request_video_bitmap(video_page[current_page]);
+      current_page = (current_page+1)%3;
+      ...
+

Return value: + Returns zero on success and non-zero on failure. + + +

See also: +poll_scroll, +request_scroll, +gfx_capabilities, +create_video_bitmap, +scroll_screen.
+ +
Examples using this: +ex3buf, +exupdate.
+
void vsync();

+ Waits for a vertical retrace to begin. The retrace happens when the + electron beam in your monitor has reached the bottom of the screen and is + moving back to the top ready for another scan. During this short period + the graphics card isn't sending any data to the monitor, so you can do + things to it that aren't possible at other times, such as altering the + palette without causing flickering (snow). Allegro will automatically + wait for a retrace before altering the palette or doing any hardware + scrolling, though, so you don't normally need to bother with this + function. + + + + +
See also: +set_palette, +scroll_screen.
+ +
Examples using this: +Available Allegro examples.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg009.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg009.html new file mode 100644 index 0000000..10fa4d9 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg009.html @@ -0,0 +1,687 @@ + + +Allegro Manual: Bitmap objects + + + + +

Bitmap objects

+ + + +

+Once you have selected a graphics mode, you can draw things onto the display +via the `screen' bitmap. All the Allegro graphics routines draw onto BITMAP +structures, which are areas of memory containing rectangular images, stored +as packed byte arrays (in 8-bit modes one byte per pixel, in 15- and 16-bit +modes two bytes per pixel, in 24-bit modes 3 bytes per pixel and in 32-bit +modes 4 bytes per pixel). You can create and manipulate bitmaps in system +RAM, or you can write to the special `screen' bitmap which represents the +video memory in your graphics card. + +

+Read chapter "Direct access to video memory" for information on how to get +direct access to the image memory in a bitmap. + +

+Allegro supports several different types of bitmaps: +

+ +


+

extern BITMAP *screen;

+ Global pointer to a bitmap, sized VIRTUAL_W x VIRTUAL_H. This is created + by set_gfx_mode(), and represents the hardware video memory. Only a part + of this bitmap will actually be visible, sized SCREEN_W x SCREEN_H. + Normally this is the top left corner of the larger virtual screen, so you + can ignore the extra invisible virtual size of the bitmap if you aren't + interested in hardware scrolling or page flipping. To move the visible + window to other parts of the screen bitmap, call scroll_screen(). + Initially the clipping rectangle will be limited to the physical screen + size, so if you want to draw onto a larger virtual screen space outside + this rectangle, you will need to adjust the clipping. + +

+ For example, to draw a pixel onto the screen you would write: +

+      putpixel(screen, x, y, color);
+
+ Or to implement a double-buffered system: +
+      /* Make a bitmap in RAM. */
+      BITMAP *bmp = create_bitmap(320, 200);
+      /* Clean the memory bitmap. */
+      clear_bitmap(bmp);
+      /* Draw onto the memory bitmap. */
+      putpixel(bmp, x, y, color);
+      /* Copy it to the screen. */
+      blit(bmp, screen, 0, 0, 0, 0, 320, 200);
+ +

+ Warning: be very careful when using this pointer at the same time as any + bitmaps created by the create_video_bitmap() function (see the description + of this function for more detailed information). And never try to destroy + it with destroy_bitmap(). + + +

See also: +set_gfx_mode, +is_screen_bitmap, +create_video_bitmap, +scroll_screen.
+ +
Examples using this: +Available Allegro examples.
+
#define SCREEN_W;

+
#define SCREEN_H;

+ Global defines that return the width and height of the screen, or zero if + the screen has not been initialised yet. Example: +
+      char buf[100];
+      ...
+      uszprintf(buf, sizeof(buf),
+                "The screen size is %d x %d pixels",
+                SCREEN_W, SCREEN_H);
+ + +
See also: +screen, +set_gfx_mode, +VIRTUAL_W, +VIRTUAL_H.
+ +
Examples using this: +Available Allegro examples.
+
#define VIRTUAL_W;

+
#define VIRTUAL_H;

+ Global defines that return the width and height of the virtual screen, or + zero if the screen has not been initialised yet. Example: +
+      char buf[100];
+      ...
+      uszprintf(buf, sizeof(buf),
+                "The virtual screen size is %d x %d pixels",
+                SCREEN_W, SCREEN_H);
+ + +
See also: +screen, +set_gfx_mode, +SCREEN_W, +SCREEN_H.
+
BITMAP *create_bitmap(int width, int height);

+ Creates a memory bitmap sized width by height. The bitmap will have + clipping turned on, and the clipping rectangle set to the full size of the + bitmap. The image memory will not be cleared, so it will probably contain + garbage: you should clear the bitmap before using it. This routine always + uses the global pixel format, as specified by calling set_color_depth(). + The minimum height of the BITMAP must be 1 and width can't be negative. + Example: +
+      /* Create a 10 pixel tall bitmap, as wide as the screen. */
+      BITMAP *bmp = create_bitmap(SCREEN_W, 10);
+      if (!bmp)
+         abort_on_error("Couldn't create bitmap!");
+      /* Use the bitmap. */
+      ...
+      /* Destroy it when we don't need it any more. */
+      destroy_bitmap(bmp);
+

Return value: + Returns a pointer to the created bitmap, or NULL if the bitmap could not + be created. Remember to free this bitmap later to avoid memory leaks. + + +

See also: +create_bitmap_ex, +create_sub_bitmap, +create_video_bitmap, +create_system_bitmap, +destroy_bitmap, +set_color_depth, +is_memory_bitmap, +clear_bitmap, +clear_to_color.
+ +
Examples using this: +Available Allegro examples.
+
BITMAP *create_bitmap_ex(int color_depth, int width, int height);

+ Creates a bitmap in a specific color depth (8, 15, 16, 24 or 32 bits per + pixel). Example: +
+      /* Create screen sized bitmap in 32 bits per pixel. /*
+      BITMAP *bmp = create_bitmap_ex(32, SCREEN_W, SCREEN_H);
+      if (!bmp)
+         abort_on_error("Couldn't create bitmap!");
+      /* Use the bitmap. */
+      ...
+      /* Destroy it when we don't need it any more. */
+      destroy_bitmap(bmp);
+

Return value: + Returns a pointer to the created bitmap, or NULL if the bitmap could not + be created. Remember to free this bitmap later to avoid memory leaks. + + + +

See also: +create_bitmap, +create_sub_bitmap, +create_video_bitmap, +create_system_bitmap, +destroy_bitmap, +is_memory_bitmap, +clear_bitmap, +clear_to_color.
+ +
Examples using this: +ex12bit, +exlights, +exrgbhsv, +extrans.
+
BITMAP *create_sub_bitmap(BITMAP *parent, int x, y, width, height);

+ Creates a sub-bitmap, ie. a bitmap sharing drawing memory with a + pre-existing bitmap, but possibly with a different size and clipping + settings. When creating a sub-bitmap of the mode-X screen, the x position + must be a multiple of four. The sub-bitmap width and height can extend + beyond the right and bottom edges of the parent (they will be clipped), + but the origin point must lie within the parent region. +

Return value: + Returns a pointer to the created sub bitmap, or NULL if the sub bitmap + could not be created. Remember to free the sub bitmap before freeing + the parent bitmap to avoid memory leaks and potential crashes accessing + memory which has been freed. + + +

See also: +create_bitmap, +create_bitmap_ex, +destroy_bitmap, +is_sub_bitmap, +clear_bitmap, +clear_to_color.
+ +
Examples using this: +expat, +exscroll, +exswitch.
+
BITMAP *create_video_bitmap(int width, int height);

+ Allocates a video memory bitmap of the specified size. This can be used + to allocate offscreen video memory for storing source graphics ready for + a hardware accelerated blitting operation, or to create multiple video + memory pages which can then be displayed by calling show_video_bitmap(). + Read the introduction of this chapter for a comparison with other types + of bitmaps and other specific details. + +

+ Warning: video memory bitmaps are usually allocated from the same space + as the screen bitmap, so they may overlap with it; it is therefore not + a good idea to use the global screen at the same time as any surfaces + returned by this function. +

Return value: + Returns a pointer to the bitmap on success, or NULL if you have run out + of video ram. Remember to destroy this bitmap before any subsequent + call to set_gfx_mode(). + + +

See also: +create_bitmap, +create_bitmap_ex, +create_system_bitmap, +create_sub_bitmap, +destroy_bitmap, +screen, +show_video_bitmap, +gfx_capabilities, +is_video_bitmap, +clear_bitmap, +clear_to_color.
+ +
Examples using this: +ex3buf, +exaccel, +exflip, +exupdate.
+
BITMAP *create_system_bitmap(int width, int height);

+ Allocates a system memory bitmap of the specified size. Read the + introduction of this chapter for a comparison with other types of bitmaps + and other specific details. +

Return value: + Returns a pointer to the bitmap on success, NULL otherwise. Remember to + destroy this bitmap before any subsequent call to set_gfx_mode(). + + +

See also: +create_bitmap, +create_bitmap_ex, +create_video_bitmap, +create_sub_bitmap, +destroy_bitmap, +is_system_bitmap, +clear_bitmap, +clear_to_color.
+ +
Examples using this: +exupdate.
+
void destroy_bitmap(BITMAP *bitmap);

+ Destroys a memory bitmap, sub-bitmap, video memory bitmap, or system + bitmap when you are finished with it. If you pass a NULL pointer this + function won't do anything. See above for the restrictions as to when you + are allowed to destroy the various types of bitmaps. + +

+ The bitmap must not have a mouse cursor shown on it at the time it is + destroyed. + + +

See also: +create_bitmap, +load_bitmap, +show_mouse.
+ +
Examples using this: +Available Allegro examples.
+
void lock_bitmap(BITMAP *bitmap);

+ Under DOS, locks all the memory used by a bitmap. You don't normally need + to call this function unless you are doing very weird things in your + program. + +


+

int bitmap_color_depth(BITMAP *bmp);

+ Returns the color depth of the specified bitmap (8, 15, 16, 24, or 32). + Example: +
+      switch (bitmap_color_depth(screen)) {
+         case 8:
+            /* Access screen using optimized 8-bit code. */
+            break;
+         default:
+            /* Use generic slow functions. */
+            break;
+      }
+ + +
See also: +set_color_depth, +bitmap_mask_color.
+ +
Examples using this: +ex3d, +exlights, +exscn3d, +exswitch, +extrans, +exupdate, +exzbuf.
+
int bitmap_mask_color(BITMAP *bmp);

+ Returns the mask color for the specified bitmap (the value which is + skipped when drawing sprites). For 256-color bitmaps this is zero, and + for truecolor bitmaps it is bright pink (maximum red and blue, zero + green). A frequent use of this function is to clear a bitmap with the mask + color so you can later use this bitmap with masked_blit() or + draw_sprite() after drawing other stuff on it. Example: +
+      /* Replace mask color with another color. */
+      for (y = 0; y < bmp->h; y++)
+         for (x = 0; x < bmp->w; x++)
+            if (getpixel(bmp, x, y) == bitmap_mask_color(bmp))
+               putpixel(bmp, x, y, another_color);
+ + +
See also: +MASK_COLOR_8, +set_color_depth, +bitmap_color_depth.
+ +
Examples using this: +ex3d, +exmouse, +expat.
+
int is_same_bitmap(BITMAP *bmp1, BITMAP *bmp2);

+ Returns TRUE if the two bitmaps describe the same drawing surface, ie. + the pointers are equal, one is a sub-bitmap of the other, or they are + both sub-bitmaps of a common parent. + + +
See also: +create_sub_bitmap.
+
int is_planar_bitmap(BITMAP *bmp);

+ Returns TRUE if bmp is a planar (mode-X or Xtended mode) screen bitmap. + + +
See also: +is_linear_bitmap, +is_memory_bitmap.
+
int is_linear_bitmap(BITMAP *bmp);

+ Returns TRUE if bmp is a linear bitmap, i.e. a bitmap that can be accessed + linearly within each scanline (for example a memory bitmap, the DOS VGA + or SVGA screen, Windows bitmaps, etc). Linear bitmaps can be used with the + _putpixel(), _getpixel(), bmp_write_line(), and bmp_read_line() functions. + +

+ Historically there were only linear and planar bitmaps for Allegro, so + is_linear_bitmap() is actually an alias for !is_planar_bitmap(). + + +

See also: +is_planar_bitmap, +is_memory_bitmap.
+
int is_memory_bitmap(BITMAP *bmp);

+ Returns TRUE if bmp is a memory bitmap, ie. it was created by calling + create_bitmap() or loaded from a grabber datafile or image file. Memory + bitmaps can be accessed directly via the line pointers in the bitmap + structure, eg. bmp->line[y][x] = color. + + +
See also: +is_linear_bitmap, +is_planar_bitmap.
+
int is_screen_bitmap(BITMAP *bmp);

+ Returns TRUE if bmp is the screen bitmap, or a sub-bitmap of the screen. + + +
See also: +screen, +create_sub_bitmap.
+
int is_video_bitmap(BITMAP *bmp);

+ Returns TRUE if bmp is the screen bitmap, a video memory bitmap, or a + sub-bitmap of either. + + +
See also: +screen, +create_video_bitmap, +create_sub_bitmap.
+
int is_system_bitmap(BITMAP *bmp);

+ Returns TRUE if bmp is a system bitmap object, or a sub-bitmap of one. + + +
See also: +create_system_bitmap, +create_sub_bitmap.
+
int is_sub_bitmap(BITMAP *bmp);

+ Returns TRUE if bmp is a sub-bitmap. + + +
See also: +create_sub_bitmap.
+
void acquire_bitmap(BITMAP *bmp);

+ Acquires the specified video bitmap prior to drawing onto it. You never need + to call the function explicitly as it is low level, and will only give you a + speed up if you know what you are doing. Using it wrongly may cause slowdown, + or even lock up your program. + +

+ Note: You do never need to use acquire_bitmap on a memory bitmap, i.e. a + normal bitmap created with create_bitmap. It will simply do nothing in that + case. + +

+ It still can be useful, because e.g. under the current DirectDraw driver of + Allegro, most drawing functions need to lock a video bitmap before drawing to + it. But doing this is very slow, so you will get much better performance if + you acquire the screen just once at the start of your main redraw function, + then call multiple drawing operations which need the bitmap locked, and only + release it when done. + +

+ Multiple acquire calls may be nested, but you must make sure to match up the + acquire_bitmap and release_bitmap calls. Be warned that DirectX and X11 + programs activate a mutex lock whenever a surface is locked, which prevents + them from getting any input messages, so you must be sure to release all your + bitmaps before using any timer, keyboard, or other non-graphics routines! + +

+ Note that if you are using hardware accelerated VRAM->VRAM functions, you + should not call acquire_bitmap(). Such functions need an unlocked target + bitmap under DirectX, so there is now just the opposite case from before - if + the bitmap is already locked with acquire_bitmap, the drawing + operation has to unlock it. + +

+ Note: For backwards compatibility, the unlocking behavior of such functions + is permanent. That is, if you call acquire_bitmap first, then call e.g. an + accelerated blit, the DirectX bitmap will be unlocked internally (it won't + affect the nesting counter of acquire/release calls). + +

+ There is no clear cross-platform way in this Allegro version to know which + drawing operations need a locked/unlocked state. For example a normal + rectfill most probably is accelerated under DirectX, and therefore needs the + screen unlocked, but an XOR rectfill, or one with blending activated, most + probably is not, and therefore locks the screen. And while the DirectX driver + will do automatic unlocking, there is no such thing under X11, where the + function is used to synchronize X11 calls from different threads. Your best + bet is to never use acquire_bitmap - changes are you are doing something in + the wrong way if you think you need it. + +

+ Warning: This function can be very dangerous to use, since the whole program + may get locked while the bitmap is locked. So the lock should only be held + for a short time, and you should not call anything but drawing operations + onto the locked video bitmap while a lock is in place. Especially don't call + things like show_mouse (or scare_mouse which calls that) or readkey, since + it will most likely deadlock your entire program. + + +

See also: +release_bitmap, +acquire_screen, +release_screen.
+ +
Examples using this: +ex3buf, +exaccel, +expat, +exquat, +exscroll, +exswitch, +exupdate.
+
void release_bitmap(BITMAP *bmp);

+ Releases a bitmap that was previously locked by calling acquire_bitmap(). + If the bitmap was locked multiple times, you must release it the same + number of times before it will truly be unlocked. + + +
See also: +acquire_bitmap, +acquire_screen, +release_screen.
+ +
Examples using this: +ex3buf, +exaccel, +expat, +exquat, +exscroll, +exswitch, +exupdate.
+
void acquire_screen();

+ Shortcut version of acquire_bitmap(screen); + + +
See also: +acquire_bitmap, +release_bitmap, +release_screen.
+ +
Examples using this: +Available Allegro examples.
+
void release_screen();

+ Shortcut version of release_bitmap(screen); + + +
See also: +acquire_bitmap, +release_bitmap, +acquire_screen.
+ +
Examples using this: +Available Allegro examples.
+
void set_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2);

+ Each bitmap has an associated clipping rectangle, which is the area of + the image that it is ok to draw onto. Nothing will be drawn to positions + outside this space. This function sets the clipping rectangle for the + specified bitmap. Pass the coordinates of the top-left and bottom-right + corners of the clipping rectangle in this order; these are both inclusive, + i.e. set_clip_rect(bitmap, 16, 16, 32, 32) will allow drawing to (16, 16) + and (32, 32), but not to (15, 15) and (33, 33). + +

+ Drawing operations will be performed (at least partially) on the bitmap as + long as the first coordinates of its clipping rectangle are not greater + than the second coordinates and its intersection with the actual image + is non-empty. If either condition is not fulfilled, drawing will be turned + off for the bitmap, e.g. +

+      set_clip_rect(bmp, 0, 0, -1, -1); /* disable drawing on bmp */
+ +

+ Note that passing "out-of-bitmap" coordinates is allowed, but they are + likely to be altered (and so the coordinates returned by get_clip_rect() + will be different). However, such modifications are guaranteed to preserve + the external effect of the clipping rectangle, that is not to modify the + actual area of the image that it is ok to draw onto. + + +

See also: +get_clip_rect, +add_clip_rect, +set_clip_state, +get_clip_state.
+ +
Examples using this: +ex12bit, +excamera.
+
void get_clip_rect(BITMAP *bitmap, int *x1, int *y1, int *x2, int *y2);

+ Returns the clipping rectangle for the specified bitmap. + + +
See also: +set_clip_rect, +add_clip_rect, +set_clip_state, +get_clip_state.
+
void add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2);

+ Sets the clipping rectangle of the specified bitmap as the intersection of + its current clipping rectangle and the rectangle described by the four + coordinates. + + +
See also: +set_clip_rect, +get_clip_rect, +set_clip_state, +get_clip_state.
+
void set_clip_state(BITMAP *bitmap, int state)

+ Turns on (if state is non-zero) or off (if state is zero) clipping for the + specified bitmap. Turning clipping off may slightly speed up some drawing + operations (usually a negligible difference, although every little helps) + but will result in your program dying a horrible death if you try to draw + beyond the edges of the bitmap. + + +
See also: +set_clip_rect, +get_clip_rect, +add_clip_rect, +get_clip_state.
+
int get_clip_state(BITMAP *bitmap)

+ Returns non-zero if clipping is turned on for the specified bitmap and + zero otherwise. + + +
See also: +set_clip_rect, +get_clip_rect, +add_clip_rect, +set_clip_state.
+
int is_inside_bitmap(BITMAP *bmp, int x, int y, int clip);

+ Returns non-zero if point (x, y) lies inside the bitmap. If `clip' is + non-zero, the function compares the coordinates with the clipping + rectangle, that is it returns non-zero if the point lies inside the + clipping rectangle or if clipping is disabled for the bitmap. If `clip' + is zero, the function compares the coordinates with the actual dimensions + of the bitmap. + + + + +
See also: +set_clip_rect, +set_clip_state, +getpixel.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg010.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg010.html new file mode 100644 index 0000000..b44b354 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg010.html @@ -0,0 +1,420 @@ + + +Allegro Manual: Loading image files + + + + +

Loading image files

+ + + +

+Warning: when using truecolor images, you should always set the graphics +mode before loading any bitmap data! Otherwise the pixel format (RGB or BGR) +will not be known, so the file may be converted wrongly. + +


+

BITMAP *load_bitmap(const char *filename, RGB *pal);

+ Loads a bitmap from a file. The palette data will be stored in the second + parameter, which should be an array of 256 RGB structures. At present this + function supports BMP, LBM, PCX, and TGA files, determining the type from + the file extension. + +

+ If the file contains a truecolor image, you must set the video mode or + call set_color_conversion() before loading it. In this case, if the + destination color depth is 8-bit, the palette will be generated by calling + generate_optimized_palette() on the bitmap; otherwise, the returned + palette will be generated by calling generate_332_palette(). + +

+ The pal argument may be NULL. In this case, the palette data are simply + not returned. Additionally, if the file is a truecolor image and the + destination color depth is 8-bit, the color conversion process will use + the current palette instead of generating an optimized one. + +

+ Example: +

+      BITMAP *bmp;
+      PALETTE palette;
+      ...
+      bmp = load_bitmap("image.pcx", palette);
+      if (!bmp)
+         abort_on_error("Couldn't load image.pcx!");
+      ...
+      destroy_bitmap(bmp);
+

Return value: + Returns a pointer to the bitmap or NULL on error. Remember that you are + responsible for destroying the bitmap when you are finished with it to + avoid memory leaks. + + +

See also: +load_bmp, +load_lbm, +load_pcx, +load_tga, +destroy_bitmap, +save_bitmap, +register_bitmap_file_type, +set_color_depth, +set_color_conversion, +generate_optimized_palette, +generate_332_palette.
+ +
Examples using this: +exaccel, +exalpha, +exbitmap, +exblend, +exconfig, +exlights, +exshade, +extrans, +exxfade.
+
BITMAP *load_bmp(const char *filename, RGB *pal);

+ Loads an 8-bit, 16-bit, 24-bit or 32-bit Windows or OS/2 BMP file. +

Return value: + Returns a pointer to the bitmap or NULL on error. Remember that you are + responsible for destroying the bitmap when you are finished with it to + avoid memory leaks. + + +

See also: +load_bitmap, +load_bmp_pf.
+
BITMAP *load_bmp_pf(PACKFILE *f, RGB *pal);

+ A version of load_bmp() which reads from a packfile. Example: +
+      PACKFILE *packfile;
+      BITMAP *bmp;
+
+      packfile = pack_fopen("mybitmap.bmp", F_READ);
+      if (!packfile)
+         abort_on_error("Couldn't open mybitmap.bmp");
+         
+      bmp = load_bmp_pf(packfile, pal);
+      if (!bmp)
+         abort_on_error("Error loading mybitmap.bmp");
+

Return value: + Returns a pointer to the bitmap or NULL on error. Remember that you are + responsible for destroying the bitmap when you are finished with it to + avoid memory leaks. + + +

See also: +load_bmp.
+ +
Examples using this: +expackf.
+
BITMAP *load_lbm(const char *filename, RGB *pal);

+ Loads a 256-color IFF ILBM/PBM file. +

Return value: + Returns a pointer to the bitmap or NULL on error. Remember that you are + responsible for destroying the bitmap when you are finished with it to + avoid memory leaks. + + +

See also: +load_bitmap.
+
BITMAP *load_pcx(const char *filename, RGB *pal);

+ Loads a 256-color or 24-bit truecolor PCX file. +

Return value: + Returns a pointer to the bitmap or NULL on error. Remember that you are + responsible for destroying the bitmap when you are finished with it to + avoid memory leaks. + + +

See also: +load_bitmap.
+ +
Examples using this: +expackf, +exscale.
+
BITMAP *load_pcx_pf(PACKFILE *f, RGB *pal);

+ A version of load_pcx() which reads from a packfile. Example: +
+      PACKFILE *packfile;
+      BITMAP *bmp;
+
+      packfile = pack_fopen("mybitmap.pcx", F_READ);
+      if (!packfile)
+         abort_on_error("Couldn't open mybitmap.pcx");
+         
+      bmp = load_bmp_pf(packfile, pal);
+      if (!bmp)
+         abort_on_error("Error loading mybitmap.pcx");
+

Return value: + Returns a pointer to the bitmap or NULL on error. Remember that you are + responsible for destroying the bitmap when you are finished with it to + avoid memory leaks. + + +

See also: +load_pcx.
+ +
Examples using this: +expackf.
+
BITMAP *load_tga(const char *filename, RGB *pal);

+ Loads a 256-color, 15-bit hicolor, 24-bit truecolor, or 32-bit + truecolor+alpha TGA file. +

Return value: + Returns a pointer to the bitmap or NULL on error. Remember that you are + responsible for destroying the bitmap when you are finished with it to + avoid memory leaks. + + +

See also: +load_bitmap.
+
BITMAP *load_tga_pf(PACKFILE *f, RGB *pal);

+ A version of load_tga() which reads from a packfile. Example: +
+      PACKFILE *packfile;
+      BITMAP *bmp;
+
+      packfile = pack_fopen("mybitmap.tga", F_READ);
+      if (!packfile)
+         abort_on_error("Couldn't open mybitmap.tga");
+         
+      bmp = load_bmp_pf(packfile, pal);
+      if (!bmp)
+         abort_on_error("Error loading mybitmap.tga");
+

Return value: + Returns a pointer to the bitmap or NULL on error. Remember that you are + responsible for destroying the bitmap when you are finished with it to + avoid memory leaks. + + +

See also: +load_tga.
+ +
Examples using this: +expackf.
+
int save_bitmap(const char *filename, BITMAP *bmp, const RGB *pal);

+ Writes a bitmap into a file, using the specified palette, which should be + an array of 256 RGB structures. The output format is determined from the + filename extension: at present this function supports BMP, PCX and TGA + formats. + +

+ Two things to watch out for: on some video cards it may be faster to copy + the screen to a memory bitmap and save the latter, and if you use this to + dump the screen into a file you may end up with an image much larger than + you were expecting, because Allegro often creates virtual screens larger + than the visible screen. You can get around this by using a sub-bitmap to + specify which part of the screen to save, eg: +

+      BITMAP *bmp;
+      PALETTE pal;
+      ...
+      get_palette(pal);
+      bmp = create_sub_bitmap(screen, 0, 0, SCREEN_W, SCREEN_H);
+      save_bitmap("dump.pcx", bmp, pal);
+      destroy_bitmap(bmp);
+

Return value: + Returns non-zero on error. + + +

See also: +save_bmp, +save_pcx, +save_tga, +load_bitmap, +register_bitmap_file_type.
+
int save_bmp(const char *filename, BITMAP *bmp, const RGB *pal);

+ Writes a bitmap into a 256-color or 24-bit truecolor BMP file. +

Return value: + Returns non-zero on error. + + +

See also: +save_bitmap.
+
int save_bmp_pf(PACKFILE *f, BITMAP *bmp, RGB *pal);

+ A version of save_bmp which writes to a packfile. + + +
See also: +save_bmp.
+ +
Examples using this: +expackf.
+
int save_pcx(const char *filename, BITMAP *bmp, const RGB *pal);

+ Writes a bitmap into a 256-color or 24-bit truecolor PCX file. +

Return value: + Returns non-zero on error. + + +

See also: +save_bitmap.
+
int save_pcx_pf(PACKFILE *f, BITMAP *bmp, RGB *pal);

+ A version of save_pcx which writes to a packfile. + + +
See also: +save_pcx.
+
int save_tga(const char *filename, BITMAP *bmp, const RGB *pal);

+ Writes a bitmap into a 256-color, 15-bit hicolor, 24-bit truecolor, or + 32-bit truecolor+alpha TGA file. +

Return value: + Returns non-zero on error. + + +

See also: +save_bitmap.
+
int save_tga_pf(PACKFILE *f, BITMAP *bmp, RGB *pal);

+ A version of save_tga which writes to a packfile. + + +
See also: +save_tga.
+ +
Examples using this: +expackf.
+
void register_bitmap_file_type(const char *ext, + BITMAP *(*load)(const char *filename, RGB *pal), + int (*save)(const char *filename, BITMAP *bmp, const RGB *pal));

+ Informs the load_bitmap() and save_bitmap() functions of a new file type, + providing routines to read and write images in this format (either + function may be NULL). The functions you supply must follow the same + prototype as load_bitmap() and save_bitmap(). Example: +
+      BITMAP *load_dump(const char *filename, RGB *pal)
+      {
+         ...
+      }
+      
+      int save_dump(const char *filename, BITMAP *bmp, const RGB *pal)
+      {
+         ...
+      }
+
+         register_bitmap_file_type("dump", load_dump, save_dump);
+ + +
See also: +load_bitmap, +save_bitmap.
+
void set_color_conversion(int mode);

+ Specifies how to convert images between the various color depths when + reading graphics from external bitmap files or datafiles. The mode is a + bitmask specifying which types of conversion are allowed. If the + appropriate bit is set, data will be converted into the current pixel + format (selected by calling the set_color_depth() function), otherwise it + will be left in the same format as the disk file, leaving you to convert + it manually before the graphic can be displayed. The default mode is + total conversion, so that all images will be loaded in the appropriate + format for the current video mode. Valid bit flags are: +
+      COLORCONV_NONE                // disable all format
+                                    // conversions
+      COLORCONV_8_TO_15             // expand 8-bit to 15-bit
+      COLORCONV_8_TO_16             // expand 8-bit to 16-bit
+      COLORCONV_8_TO_24             // expand 8-bit to 24-bit
+      COLORCONV_8_TO_32             // expand 8-bit to 32-bit
+      COLORCONV_15_TO_8             // reduce 15-bit to 8-bit
+      COLORCONV_15_TO_16            // expand 15-bit to 16-bit
+      COLORCONV_15_TO_24            // expand 15-bit to 24-bit
+      COLORCONV_15_TO_32            // expand 15-bit to 32-bit
+      COLORCONV_16_TO_8             // reduce 16-bit to 8-bit
+      COLORCONV_16_TO_15            // reduce 16-bit to 15-bit
+      COLORCONV_16_TO_24            // expand 16-bit to 24-bit
+      COLORCONV_16_TO_32            // expand 16-bit to 32-bit
+      COLORCONV_24_TO_8             // reduce 24-bit to 8-bit
+      COLORCONV_24_TO_15            // reduce 24-bit to 15-bit
+      COLORCONV_24_TO_16            // reduce 24-bit to 16-bit
+      COLORCONV_24_TO_32            // expand 24-bit to 32-bit
+      COLORCONV_32_TO_8             // reduce 32-bit RGB to 8-bit
+      COLORCONV_32_TO_15            // reduce 32-bit RGB to 15-bit
+      COLORCONV_32_TO_16            // reduce 32-bit RGB to 16-bit
+      COLORCONV_32_TO_24            // reduce 32-bit RGB to 24-bit
+      COLORCONV_32A_TO_8            // reduce 32-bit RGBA to 8-bit
+      COLORCONV_32A_TO_15           // reduce 32-bit RGBA to 15-bit
+      COLORCONV_32A_TO_16           // reduce 32-bit RGBA to 16-bit
+      COLORCONV_32A_TO_24           // reduce 32-bit RGBA to 24-bit
+      COLORCONV_DITHER_PAL          // dither when reducing to 8-bit
+      COLORCONV_DITHER_HI           // dither when reducing to
+                                    // hicolor
+      COLORCONV_KEEP_TRANS          // keep original transparency
+
+ For convenience, the following macros can be used to select common + combinations of these flags: +
+      COLORCONV_EXPAND_256          // expand 256-color to hi/truecolor
+      COLORCONV_REDUCE_TO_256       // reduce hi/truecolor to 256-color
+      COLORCONV_EXPAND_15_TO_16     // expand 15-bit hicolor to 16-bit
+      COLORCONV_REDUCE_16_TO_15     // reduce 16-bit hicolor to 15-bit
+      COLORCONV_EXPAND_HI_TO_TRUE   // expand 15/16-bit to 24/32-bit
+      COLORCONV_REDUCE_TRUE_TO_HI   // reduce 24/32-bit to 15/16-bit
+      COLORCONV_24_EQUALS_32        // convert between 24- and 32-bit
+      COLORCONV_TOTAL               // everything to current format
+      COLORCONV_PARTIAL             // convert 15 <-> 16-bit and
+                                    // 24 <-> 32-bit
+      COLORCONV_MOST                // all but hi/truecolor <-> 256
+      COLORCONV_DITHER              // dither during all color reductions
+      COLORCONV_KEEP_ALPHA          // convert everything to current format
+                                    // unless it would lose alpha information
+
+ If you enable the COLORCONV_DITHER flag, dithering will be performed + whenever truecolor graphics are converted into a hicolor or paletted + format, including by the blit() function, and any automatic conversions + that take place while reading graphics from disk. This can produce much + better looking results, but is obviously slower than a direct conversion. + +

+ If you intend using converted bitmaps with functions like masked_blit() + or draw_sprite(), you should specify the COLORCONV_KEEP_TRANS flag. It + will ensure that the masked areas in the bitmap before and after the + conversion stay exactly the same, by mapping transparent colors to each + other and adjusting colors which would be converted to the transparent + color otherwise. It affects every blit() operation between distinct pixel + formats and every automatic conversion. + + +

See also: +set_color_depth, +load_bitmap, +load_datafile, +fixup_datafile, +makecol15_dither, +get_color_conversion.
+ +
Examples using this: +exalpha, +exblend, +exdata, +exexedat, +exlights, +exxfade.
+
int get_color_conversion();

+ Returns the current color conversion mode. + + + + +
See also: +set_color_conversion.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg011.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg011.html new file mode 100644 index 0000000..69f06b6 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg011.html @@ -0,0 +1,411 @@ + + +Allegro Manual: Palette routines + + + + +

Palette routines

+ + + +

+All the Allegro drawing functions use integer parameters to represent +colors. In truecolor resolutions these numbers encode the color directly as +a collection of red, green, and blue bits, but in a regular 256-color mode +the values are treated as indexes into the current palette, which is a table +listing the red, green and blue intensities for each of the 256 possible +colors. + +

+Palette entries are stored in an RGB structure, which contains red, green +and blue intensities in the VGA hardware format, ranging from 0-63, and is +defined as: +

+   typedef struct RGB
+   {
+      unsigned char r, g, b;
+   } RGB;
+
+It contains an additional field for the purpose of padding but you should +not usually care about it. For example: +
+   RGB black = { 0,  0,  0  };
+   RGB white = { 63, 63, 63 };
+   RGB green = { 0,  63, 0  };
+   RGB grey  = { 32, 32, 32 };
+
+The type PALETTE is defined to be an array of PAL_SIZE RGB structures, where +PAL_SIZE is a preprocessor constant equal to 256. + +

+You may notice that a lot of the code in Allegro spells 'palette' as +'pallete'. This is because the headers from my old Mark Williams compiler on +the Atari spelt it with two l's, so that is what I'm used to. Allegro will +happily accept either spelling, due to some #defines in allegro/alcompat.h +(which can be turned off by defining the ALLEGRO_NO_COMPATIBILITY symbol +before including Allegro headers). + +


+

void set_color(int index, const RGB *p);

+ Sets the specified palette entry to the specified RGB triplet. Unlike the + other palette functions this doesn't do any retrace synchronisation, so + you should call vsync() before it to prevent snow problems. Example: +
+      RGB rgb;
+      ...
+      vsync();
+      set_color(192, &rgb);
+ + +
See also: +set_palette, +get_color, +_set_color.
+ +
Examples using this: +ex12bit, +exrgbhsv, +exscroll.
+
void _set_color(int index, const RGB *p);

+ This is an inline version of set_color(), intended for use in the + vertical retrace simulator callback function (retrace_proc, which is now + deprecated). + +

+ If you really must use _set_color from retrace_proc, note that it should + only be used under DOS, in VGA mode 13h and mode-X. Some SVGA chipsets + aren't VGA compatible (set_color() and set_palette() will use VESA calls on + these cards, but _set_color() doesn't know about that). + + +

See also: +set_color, +set_gfx_mode.
+ +
Examples using this: +ex3buf.
+
void set_palette(const PALETTE p);

+ Sets the entire palette of 256 colors. You should provide an array of 256 + RGB structures. Unlike set_color(), there is no need to call vsync() + before this function. Example: +
+      BITMAP *bmp;
+      PALETTE palette;
+      ...
+      bmp = load_bitmap(filename, palette);
+      if (!bmp)
+         abort_on_error("Couldn't load bitmap!");
+      set_palette(palette);
+ + +
See also: +set_gfx_mode, +set_palette_range, +set_color, +get_palette, +select_palette, +palette_color.
+ +
Examples using this: +Available Allegro examples.
+
void set_palette_range(const PALETTE p, int from, int to, int vsync);

+ Sets the palette entries between from and to (inclusive: pass 0 and 255 + to set the entire palette). If vsync is set it waits for the vertical + retrace, otherwise it sets the colors immediately. Example: +
+      PALETTE palette;
+      ...
+      /* Modify the first 16 entries. */
+      change_first_16_colors(palette);
+      /* Now update them waiting for vsync. */
+      set_palette_range(palette, 0, 15, 1);
+ + +
See also: +set_palette, +get_palette_range.
+
void get_color(int index, RGB *p);

+ Retrieves the specified palette entry. Example: +
+      RGB color;
+      ...
+      get_color(11, &color);
+ + +
See also: +get_palette, +set_color.
+
void get_palette(PALETTE p);

+ Retrieves the entire palette of 256 colors. You should provide an array + of 256 RGB structures to store it in. Example: +
+      PALETTE pal;
+      ...
+      get_palette(pal);
+ + +
See also: +get_palette_range, +get_color, +set_palette.
+
void get_palette_range(PALETTE p, int from, int to);

+ Retrieves the palette entries between from and to (inclusive: pass 0 and + 255 to get the entire palette). + + +
See also: +get_palette, +set_palette_range.
+
void fade_interpolate(const PALETTE source, const PALETTE dest, + PALETTE output, int pos, int from, int to);

+ Calculates a temporary palette part way between source and dest, + returning it in the output parameter. The position between the two + extremes is specified by the pos value: 0 returns an exact copy of + source, 64 returns dest, 32 returns a palette half way between the two, + etc. This routine only affects colors between from and to (inclusive: + pass 0 and 255 to interpolate the entire palette). + + +
See also: +fade_in, +fade_out, +fade_from.
+
void fade_from_range(const PALETTE source, const PALETTE dest, + int speed, int from, int to);

+ Gradually fades a part of the palette from the source palette to the dest + palette. The speed is from 1 (the slowest) up to 64 (instantaneous). This + routine only affects colors between from and to (inclusive: pass 0 and + 255 to fade the entire palette). + +

+ Note that this function will block your game while the fade is in effect, + and it won't work right visually if you are not in an 8 bit color depth + resolution. + + +

See also: +fade_from.
+
void fade_in_range(const PALETTE p, int speed, int from, int to);

+ Gradually fades a part of the palette from a black screen to the + specified palette. The speed is from 1 (the slowest) up to 64 + (instantaneous). This routine only affects colors between from and to + (inclusive: pass 0 and 255 to fade the entire palette). + +

+ Note that this function will block your game while the fade is in effect, + and it won't work right visually if you are not in an 8 bit color depth + resolution. + + +

See also: +fade_in.
+
void fade_out_range(int speed, int from, int to);

+ Gradually fades a part of the palette from the current palette to a black + screen. The speed is from 1 (the slowest) up to 64 (instantaneous). This + routine only affects colors between from and to (inclusive: pass 0 and + 255 to fade the entire palette). + +

+ Note that this function will block your game while the fade is in effect, + and it won't work right visually if you are not in an 8 bit color depth + resolution. + + +

See also: +fade_out.
+
void fade_from(const PALETTE source, const PALETTE dest, int speed);

+ Fades gradually from the source palette to the dest palette. The speed is + from 1 (the slowest) up to 64 (instantaneous). + +

+ Note that this function will block your game while the fade is in effect, + and it won't work right visually if you are not in an 8 bit color depth + resolution. + + +

See also: +fade_in, +fade_out, +fade_interpolate, +fade_from_range.
+
void fade_in(const PALETTE p, int speed);

+ Fades gradually from a black screen to the specified palette. The speed + is from 1 (the slowest) up to 64 (instantaneous). + +

+ Note that this function will block your game while the fade is in effect, + and it won't work right visually if you are not in an 8 bit color depth + resolution. + + +

See also: +fade_out, +fade_from, +fade_interpolate, +fade_in_range.
+
void fade_out(int speed);

+ Fades gradually from the current palette to a black screen. The speed is + from 1 (the slowest) up to 64 (instantaneous). + +

+ Note that this function will block your game while the fade is in effect, + and it won't work right visually if you are not in an 8 bit color depth + resolution. + + +

See also: +fade_in, +fade_from, +fade_interpolate, +fade_in_range.
+ +
Examples using this: +ex12bit.
+
void select_palette(const PALETTE p);

+ Ugly hack for use in various dodgy situations where you need to convert + between paletted and truecolor image formats. Sets the internal palette + table in the same way as the set_palette() function, so the conversion + will use the specified palette, but without affecting the display + hardware in any way. The previous palette settings are stored in an + internal buffer, and can be restored by calling unselect_palette(). If + you call select_palette() again, however, the internal buffer will be + overwritten. + + +
See also: +set_palette, +unselect_palette.
+ +
Examples using this: +exlights.
+
void unselect_palette();

+ Restores the palette tables that were in use before the last call to + select_palette(). + + +
See also: +select_palette.
+
void generate_332_palette(PALETTE pal);

+ Constructs a fake truecolor palette, using three bits for red and green + and two for the blue. The load_bitmap() function fills the palette + parameter with this if the file does not contain a palette itself (ie. you + are reading a truecolor bitmap). + + +
See also: +generate_optimized_palette, +set_color_depth.
+ +
Examples using this: +excolmap, +exrgbhsv, +extruec, +exupdate.
+
int generate_optimized_palette(BITMAP *bmp, PALETTE pal, + const char rsvd[PAL_SIZE]);

+ Generates a 256-color palette suitable for making a reduced color version + of the specified truecolor image. The rsvd parameter points to a table + indicating which colors it is allowed to modify: zero for free colors + which may be set to whatever the optimiser likes, negative values for + reserved colors which cannot be used, and positive values for fixed + palette entries that must not be changed, but can be used in the + optimisation. +

Return value: + Returns the number of different colors recognised in the provided bitmap, + zero if the bitmap is not a truecolor image or there wasn't enough memory + to perform the operation, and negative if there was any internal error in + the color reduction code. + + +

See also: +generate_332_palette, +set_color_depth.
+
extern PALETTE default_palette;

+ The default IBM BIOS palette. This will be automatically selected + whenever you set a new graphics mode. The palette contains 16 basic + colors plus many gradients between them. If you want to see the values, + you can write a small Allegro program which saves a screenshot with this + palette, or open the grabber tool provided with Allegro and create a new + palette object, which will use this palette by default. + + +
See also: +black_palette, +desktop_palette.
+ +
Examples using this: +exjoy.
+
extern PALETTE black_palette;

+ A palette containing solid black colors, used by the fade routines. + + +
See also: +default_palette, +desktop_palette.
+ +
Examples using this: +expal.
+
extern PALETTE desktop_palette;

+ The palette used by the Atari ST low resolution desktop. I'm not quite + sure why this is still here, except that the grabber and test programs + use it. It is probably the only Atari legacy code left in Allegro, and it + would be a shame to remove it :-) + +

+ The contents of this palette are 16 colors repeated 16 times. Color entry + zero is equal to color entry 16, which is equal to color entry 24, etc. +

+       Index      Color       RGB values
+         0     White          63  63  63
+         1     Red            63   0   0
+         2     Green           0  63   0
+         3     Yellow         63  63   0
+         4     Blue            0   0  63
+         5     Pink           63   0  63
+         6     Cyan            0  63  63
+         7     Grey           16  16  16
+         8     Light grey     31  31  31
+         9     Light red      63  31  31
+        10     Light green    31  63  31
+        11     Light yellow   63  63  31
+        12     Light blue     31  31  63
+        13     Light pink     63  31  63
+        14     Light cyan     31  63  63
+        15     Black           0   0   0
+ + + + +
See also: +default_palette, +black_palette.
+ +
Examples using this: +Available Allegro examples.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg012.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg012.html new file mode 100644 index 0000000..909b34c --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg012.html @@ -0,0 +1,327 @@ + + +Allegro Manual: Truecolor pixel formats + + + + +

Truecolor pixel formats

+ + + +

+In a truecolor video mode the red, green, and blue components for each pixel +are packed directly into the color value, rather than using a palette lookup +table. In a 15-bit mode there are 5 bits for each color, in 16-bit modes +there are 5 bits each of red and blue and six bits of green, and both 24 and +32-bit modes use 8 bits for each color (the 32-bit pixels simply have an +extra padding byte to align the data nicely). The layout of these components +can vary depending on your hardware, but will generally either be RGB or +BGR. Since the layout is not known until you select the video mode you will +be using, you must call set_gfx_mode() before using any of the following +routines! + +


+

int makecol8(int r, int g, int b);

+
int makecol15(int r, int g, int b);

+
int makecol16(int r, int g, int b);

+
int makecol24(int r, int g, int b);

+
int makecol32(int r, int g, int b);

+ These functions convert colors from a hardware independent form (red, + green, and blue values ranging 0-255) into various display dependent + pixel formats. Converting to 15, 16, 24, or 32-bit formats only takes a + few shifts, so it is fairly efficient. Converting to an 8-bit color + involves searching the palette to find the closest match, which is quite + slow unless you have set up an RGB mapping table (see below). Example: +
+      /* 16 bit color version of green. */
+      int green_color = makecol16(0, 255, 0);
+

Return value: + Returns the requested RGB triplet in the specified color depth. + + +

See also: +makeacol32, +makecol, +makecol_depth, +makecol15_dither, +rgb_map, +bestfit_color, +set_color_depth.
+ +
Examples using this: +exrgbhsv.
+
int makeacol32(int r, int g, int b, int a);

+ Converts an RGBA color into a 32-bit display pixel format, which includes + an alpha (transparency) value. There are no versions of this routine for + other color depths, because only the 32-bit format has enough room to + store a proper alpha channel. You should only use RGBA format colors as + the input to draw_trans_sprite() or draw_trans_rle_sprite() after calling + set_alpha_blender(), rather than drawing them directly to the screen. + + +
See also: +makeacol, +set_alpha_blender, +set_write_alpha_blender.
+
int makecol(int r, int g, int b);

+ Converts colors from a hardware independent format (red, green, and blue + values ranging 0-255) to the pixel format required by the current video + mode, calling the preceding 8, 15, 16, 24, or 32-bit makecol functions as + appropriate. Example: +
+      /* Regardless of color depth, this will look green. */
+      int green_color = makecol(0, 255, 0);
+

Return value: + Returns the requested RGB triplet in the current color depth. + + +

See also: +makeacol, +makecol8, +makecol_depth, +makecol15_dither, +rgb_map, +set_color_depth.
+ +
Examples using this: +Available Allegro examples.
+
int makecol_depth(int color_depth, int r, int g, int b);

+ Converts colors from a hardware independent format (red, green, and blue + values ranging 0-255) to the pixel format required by the specified color + depth. Example: +
+      /* Compose the green color for 15 bit color depth. */
+      int green_15bit = makecol_depth(15, 0, 255, 0);
+

Return value: + Returns the requested RGB triplet in the specified color depth. + + +

See also: +makeacol, +makecol, +makecol8, +makecol15_dither, +rgb_map, +set_color_depth.
+
int makeacol(int r, int g, int b, int a);

+
int makeacol_depth(int color_depth, int r, int g, int b, int a);

+ Convert RGBA colors into display dependent pixel formats. In anything + less than a 32-bit mode, these are the same as calling makecol() or + makecol_depth(), but by using these routines it is possible to create + 32-bit color values that contain a true 8 bit alpha channel along with + the red, green, and blue components. You should only use RGBA format + colors as the input to draw_trans_sprite() or draw_trans_rle_sprite() + after calling set_alpha_blender(), rather than drawing them directly to + the screen. +

Return value: + Returns the requested RGBA quadruplet. + + +

See also: +makecol, +makecol_depth, +set_alpha_blender, +set_write_alpha_blender.
+
int makecol15_dither(int r, int g, int b, int x, int y);

+
int makecol16_dither(int r, int g, int b, int x, int y);

+ Given both a color value and a pixel coordinate, calculate a dithered 15 + or 16-bit RGB value. This can produce better results when reducing images + from truecolor to hicolor. In addition to calling these functions + directly, hicolor dithering can be automatically enabled when loading + graphics by calling the set_color_conversion() function, for example + set_color_conversion(COLORCONV_REDUCE_TRUE_TO_HI | COLORCONV_DITHER). + +

+ Example: +

+      int pixel1, pixel2;
+
+      /* The following two color values MAY be different. */
+      pixel1 = makecol16_dither(255, 192, 64, 0, 0);
+      pixel2 = makecol16_dither(255, 192, 64, 1, 0);
+

Return value: + Returns the RGB value dithered for the specified coordinate. + + +

See also: +makecol, +makecol8, +set_color_conversion.
+
int getr8(int c);

+
int getg8(int c);

+
int getb8(int c);

+
int getr15(int c);

+
int getg15(int c);

+
int getb15(int c);

+
int getr16(int c);

+
int getg16(int c);

+
int getb16(int c);

+
int getr24(int c);

+
int getg24(int c);

+
int getb24(int c);

+
int getr32(int c);

+
int getg32(int c);

+
int getb32(int c);

+ Given a color in a display dependent format, these functions extract one + of the red, green, or blue components (ranging 0-255). Example: +
+      int r, g, b, color_value;
+
+      color_value = _getpixel15(screen, 100, 100);
+      r = getr15(color_value);
+      g = getg15(color_value);
+      b = getb15(color_value);
+ + +
See also: +geta32, +getr, +getr_depth, +makecol, +set_color_depth.
+
int geta32(int c);

+ Given a color in a 32-bit pixel format, this function extracts the alpha + component (ranging 0-255). + + +
See also: +getr8.
+
int getr(int c);

+
int getg(int c);

+
int getb(int c);

+
int geta(int c);

+ Given a color in the format being used by the current video mode, these + functions extract one of the red, green, blue, or alpha components + (ranging 0-255), calling the preceding 8, 15, 16, 24, or 32-bit get + functions as appropriate. The alpha part is only meaningful for 32-bit + pixels. Example: +
+      int r, g, b, color_value;
+
+      color_value = getpixel(screen, 100, 100);
+      r = getr(color_value);
+      g = getg(color_value);
+      b = getb(color_value);
+ + +
See also: +getr8, +getr_depth, +makecol, +set_color_depth.
+ +
Examples using this: +exalpha.
+
int getr_depth(int color_depth, int c);

+
int getg_depth(int color_depth, int c);

+
int getb_depth(int color_depth, int c);

+
int geta_depth(int color_depth, int c);

+ Given a color in the format being used by the specified color depth, + these functions extract one of the red, green, blue, or alpha components + (ranging 0-255). The alpha part is only meaningful for 32-bit pixels. + Example: +
+      int r, g, b, color_value, bpp;
+
+      bpp = bitmap_color_depth(bitmap);
+      color_value = getpixel(bitmap, 100, 100);
+      r = getr_depth(bpp, color_value);
+      g = getg_depth(bpp, color_value);
+      b = getb_depth(bpp, color_value);
+ + +
See also: +getr, +getr8, +geta32, +makecol, +set_color_depth.
+ +
Examples using this: +exlights.
+
extern int palette_color[256];

+ Table mapping palette index colors (0-255) into whatever pixel format is + being used by the current display mode. In a 256-color mode this just + maps onto the array index. In truecolor modes it looks up the specified + entry in the current palette, and converts that RGB value into the + appropriate packed pixel format. Example: +
+      set_color_depth(32);
+      ...
+      set_palette(desktop_palette);
+      /* Put a pixel with the color 2 (green) of the palette */
+      putpixel(screen, 100, 100, palette_color[2]);
+ + +
See also: +set_palette, +makecol, +set_color_depth.
+ +
Examples using this: +Available Allegro examples.
+
#define MASK_COLOR_8 0

+
#define MASK_COLOR_15 (5.5.5 pink)

+
#define MASK_COLOR_16 (5.6.5 pink)

+
#define MASK_COLOR_24 (8.8.8 pink)

+
#define MASK_COLOR_32 (8.8.8 pink)

+ Constants representing the colors used to mask transparent sprite pixels + for each color depth. In 256-color resolutions this is zero, and in + truecolor modes it is bright pink (maximum red and blue, zero green). + + + + +
See also: +bitmap_mask_color, +makecol, +draw_sprite, +masked_blit.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg013.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg013.html new file mode 100644 index 0000000..63c3752 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg013.html @@ -0,0 +1,516 @@ + + +Allegro Manual: Drawing primitives + + + + +

Drawing primitives

+ + + +

+Except for _putpixel(), all these routines are affected by the current +drawing mode and the clipping rectangle of the destination bitmap. Unless +specified otherwise, all coordinates for drawing operations are inclusive, +and they, as well as lengths, are specified in pixel units. + +


+

void clear_bitmap(BITMAP *bitmap);

+ Clears the bitmap to color 0. + + +
See also: +clear_to_color.
+ +
Examples using this: +Available Allegro examples.
+
void clear_to_color(BITMAP *bitmap, int color);

+ Clears the bitmap to the specified color. Example: +
+      /* Clear the screen to red. */
+      clear_to_color(bmp, makecol(255, 0, 0));
+ + +
See also: +clear_bitmap, +makecol.
+ +
Examples using this: +Available Allegro examples.
+
void putpixel(BITMAP *bmp, int x, int y, int color);

+ Writes a pixel to the specified position in the bitmap, using the current + drawing mode and the bitmap's clipping rectangle. Example: +
+      putpixel(screen, 10, 30, some_color);
+ + +
See also: +getpixel, +_putpixel, +drawing_mode, +makecol.
+ +
Examples using this: +ex12bit, +exalpha, +exflame, +exjoy, +exstars, +exswitch.
+
void _putpixel(BITMAP *bmp, int x, int y, int color);

+
void _putpixel15(BITMAP *bmp, int x, int y, int color);

+
void _putpixel16(BITMAP *bmp, int x, int y, int color);

+
void _putpixel24(BITMAP *bmp, int x, int y, int color);

+
void _putpixel32(BITMAP *bmp, int x, int y, int color);

+ Like the regular putpixel(), but much faster because they are implemented + as an inline assembler functions for specific color depths. These won't + work in mode-X graphics modes, don't perform any clipping (they will + crash if you try to draw outside the bitmap!), and ignore the drawing + mode. + + +
See also: +putpixel, +makecol.
+
int getpixel(BITMAP *bmp, int x, int y);

+ Reads a pixel from point (x, y) in the bitmap. +

Return value: + Returns -1 if the point lies outside the bitmap (ignoring the clipping + rectangle), otherwise the value of the pixel in the color format of the + bitmap. + +

+ Warning: -1 is also a valid value for pixels contained in 32-bit bitmaps + with alpha channel (when R,G,B,A are all equal to 255) so you can't use + the test against -1 as a predicate for such bitmaps. In this cases, the + only reliable predicate is is_inside_bitmap(). + +

+ To extract the individual color components, use the getr() / getg() / + getb() / geta() family of functions. + + +

See also: +putpixel, +_getpixel, +is_inside_bitmap, +getr, +getg, +getb, +geta, +Truecolor pixel formats, +Palette routines.
+ +
Examples using this: +ex12bit, +exalpha, +exflame, +exlights.
+
int _getpixel(BITMAP *bmp, int x, int y);

+
int _getpixel15(BITMAP *bmp, int x, int y);

+
int _getpixel16(BITMAP *bmp, int x, int y);

+
int _getpixel24(BITMAP *bmp, int x, int y);

+
int _getpixel32(BITMAP *bmp, int x, int y);

+ Faster inline versions of getpixel() for specific color depths. These + won't work in mode-X, and don't do any clipping, so you must make sure + the point lies inside the bitmap. +

Return value: + Returns the value of the pixel in the color format you specified. + + +

See also: +getpixel.
+
void vline(BITMAP *bmp, int x, int y1, int y2, int color);

+ Draws a vertical line onto the bitmap, from point (x, y1) to (x, y2). + +

+ Note: vline() is implemented as an alias to another function. + See ALLEGRO_NO_VHLINE_ALIAS in the `Differences between platforms' + section for details. + + +

See also: +hline, +line, +drawing_mode, +makecol, +Differences between platforms.
+ +
Examples using this: +exrgbhsv, +exscroll, +extruec.
+
void hline(BITMAP *bmp, int x1, int y, int x2, int color);

+ Draws a horizontal line onto the bitmap, from point (x1, y) to (x2, y). + +

+ Note: hline() is implemented as an alias to another function. + See ALLEGRO_NO_VHLINE_ALIAS in the `Differences between platforms' + section for details. + + +

See also: +vline, +line, +drawing_mode, +makecol, +Differences between platforms.
+ +
Examples using this: +exsprite.
+
void do_line(BITMAP *bmp, int x1, y1, x2, y2, int d, + void (*proc)(BITMAP *bmp, int x, int y, int d));

+ Calculates all the points along a line from point (x1, y1) to (x2, y2), + calling the supplied function for each one. This will be passed a copy of + the bmp parameter, the x and y position, and a copy of the d parameter, + so it is suitable for use with putpixel(). Example: +
+      void draw_dust_particle(BITMAP *bmp, int x, int y, int d)
+      {
+         ...
+      }
+      
+         do_line(screen, 0, 0, SCREEN_W-1, SCREEN_H-2,
+                 dust_strength, draw_dust_particle);
+ + +
See also: +do_circle, +do_ellipse, +do_arc, +line.
+
void line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);

+ Draws a line onto the bitmap, from point (x1, y1) to (x2, y2). + + +
See also: +fastline, +hline, +vline, +do_line, +drawing_mode, +makecol.
+ +
Examples using this: +Available Allegro examples.
+
void fastline(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);

+ Faster version of the previous function. Note that pixel correctness is + not guaranteed for this function. + + +
See also: +line, +hline, +vline, +do_line, +drawing_mode, +makecol.
+ +
Examples using this: +Available Allegro examples.
+
void triangle(BITMAP *bmp, int x1, y1, x2, y2, x3, y3, int color);

+ Draws a filled triangle between the three points. + + +
See also: +polygon, +triangle3d, +drawing_mode, +makecol.
+ +
Examples using this: +ex3buf, +exstars, +exupdate.
+
void polygon(BITMAP *bmp, int vertices, const int *points, int color);

+ Draws a filled polygon with an arbitrary number of corners. Pass the + number of vertices and an array containing a series of x, y points (a + total of vertices*2 values). Example: +
+      int points[12] = { 50, 50,   100, 100,  100, 150,
+                         50, 200,  0,   150,  0,   100 };
+      ...
+      clear_to_color(screen, makecol(255, 255, 255));
+      polygon(screen, 6, points, makecol(0, 0, 0));
+ + +
See also: +triangle, +polygon3d, +drawing_mode, +makecol.
+ +
Examples using this: +excamera.
+
void rect(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);

+ Draws an outline rectangle with the two points as its opposite corners. + + +
See also: +rectfill, +drawing_mode, +makecol.
+ +
Examples using this: +ex3d, +excamera.
+
void rectfill(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);

+ Draws a solid, filled rectangle with the two points as its opposite + corners. + + +
See also: +rect, +clear_bitmap, +drawing_mode, +makecol.
+ +
Examples using this: +exalpha, +excolmap, +exkeys, +exmidi, +expat, +exscroll, +exsprite, +exstars, +exswitch, +extrans.
+
void do_circle(BITMAP *bmp, int x, int y, int radius, int d, + void (*proc)(BITMAP *bmp, int x, int y, int d));

+ Calculates all the points in a circle around point (x, y) with radius r, + calling the supplied function for each one. This will be passed a copy of + the bmp parameter, the x and y position, and a copy of the d parameter, + so it is suitable for use with putpixel(). Example: +
+      void draw_explosion_ring(BITMAP *bmp, int x, int y, int d)
+      {
+         ...
+      }
+      
+         do_circle(screen, SCREEN_W/2, SCREEN_H/2,
+                   SCREEN_H/16, flame_color,
+                   draw_explosion_ring);
+ + +
See also: +do_ellipse, +do_arc, +do_line, +circle, +circlefill.
+
void circle(BITMAP *bmp, int x, int y, int radius, int color);

+ Draws a circle with the specified centre and radius. + + +
See also: +ellipse, +arc, +circlefill, +do_circle, +drawing_mode, +makecol.
+ +
Examples using this: +ex12bit, +exblend, +excustom, +exjoy, +exmem, +exmouse, +exquat, +exsprite.
+
void circlefill(BITMAP *bmp, int x, int y, int radius, int color);

+ Draws a filled circle with the specified centre and radius. + + +
See also: +ellipsefill, +circle, +do_circle, +drawing_mode, +makecol.
+ +
Examples using this: +excolmap, +excustom, +exdbuf, +exflip, +exlights, +expal, +exspline, +extrans.
+
void do_ellipse(BITMAP *bmp, int x, int y, int rx, ry, int d, + void (*proc)(BITMAP *bmp, int x, int y, int d));

+ Calculates all the points in an ellipse around point (x, y) with radius + rx and ry, calling the supplied function for each one. This will be + passed a copy of the bmp parameter, the x and y position, and a copy of + the d parameter, so it is suitable for use with putpixel(). Example: +
+      void draw_explosion_ring(BITMAP *bmp, int x, int y, int d)
+      {
+         ...
+      }
+      
+         do_ellipse(screen, SCREEN_W/2, SCREEN_H/2,
+                   SCREEN_H/16, SCREEN_H/32, flame_color,
+                   draw_explosion_ring);
+ + +
See also: +do_circle, +do_arc, +do_line, +ellipse, +ellipsefill.
+
void ellipse(BITMAP *bmp, int x, int y, int rx, int ry, int color);

+ Draws an ellipse with the specified centre and radius. + + +
See also: +circle, +arc, +ellipsefill, +do_ellipse, +drawing_mode, +makecol.
+
void ellipsefill(BITMAP *bmp, int x, int y, int rx, int ry, int color);

+ Draws a filled ellipse with the specified centre and radius. + + +
See also: +circlefill, +ellipse, +do_ellipse, +drawing_mode, +makecol.
+ +
Examples using this: +ex12bit.
+
void do_arc(BITMAP *bmp, int x, int y, fixed a1, fixed a2, int r, int d, + void (*proc)(BITMAP *bmp, int x, int y, int d));

+ Calculates all the points in a circular arc around point (x, y) with + radius r, calling the supplied function for each one. This will be passed + a copy of the bmp parameter, the x and y position, and a copy of the d + parameter, so it is suitable for use with putpixel(). The arc will be + plotted in an anticlockwise direction starting from the angle a1 and + ending when it reaches a2. These values are specified in 16.16 fixed + point format, with 256 equal to a full circle, 64 a right angle, etc. + Zero is to the right of the centre point, and larger values rotate + anticlockwise from there. Example: +
+      void draw_explosion_ring(BITMAP *bmp, int x, int y, int d)
+      {
+         ...
+      }
+         do_arc(screen, SCREEN_W/2, SCREEN_H/2,
+             itofix(-21), itofix(43), 50, flame_color,
+             draw_explosion_ring);
+ + +
See also: +do_circle, +do_ellipse, +do_line, +arc.
+
void arc(BITMAP *bmp, int x, y, fixed ang1, ang2, int r, int color);

+ Draws a circular arc with centre x, y and radius r, in an anticlockwise + direction starting from the angle a1 and ending when it reaches a2. These + values are specified in 16.16 fixed point format, with 256 equal to a + full circle, 64 a right angle, etc. Zero is to the right of the centre + point, and larger values rotate anticlockwise from there. Example: +
+      /* Draw a black arc from 4 to 1 o'clock. */
+      arc(screen, SCREEN_W/2, SCREEN_H/2,
+          itofix(-21), itofix(43), 50, makecol(0, 0, 0));
+ + +
See also: +circle, +ellipse, +drawing_mode, +makecol.
+
void calc_spline(const int points[8], int npts, int *x, int *y);

+ Calculates a series of npts values along a bezier spline, storing them in + the output x and y arrays. The bezier curve is specified by the four x/y + control points in the points array: points[0] and points[1] contain the + coordinates of the first control point, points[2] and points[3] are the + second point, etc. Control points 0 and 3 are the ends of the spline, and + points 1 and 2 are guides. The curve probably won't pass through points 1 + and 2, but they affect the shape of the curve between points 0 and 3 (the + lines p0-p1 and p2-p3 are tangents to the spline). The easiest way to + think of it is that the curve starts at p0, heading in the direction of + p1, but curves round so that it arrives at p3 from the direction of p2. + In addition to their role as graphics primitives, spline curves can be + useful for constructing smooth paths around a series of control points, + as in exspline.c. + + +
See also: +spline.
+ +
Examples using this: +exspline.
+
void spline(BITMAP *bmp, const int points[8], int color);

+ Draws a bezier spline using the four control points specified in the + points array. Read the description of calc_spline() for information on + how to build the points array. + + +
See also: +calc_spline, +drawing_mode, +makecol.
+ +
Examples using this: +exspline.
+
void floodfill(BITMAP *bmp, int x, int y, int color);

+ Floodfills an enclosed area, starting at point (x, y), with the specified + color. + + + + +
See also: +drawing_mode, +makecol.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg014.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg014.html new file mode 100644 index 0000000..3f56292 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg014.html @@ -0,0 +1,620 @@ + + +Allegro Manual: Blitting and sprites + + + + +

Blitting and sprites

+ + + +

+As far as Allegro is concerned, a bitmap and a sprite are the same thing, +but to many people the two words imply slightly different things. The +function draw_sprite() is called so rather than draw_bitmap() partly because +it indicates that it uses a masked drawing mode (if it existed, you could +expect draw_bitmap() to be a simple block copy), and partly for historical +reasons. In Allegro 1.0 there were actually different structures for sprites +and bitmaps, each with their own set of abilities. Allegro 2.0 merged these +into a single more flexible structure, but retained some names like +draw_sprite(). + +

+In wider (non-Allegro) terms, the two words can mean quite different things. +Generally you can say that sprites are a subset of bitmaps, but even that +isn't true in 100% of cases. + +

+BITMAP: a widely accepted term that will be understood by anyone even +remotely connected with computer graphics. It simply means an image built up +from a grid of pixels, ie. just about any picture that you are likely to come +across on a computer (vector graphics formats are the exception, but those +must be rendered into a bitmap format before they can be displayed by most +hardware). A more accurate term but slightly rarer term with the same meaning +is "pixmap" (pixel-map). + +

+SPRITE: a particular usage of bitmapped images, restricted to video games +(other types of programmer probably won't be familiar with this term). +Originally on machines like the C64, sprites were a hardware feature that +allowed a number of small bitmap images to be loaded into special registers, +and they could then be superimposed over the main graphics display and moved +around just by modifying the position register. They were used for the moving +objects (player and enemy characters), and enabled the C64 to do much more +impressive things than would have been possible if all the drawing had to be +done directly by the puny CPU. + +

+Later on, a lot of old C64 programmers upgraded to machines like the Atari +ST, which didn't have any special sprite hardware, but they carried on +referring to their main moving objects as sprites (the routine to draw such a +thing would obviously be called draw_sprite()). A sprite is really just a +bitmap graphic which is drawn onto the screen, but when you call it a sprite +rather than a bitmap, this suggests it is a gameplay element that can move +freely around the world rather than being a static part of the environment, +and that it will be drawn in a masked overlay mode rather than as a solid +rectangle (there is also a strong implication that a sprite will be animated +by cycling through a number of frames, but that isn't always the case). + +

+In recent years some people have started using "sprite" to refer to any +character graphics, even if they are not in fact drawn as 2d bitmaps, eg. +"this game uses 3d polygonal player sprites". This is a confusing misuse of +the word (Doom uses sprites, Quake does not), but it does happen. + +

+The origin of the term "blit" is also rather interesting. This was originally +BitBlt, an abbreviation of BITmap BLock Transfer, which was a function +designed (possibly) by the people at Xerox who did so much of the pioneering +work on graphics display systems, and subsequently copied by virtually +everybody doing computer graphics (the Microsoft Windows GDI still provides a +BitBlt function with identical functionality to the original). This routine +was a workhorse for all sorts of drawing operations, basically copying bitmap +graphics from one place to another, but including a number of different ROP +modes (Raster OPerations) for doing things like XOR, inverting pixels, etc. +A whole family of related words grew up around the BitBlt function, but "blt" +is impossible to speak (try saying "bltter" or "bltting" :-) so people added +the vowel to make it easier to pronounce. + +

+Thusly, the act of calling the BitBlt function came to be known as "doing a +blit". The obvious next step was to rename the function itself to blit(), +which generally took place at the same time as people decided to simplify the +original, removing the different ROP modes on the grounds that they aren't +needed for games coding and don't work well with anything higher than +monochrome images in any case. This leaves us with a function called blit(), +which is an abbreviation for "block transfer". A strong case could be made +for calling this blot() instead, but somehow that just doesn't sound the +same! + +

+Anyway, all the routines in this chapter are affected by the +clipping rectangle of the destination bitmap. + +


+

void blit(BITMAP *source, BITMAP *dest, int source_x, int source_y, + int dest_x, int dest_y, int width, int height);

+ Copies a rectangular area of the source bitmap to the destination bitmap. + The source_x and source_y parameters are the top left corner of the area + to copy from the source bitmap, and dest_x and dest_y are the + corresponding position in the destination bitmap. This routine respects + the destination clipping rectangle, and it will also clip if you try to + blit from areas outside the source bitmap. Example: +
+      BITMAP *bmp;
+      ...
+      /* Blit src on the screen. */
+      blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
+      
+      /* Now copy a chunk to a corner, slightly outside. /*
+      blit(screen, screen, 100, 100, -10, -10, 25, 30);
+
+ You can blit between any parts of any two bitmaps, even if the two memory + areas overlap (ie. source and dest are the same, or one is sub-bitmap of + the other). You should be aware, however, that a lot of SVGA cards don't + provide separate read and write banks, which means that blitting from one + part of the screen to another requires the use of a temporary bitmap in + memory, and is therefore extremely slow. As a general rule you should + avoid blitting from the screen onto itself in SVGA modes. + +

+ In mode-X, on the other hand, blitting from one part of the screen to + another can be significantly faster than blitting from memory onto the + screen, as long as the source and destination are correctly aligned with + each other. Copying between overlapping screen rectangles is slow, but if + the areas don't overlap, and if they have the same plane alignment (ie. + (source_x%4) == (dest_x%4)), the VGA latch registers can be used for a + very fast data transfer. To take advantage of this, in mode-X it is often + worth storing tile graphics in a hidden area of video memory (using a + large virtual screen), and blitting them from there onto the visible part + of the screen. + +

+ If the GFX_HW_VRAM_BLIT bit in the gfx_capabilities flag is set, the + current driver supports hardware accelerated blits from one part of the + screen onto another. This is extremely fast, so when this flag is set it + may be worth storing some of your more frequently used graphics in an + offscreen portion of the video memory. + +

+ Unlike most of the graphics routines, blit() allows the source and + destination bitmaps to be of different color depths, so it can be + used to convert images from one pixel format to another. In this + case, the behavior is affected by the COLORCONV_KEEP_TRANS and + COLORCONV_DITHER* flags of the current color conversion mode: see + set_color_conversion() for more information. + + +

See also: +masked_blit, +stretch_blit, +draw_sprite, +gfx_capabilities, +set_color_conversion.
+ +
Examples using this: +Available Allegro examples.
+
void stretch_blit(BITMAP *source, BITMAP *dest, + int source_x, source_y, source_width, source_height, + int dest_x, dest_y, dest_width, dest_height);

+ Like blit(), except it can scale images (so the source and destination + rectangles don't need to be the same size) and requires the source and + destination bitmaps to be of the same color depth. This routine doesn't + do as much safety checking as the regular blit(): in particular you must + take care not to copy from areas outside the source bitmap, and you + cannot blit between overlapping regions, ie. you must use different + bitmaps for the source and the destination. Moreover, the source must + be a memory bitmap. Example: +
+      BITMAP *bmp;
+      ...
+      /* Stretch bmp to fill the screen. */
+      stretch_blit(bmp, screen, 0, 0, bmp->w, bmp->h,
+                   0, 0, SCREEN_W, SCREEN_H);
+ + +
See also: +blit, +masked_stretch_blit, +stretch_sprite.
+ +
Examples using this: +exalpha, +exconfig, +exscale, +extrans.
+
void masked_blit(BITMAP *source, BITMAP *dest, int source_x, int source_y, + int dest_x, int dest_y, int width, int height);

+ Like blit(), but skips transparent pixels, which are marked by a zero in + 256-color modes or bright pink for truecolor data (maximum red and blue, + zero green), and requires the source and destination bitmaps to be of + the same color depth. The source and destination regions must not overlap. + Example: +
+      BITMAP *hud_overlay;
+      ...
+      /* Paint hud overlay on the screen. */
+      masked_blit(hud_overlay, screen, 0, 0, 0, 0,
+                  hud_overlay->w, hud_overlay->h);
+ +

+ If the GFX_HW_VRAM_BLIT_MASKED bit in the gfx_capabilities flag is set, + the current driver supports hardware accelerated masked blits from one + part of the screen onto another. This is extremely fast, so when this + flag is set it may be worth storing some of your more frequently used + sprites in an offscreen portion of the video memory. + +

+ Warning: if the hardware acceleration flag is not set, masked_blit() will + not work correctly when used with a source image in system or video + memory so the latter must be a memory bitmap. + + +

See also: +blit, +masked_stretch_blit, +draw_sprite, +bitmap_mask_color.
+ +
Examples using this: +ex12bit, +expat.
+
void masked_stretch_blit(BITMAP *source, BITMAP *dest, + int source_x, source_y, source_w, source_h, + int dest_x, dest_y, dest_w, dest_h);

+ Like masked_blit(), except it can scale images (so the source and + destination rectangles don't need to be the same size). This routine + doesn't do as much safety checking as the regular masked_blit(): in + particular you must take care not to copy from areas outside the source + bitmap. Moreover, the source must be a memory bitmap. Example: +
+      BITMAP *hud_overlay;
+      ...
+      /* Stretch hud overlay over the screen. */
+      masked_stretch_blit(hud_overlay, screen, 0, 0,
+                          hud_overlay->w, hud_overlay->h,
+                          0, 0, SCREEN_W, SCREEN_H);
+ + +
See also: +blit, +masked_blit, +stretch_blit, +stretch_sprite.
+
void draw_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y);

+ Draws a copy of the sprite bitmap onto the destination bitmap at the + specified position. This is almost the same as blit(sprite, bmp, 0, 0, x, + y, sprite->w, sprite->h), but it uses a masked drawing mode where + transparent pixels are skipped, so the background image will show through + the masked parts of the sprite. Transparent pixels are marked by a zero + in 256-color modes or bright pink for truecolor data (maximum red and + blue, zero green). Example: +
+      BITMAP *spaceship;
+      ...
+      draw_sprite(screen, spaceship, x, y);
+ +

+ If the GFX_HW_VRAM_BLIT_MASKED bit in the gfx_capabilities flag is set, + the current driver supports hardware accelerated sprite drawing when the + source image is a video memory bitmap or a sub-bitmap of the screen. This + is extremely fast, so when this flag is set it may be worth storing some + of your more frequently used sprites in an offscreen portion of the video + memory. + +

+ Warning: if the hardware acceleration flag is not set, draw_sprite() will + not work correctly when used with a sprite image in system or video + memory so the latter must be a memory bitmap. + +

+ Although generally not supporting graphics of mixed color depths, as a + special case this function can be used to draw 256-color source images + onto truecolor destination bitmaps, so you can use palette effects on + specific sprites within a truecolor program. + + +

See also: +draw_sprite_v_flip, +draw_trans_sprite, +draw_lit_sprite, +draw_gouraud_sprite, +stretch_sprite, +rotate_sprite, +draw_character_ex, +draw_rle_sprite, +draw_compiled_sprite, +masked_blit, +blit, +bitmap_mask_color.
+ +
Examples using this: +exsprite.
+
void stretch_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int w, int h);

+ Like draw_sprite(), except it can stretch the sprite image to the + specified width and height and requires the sprite image and destination + bitmap to be of the same color depth. Moreover, the sprite image must + be a memory bitmap. Example: +
+      /* Create tunnel like effect. */
+      for (step = 1; step < 16; step++) {
+         int width = SCREEN_W / step;
+         int height = SCREEN_H / step;
+         stretch_sprite(screen, image, SCREEN_W / 2 - width / 2,
+                        SCREEN_H / 2 - height / 2, width, height);
+      }
+ + +
See also: +draw_sprite, +stretch_blit, +bitmap_mask_color.
+
void draw_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);

+
void draw_sprite_h_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);

+
void draw_sprite_vh_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);

+ These are like draw_sprite(), but they additionally flip the image + vertically, horizontally, or both, respectively. Flipping vertically + means that the y-axis is reversed, while flipping horizontally means + that the x-axis is reversed, between the source and the destination. + This produces exact mirror images, which is not the same as rotating the + sprite (and it is a lot faster than the rotation routine). The sprite + must be a memory bitmap. Example: +
+      if (key[KEY_RIGHT])
+         draw_sprite(screen, hero_right, pos_x, pos_y);
+      else if (key[KEY_LEFT])
+         draw_h_sprite(screen, hero_right, pos_x, pos_y);
+      else
+         draw_sprite(screen, hero_idle, pos_x, pos_y);
+ + +
See also: +draw_sprite, +bitmap_mask_color.
+ +
Examples using this: +exsprite.
+
void draw_trans_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y);

+ Uses the global color_map table or truecolor blender functions to overlay + the sprite on top of the existing image. This must only be used after you + have set up the color mapping table (for 256-color modes) or blender + functions (for truecolor modes). Because it involves reading as well as + writing the bitmap memory, translucent drawing is very slow if you draw + directly to video RAM, so wherever possible you should use a memory + bitmap instead. Example: +
+      /* Some one time initialisation code. */
+      COLOR_MAP global_trans_table;
+      create_trans_table(&global_trans_table, my_palette,
+                         128, 128, 128, NULL);
+      ...
+      if (get_color_depth() == 8)
+         color_map = &global_trans_table;
+      else
+         set_trans_blender(128, 128, 128, 128);
+
+      draw_trans_sprite(buffer, ghost_sprite, x, y);
+ +

+ The bitmap and sprite must normally be in the same color depth, but as a + special case you can draw 32 bit RGBA format sprites onto any hicolor or + truecolor bitmap, as long as you call set_alpha_blender() first, and you + can draw 8-bit alpha images onto a 32-bit RGBA destination, as long as you + call set_write_alpha_blender() first. As draw_sprite() this function skips + transparent pixels, except if the source sprite is an 8-bit image; if this + is the case, you should pay attention to properly set up your color map + table for index 0. + + +

See also: +draw_sprite, +draw_lit_sprite, +draw_trans_rle_sprite, +color_map, +set_trans_blender, +set_alpha_blender, +set_write_alpha_blender, +bitmap_mask_color.
+ +
Examples using this: +exalpha, +exblend, +exlights, +extrans, +exxfade.
+
void draw_lit_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int color);

+ In 256-color modes, uses the global color_map table to tint the sprite + image to the specified color or to light it to the level specified by + 'color', depending on the function which was used to build the table + (create_trans_table or create_light_table), and draws the resulting image + to the destination bitmap. In truecolor modes, uses the blender functions + to light the sprite image using the alpha level specified by 'color' (the + alpha level which was passed to the blender functions is ignored) and + draws the resulting image to the destination bitmap. The 'color' parameter + must be in the range [0-255] whatever its actual meaning is. This must + only be used after you have set up the color mapping table (for 256-color + modes) or blender functions (for truecolor modes). Example: +
+      /* Some one time initialisation code. */
+      COLOR_MAP global_light_table;
+      create_light_table(&global_trans_table, my_palette,
+                         10, 10, 60, NULL);
+      ...
+      if (get_color_depth() == 8)
+         color_map = &global_light_table;
+      else
+         set_trans_blender(40, 40, 255, 255);
+
+      /* Lit the cape with a blueish light. */
+      draw_lit_sprite(buffer, colored_cape, x, y);
+ + +
See also: +draw_sprite, +draw_trans_sprite, +draw_gouraud_sprite, +draw_lit_rle_sprite, +color_map, +set_trans_blender, +bitmap_mask_color.
+ +
Examples using this: +exblend.
+
void draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, + int c1, int c2, int c3, int c4);

+ More sophisticated version of draw_lit_sprite(): the 'color' parameter is + not constant across the sprite image anymore but interpolated between the + four specified corner colors. The corner values passed to this function + indicate the strength of the color applied on them, ranging from 0 (no + strength) to 255 (full strength). Example: +
+      /* Some one time initialisation code. */
+      COLOR_MAP global_light_table;
+      create_light_table(&global_trans_table, my_palette,
+                         0, 0, 0, NULL);
+      ...
+      if (get_color_depth() == 8)
+         color_map = &global_light_table;
+      else
+         set_trans_blender(0, 0, 0, 128);
+
+      /* Enemies are in shadow unless lit by torch. */
+      draw_gouraud_sprite(buffer, menacing_spy, x, y,
+                          light_strength_on_corner_1,
+                          light_strength_on_corner_2,
+                          light_strength_on_corner_3,
+                          light_strength_on_corner_4);
+ + +
See also: +draw_sprite, +draw_lit_sprite, +color_map, +set_trans_blender, +bitmap_mask_color.
+ +
Examples using this: +exshade.
+
void draw_character_ex(BITMAP *bmp, BITMAP *sprite, int x, int y, + color, bg);

+ Draws a copy of the sprite bitmap onto the destination bitmap at the + specified position, drawing transparent pixels in the background color + (or skipping them if the background color is -1) and setting all other + pixels to the specified color. Transparent pixels are marked by a zero + in 256-color modes or bright pink for truecolor data (maximum red and + blue, zero green). The sprite must be an 8-bit image, even if the + destination is a truecolor bitmap. Example: +
+      BITMAP *logo;
+      ...
+      /* Draw the logo silhouette in red. */
+      draw_character_ex(screen, logo, SCREEN_W / 2, SCREEN_H / 2,
+                        makecol(255, 0, 0), -1);
+ + +
See also: +draw_sprite, +bitmap_mask_color.
+
void rotate_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle);

+ Draws the sprite image onto the bitmap. It is placed with its top left + corner at the specified position, then rotated by the specified angle + around its centre. The angle is a fixed point 16.16 number in the same + format used by the fixed point trig routines, with 256 equal to a full + circle, 64 a right angle, etc. All rotation functions can draw between any + two bitmaps, even screen bitmaps or bitmaps of different color depth. + +

+ Positive increments of the angle will make the sprite rotate clockwise + on the screen, as demonstrated by the Allegro example. + + +

See also: +draw_sprite, +rotate_scaled_sprite, +rotate_sprite_v_flip, +rotate_scaled_sprite_v_flip, +pivot_sprite, +pivot_sprite_v_flip, +pivot_scaled_sprite, +pivot_scaled_sprite_v_flip, +itofix, +Fixed point trig.
+ +
Examples using this: +exsprite.
+
void rotate_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle);

+ Like rotate_sprite, but flips the image vertically before rotating it. To + flip horizontally, use this routine but add itofix(128) to the angle. To + flip in both directions, use rotate_sprite() and add itofix(128) to its + angle. + + +
See also: +rotate_sprite, +rotate_scaled_sprite_v_flip, +pivot_sprite_v_flip, +pivot_scaled_sprite_v_flip.
+ +
Examples using this: +exsprite.
+
void rotate_scaled_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, + fixed angle, fixed scale);

+ Like rotate_sprite(), but stretches or shrinks the image at the same time + as rotating it. + + +
See also: +rotate_sprite, +rotate_scaled_sprite_v_flip, +pivot_scaled_sprite, +pivot_scaled_sprite_v_flip.
+
void rotate_scaled_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y, + fixed angle, fixed scale);

+ Draws the sprite, similar to rotate_scaled_sprite() except that it flips + the sprite vertically first. + + +
See also: +rotate_sprite, +rotate_scaled_sprite, +rotate_sprite_v_flip.
+
void pivot_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, + int cx, int cy, fixed angle);

+ Like rotate_sprite(), but aligns the point in the sprite given by (cx, cy) + to (x, y) in the bitmap, then rotates around this point. + + +
See also: +rotate_sprite, +pivot_scaled_sprite, +pivot_sprite_v_flip.
+ +
Examples using this: +exsprite.
+
void pivot_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y, + int cx, int cy, fixed angle);

+ Like rotate_sprite_v_flip(), but aligns the point in the sprite given by + (cx, cy) to (x, y) in the bitmap, then rotates around this point. + + +
See also: +rotate_sprite, +rotate_sprite_v_flip, +pivot_sprite.
+ +
Examples using this: +exsprite.
+
void pivot_scaled_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, + int cx, int cy, fixed angle, fixed scale);

+ Like rotate_scaled_sprite(), but aligns the point in the sprite given by + (cx, cy) to (x, y) in the bitmap, then rotates and scales around this + point. + + +
See also: +rotate_sprite, +rotate_scaled_sprite, +pivot_sprite, +pivot_scaled_sprite_v_flip.
+
void pivot_scaled_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y, + int cx, int cy, fixed angle, fixed scale);

+ Like rotate_scaled_sprite_v_flip(), but aligns the point in the sprite + given by (cx, cy) to (x, y) in the bitmap, then rotates and scales around + this point. + + + + +
See also: +rotate_sprite, +rotate_scaled_sprite_v_flip, +rotate_sprite_v_flip, +pivot_sprite, +pivot_scaled_sprite.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg015.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg015.html new file mode 100644 index 0000000..e4ee4fd --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg015.html @@ -0,0 +1,167 @@ + + +Allegro Manual: RLE sprites + + + + +

RLE sprites

+ + + +

+Because bitmaps can be used in so many different ways, the bitmap structure +is quite complicated, and it contains a lot of data. In many situations, +though, you will find yourself storing images that are only ever copied to +the screen, rather than being drawn onto or used as filling patterns, etc. +If this is the case you may be better off storing your images in RLE_SPRITE +(read chapter "Structures and types defined by Allegro" for an internal +description of the RLE_SPRITE structure) or COMPILED_SPRITE (see next +chapter) structures rather than regular bitmaps. + +

+RLE sprites store the image in a simple run-length encoded format, where +repeated zero pixels are replaced by a single length count, and strings of +non-zero pixels are preceded by a counter giving the length of the solid +run. RLE sprites are usually much smaller than normal bitmaps, both because +of the run length compression, and because they avoid most of the overhead +of the bitmap structure. They are often also faster than normal bitmaps, +because rather than having to compare every single pixel with zero to +determine whether it should be drawn, it is possible to skip over a whole +run of zeros with a single add, or to copy a long run of non-zero pixels +with fast string instructions. + +

+Every silver lining has a cloud, though, and in the case of RLE sprites it +is a lack of flexibility. You can't draw onto them, and you can't flip them, +rotate them, or stretch them. In fact the only thing you can do with them is +to blast them onto a bitmap with the draw_rle_sprite() function, which is +equivalent to using draw_sprite() with a regular bitmap. You can convert +bitmaps into RLE sprites at runtime, or you can create RLE sprite structures +in grabber datafiles by making a new object of type 'RLE sprite'. + +


+

RLE_SPRITE *get_rle_sprite(BITMAP *bitmap);

+ Creates an RLE sprite based on the specified bitmap (which must be a + memory bitmap). Remember to free this RLE sprite later to avoid memory + leaks. Example: +
+      RLE_SPRITE *rle;
+      BITMAP *bmp;
+      ...
+      /* Create RLE sprite from an existent bitmap. */
+      rle = get_rle_sprite(bmp);
+      if (!rle)
+         abort_on_error("Couldn't create RLE sprite!");
+         
+      /* We don't need the bitmap any more.*/
+      destroy_bitmap(bmp);
+      
+      /* Use the RLE sprite. */
+      ...
+      /* Destroy it when we don't need it any more. */
+      destroy_rle_sprite(rle);
+

Return value: + Returns a pointer to the created RLE sprite, or NULL if the RLE sprite + could not be created. Remember to free this RLE sprite later to avoid + memory leaks. + + +

See also: +draw_rle_sprite, +destroy_rle_sprite.
+
void destroy_rle_sprite(RLE_SPRITE *sprite);

+ Destroys an RLE sprite structure previously returned by get_rle_sprite(). + If you pass a NULL pointer this function won't do anything. Use this once + you are done with an RLE sprite to avoid memory leaks in your program. + + +
See also: +get_rle_sprite.
+
void draw_rle_sprite(BITMAP *bmp, const RLE_SPRITE *sprite, + int x, int y);

+ Draws an RLE sprite onto a bitmap at the specified position. Example: +
+      RLE_SPRITE *rle_sprite;
+      ...
+      draw_rle_sprite(screen, rle_sprite, 100, 100);
+ + +
See also: +get_rle_sprite, +draw_sprite, +draw_compiled_sprite, +draw_trans_rle_sprite, +draw_lit_rle_sprite, +bitmap_mask_color.
+
void draw_trans_rle_sprite(BITMAP *bmp, const RLE_SPRITE *sprite, + int x, int y);

+ Translucent version of draw_rle_sprite(). See the description of + draw_trans_sprite(). This must only be used after you have set up the + color mapping table (for 256-color modes) or blender functions (for + truecolor modes). The bitmap and sprite must normally be in the same + color depth, but as a special case you can draw 32-bit RGBA format + sprites onto any hicolor or truecolor bitmap, as long as you call + set_alpha_blender() first. Example: +
+      /* Some one time initialisation code. */
+      COLOR_MAP global_trans_table;
+      create_trans_table(&global_trans_table, my_palette,
+                         128, 128, 128, NULL);
+      ...
+      if (get_color_depth() == 8)
+         color_map = &global_trans_table;
+      else
+         set_trans_blender(128, 128, 128, 128);
+
+      draw_trans_rle_sprite(buffer, rle_ghost_sprite, x, y);
+ + +
See also: +draw_rle_sprite, +draw_lit_rle_sprite, +draw_trans_sprite, +color_map, +set_trans_blender, +set_alpha_blender, +bitmap_mask_color.
+
void draw_lit_rle_sprite(BITMAP *bmp, const RLE_SPRITE *sprite, + int x, y, color);

+ Tinted version of draw_rle_sprite(). See the description of + draw_lit_sprite(). This must only be used after you have set up the color + mapping table (for 256-color modes) or blender functions (for truecolor + modes). Example: +
+      /* Some one time initialisation code. */
+      COLOR_MAP global_light_table;
+      create_light_table(&global_trans_table, my_palette,
+                         10, 10, 60, NULL);
+      ...
+      if (get_color_depth() == 8)
+         color_map = &global_light_table;
+      else
+         set_trans_blender(40, 40, 255, 255);
+
+      /* Lit the cape with a blueish light. */
+      draw_lit_rle_sprite(buffer, rle_colored_cape, x, y);
+ + + + +
See also: +draw_rle_sprite, +draw_trans_rle_sprite, +draw_lit_sprite, +color_map, +set_trans_blender, +bitmap_mask_color.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg016.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg016.html new file mode 100644 index 0000000..992e26e --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg016.html @@ -0,0 +1,99 @@ + + +Allegro Manual: Compiled sprites + + + + +

Compiled sprites

+ + + +

+Compiled sprites are stored as actual machine code instructions that draw a +specific image onto a bitmap, using mov instructions with immediate data +values. This is the fastest way to draw a masked image: on slow machines, +up to and including a 486, drawing compiled sprites can be about to five +times as fast as using draw_sprite() with a regular bitmap. On newer +machines the difference is usually negligible. + +

+Compiled sprites are big, so if memory is tight you should use RLE sprites +instead, and what you can do with them is even more restricted than with RLE +sprites, because they don't support clipping. If you try to draw one off the +edge of a bitmap, you will corrupt memory and probably crash the system. You +can convert bitmaps into compiled sprites at runtime, or you can create +compiled sprite structures in grabber datafiles by making a new object of +type 'Compiled sprite' or 'Compiled x-sprite'. + +


+

COMPILED_SPRITE *get_compiled_sprite(BITMAP *bitmap, int planar);

+ Creates a compiled sprite based on the specified bitmap (which must be a + memory bitmap). Compiled sprites are device-dependent, so you have to + specify whether to compile it into a linear or planar format. Pass FALSE + as the second parameter if you are going to be drawing it onto memory + bitmaps or mode 13h and SVGA screen bitmaps, and pass TRUE if you are + going to draw it onto mode-X or Xtended mode screen bitmaps. Example: +
+      COMPILED_SPRITE *cspr;
+      BITMAP *bmp;
+      ...
+      /* Create compiled sprite from an existent bitmap. */
+      cspr = get_compiled_sprite(bmp, 0);
+      if (!cspr)
+         abort_on_error("Couldn't create compiled sprite!");
+      
+      /* We don't need the bitmap any more.*/
+      destroy_bitmap(bmp);
+      
+      /* Use the compiled sprite. */
+      ...
+      /* Destroy it when we don't need it any more. */
+      destroy_compiled_sprite(cspr);
+
+ Returns a pointer to the created compiled sprite, or NULL if the compiled + sprite could not be created. Remember to free this compiled sprite later + to avoid memory leaks. + + +
See also: +draw_compiled_sprite, +destroy_compiled_sprite.
+
void destroy_compiled_sprite(COMPILED_SPRITE *sprite);

+ Destroys a compiled sprite structure previously returned by + get_compiled_sprite(). If you pass a NULL pointer this function won't do + anything. Use this once you are done with a compiled sprite to avoid + memory leaks in your program. + + +
See also: +get_compiled_sprite.
+
void draw_compiled_sprite(BITMAP *bmp, const COMPILED_SPRITE *sprite, + int x, int y);

+ Draws a compiled sprite onto a bitmap at the specified position. The + sprite must have been compiled for the correct type of bitmap (linear or + planar). This function does not support clipping. + +

+ Hint: if not being able to clip compiled sprites is a problem, a neat + trick is to set up a work surface (memory bitmap, mode-X virtual screen, + or whatever) a bit bigger than you really need, and use the middle of it + as your screen. That way you can draw slightly off the edge without any + trouble... + + + + +

See also: +get_compiled_sprite, +draw_sprite, +draw_rle_sprite, +bitmap_mask_color.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg017.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg017.html new file mode 100644 index 0000000..148ce11 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg017.html @@ -0,0 +1,535 @@ + + +Allegro Manual: Fonts + + + + +

Fonts

+ + + +

+Allegro provides routines for loading fonts directly from GRX format .fnt +files, 8x8 or 8x16 BIOS format .fnt files, from bitmap images, from datafiles +or you can import a multiple-range Unicode font by writing a .txt script that +specifies a number of different source files for each range of characters. + +

+By default, Allegro can only use bitmapped (non-scalable) fonts. If you want +to use TrueType fonts, you will need to use an add-on library which allows +you to load them on the fly (like AllegTTF or Glyph Keeper, listed among +others at http://www.allegro.cc/) and render them directly, or generate a +bitmapped version of a TrueType font with tools like TTF2PCX +(http://www.talula.demon.co.uk/ttf2pcx/index.html). + +


+

void register_font_file_type(const char *ext, + FONT *(*load)(const char *filename, RGB *pal, void *param));

+ Informs the load_font() functions of a new file type, providing a routine + to read fonts in this format. The function you supply must follow the + following prototype: +
+      FONT *load_my_font(const char *filename, RGB *pal, void *param)
+      {
+         ...
+      }
+
+ The pal parameter can optionally be used to return a palette for the FONT. + The parameter param can be anything you like: you can use this to pass + information to your loading routine, such as for instance the font height, + the character range to load or the index number of a font in a datafile. + If you choose to write your own font loading code, your function should be + prepared to deal with a value of NULL for either of these parameters. + + +
See also: +load_font.
+
FONT *load_font(const char *filename, RGB *pal, void *param);

+ Loads a font from a file. At present, this supports loading fonts from + a GRX format .fnt file, a 8x8 or 8x16 BIOS format .fnt file, a datafile or + any bitmap format that can be loaded by load_bitmap(). + +

+ If the font contains palette information, then the palette is returned in + the second parameter, which should be an array of 256 RGB structures + (a PALETTE). The pal argument may be NULL. In this case, the palette data, + if present, is simply not returned. + +

+ The third parameter can be used to pass specific information to a custom + loader routine. Normally, you can just leave this as NULL. Note that + another way of loading fonts is embedding them into a datafile and using + the datafile related functions. + +

+ Example: +

+      FONT *myfont;
+      PALETTE palette;
+      ...
+      myfont = load_font("my_font.pcx", palette, NULL);
+      if (!myfont)
+         abort_on_error("Couldn't load font!");
+      ...
+      textout_centre_ex(screen, myfont, "This is my own pretty font!",
+                        SCREEN_W / 2, SCREEN_H / 2, white, black);
+      ...
+      destroy_font(bmp);
+

Return value: + Returns a pointer to the font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +register_font_file_type, +load_bitmap, +load_dat_font, +load_bios_font, +load_grx_font, +load_grx_or_bios_font, +load_bitmap_font, +load_txt_font, +destroy_font.
+ +
Examples using this: +exfont.
+
void destroy_font(FONT *f);

+ Frees the memory being used by a font structure. Don't use this on the + default global Allegro font or any text routines using it could crash. You + should use this only on fonts you have loaded manually after you are done + with them, to prevent memory leaks in your program. + + +
See also: +load_datafile_object, +load_font.
+ +
Examples using this: +exfont.
+
void make_trans_font(FONT *f);

+ This function converts a font to use transparency for drawing. That is, each + glyph in the font will be drawn with draw_trans_sprite, so you can use the + same blenders as with draw_trans_sprite to draw the font. One common use of + this is to load a bitmap font with an alpha channel, and therefore get + anti-aliased text output by using Allegro's alpha blender. Here's an example + how to do that: + +
+   FONT *f = load_font("alphafont.tga", NULL, NULL);
+   make_trans_font(f);
+   set_alpha_blender();
+   textprintf_centre_ex(screen, f, 320, 240, -1, -1, "Anti-aliased Font!");
+ + +
See also: +set_alpha_blender, +load_font, +draw_trans_sprite.
+
int is_color_font(FONT *f)

+ This function checks if the given font is a color font, as opposed to a + monochrome font. +

Return value: + Returns TRUE if the font is a color font, FALSE if it is not. + + +

See also: +is_mono_font.
+
int is_mono_font(FONT *f)

+ This function checks if the given font is a mono font, as opposed to a + color font. +

Return value: + Returns TRUE if the font is a monochrome font, FALSE if it is not. + + +

See also: +is_color_font.
+
FONT *is_compatible_font(FONT *f1, FONT *f2)

+ This function compares the two fonts, which you can use to find out if + Allegro is capable of merging them. +

Return value: + Returns TRUE if the two fonts are of the same general type (both are color + fonts or both are monochrome fonts, for instance). + + +

See also: +merge_fonts, +is_color_font, +is_mono_font.
+
int get_font_ranges(FONT *f)

+ Use this function to find out the number of character ranges in a font. You + should query each of these ranges with get_font_range_begin() and + get_font_range_end() to find out what characters are available in the + font. Example: +
+      FONT *f;
+      int range;
+      int n;
+      ...
+      
+      range = get_font_ranges(f);
+      printf("The font has %d character ranges:\n", range);
+      for (n = 0; n < range; n++)
+         printf("Range %d from 0x%03x - 0x%03x\n",
+                get_font_range_begin(f, n),
+                get_font_range_end(f, n));
+

Return value: + Returns the number of continuous character ranges in a font, or -1 if that + information is not available. + + +

See also: +get_font_range_begin, +get_font_range_end, +transpose_font.
+
int get_font_range_begin(FONT *f, int range)

+ This function allows you to find out the start of a specific character + range for a font. You can pass -1 for the `range' parameter if you want to + know the start of the whole font range, or a number from 0 to (but not + including) get_font_ranges(f) to get the start of a specific character + range in the font. Example: +
+      printf("The font has a character range of %d - %d\n",
+             get_font_range_begin(font, -1),
+             get_font_range_end(font, -1));
+

Return value: + Returns the first character in the font range, or -1 if that information + is not available. + + +

See also: +get_font_ranges, +get_font_range_end, +transpose_font.
+
int get_font_range_end(FONT *f, int range)

+ This function allows you to find out the index to the last character of a + character range for a font. You can pass -1 for the range parameter if you + want to know the start of the whole font range, or a number from 0 to (but + not including) get_font_ranges(f) to get the start of a specific character + range in the font. You should check the start and end of all font ranges to + see if a specific character is actually available in the font. Not all + characters in the range returned by get_font_range_begin(f, -1) and + get_font_range_end(f, -1) need to be available! Example: +
+      printf("The font has a character range of %d - %d\n",
+             get_font_range_begin(font, -1),
+             get_font_range_end(font, -1));
+

Return value: + Returns the last character in the font range, or -1 if that information is + not available. + + +

See also: +get_font_ranges, +get_font_range_begin, +transpose_font.
+
FONT *extract_font_range(FONT *f, int begin, int end)

+ This function extracts a character range from a font and returns a new font + that contains only the range of characters selected by this function. You + can pass -1 for either the lower or upper bound if you want to select all + characters from the start or to the end of the font. + Example: +
+      FONT *myfont;
+      FONT *capitals;
+      FONT *fontcopy;
+      ...
+      /* Create a font of only capital letters */
+      capitals = extract_font_range(myfont, 'A', 'Z');
+
+      /* Create a copy of the font */
+      fontcopy = extract_font_range(myfont, -1, -1);
+      ...
+      destroy_font(capitals);
+      destroy_font(fontcopy);
+

Return value: + Returns a pointer to the new font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +get_font_range_begin, +get_font_range_end, +merge_fonts, +transpose_font.
+ +
Examples using this: +exfont.
+
int transpose_font(FONT *f, int drange)

+ This function transposes all characters in a font, effectively remapping the + font. Example: +
+      FONT *myfont;
+      FONT *capitals;
+      ...
+      /* Create a font of only capital letters */
+      capitals = extract_font_range(myfont, 'A', 'Z');
+
+      /* Now transpose the characters in the font so that they will be used */
+      /*  for the lower case letters a-z */
+      transpose_font(capitals, 'a'-'A');
+      textout_ex(screen, capitals, "allcaps",
+                 100, 100, makecol(255,255,255), 0);
+

Return value: + Returns 0 on success, -1 on failure. + + +

See also: +get_font_range_begin, +get_font_range_end, +merge_fonts, +extract_font_range.
+
FONT *merge_fonts(FONT *f1, FONT *f2)

+ This function merges the character ranges from two fonts and returns a new + font containing all characters in the old fonts. In general, you cannot + merge fonts of different types (eg, TrueType fonts and bitmapped fonts), + but as a special case, this function can promote a monochrome bitmapped + font to a color font and merge those. Example: +
+      FONT *myfont;
+      FONT *myfancy_font;
+      FONT *lower_range;
+      FONT *upper_range;
+      FONT *capitals;
+      FONT *combined_font;
+      FONT *tempfont;
+      ...
+      /* Create a font that contains the capatials from  */
+      /* the fancy font but other characters from myfont */
+      lower_range = extract_font_range(myfont, -1, 'A'-1);
+      upper_range = extract_font_range(myfont, 'Z'+1, -1);
+      capitals = extract_font_range(myfancy_font, 'A', 'Z');
+
+      tempfont = merge_fonts(lower_range, capitals);
+      combined_font = merge_fonts(tempfont, upper_range);
+
+      /* Clean up temporary fonts */
+      destroy_font(lower_range);
+      destroy_font(upper_range);
+      destroy_font(capitals);
+      destroy_font(tempfont);
+

Return value: + Returns a pointer to the new font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +extract_font_range, +is_color_font, +is_mono_font.
+ +
Examples using this: +exfont.
+
FONT *load_dat_font(const char *filename, RGB *pal, void *param)

+ Loads a FONT from an Allegro datafile. You can set param parameter to + point to an array that holds two strings that identify the font and the + palette in the datafile by name. + The first string in this list is the name of the font. You can pass NULL + here to just load the first font found in the datafile. The second string + can be used to specify the name of the palette associated with the font. + This is only returned if the pal parameter is not NULL. If you pass NULL + for the name of the palette, the last palette found before the font was + found is returned. + You can also pass NULL for param, which is treated as if you had passed + NULL for both strings separately. In this case, the function will simply + load the first font it finds from the datafile and the palette that + precedes it. + +

+ For example, suppose you have a datafile named `fonts.dat' with the + following contents: +

+      FONT  FONT_1_DATA
+      FONT  FONT_2_DATA
+      FONT  FONT_3_DATA
+      PAL   FONT_1_PALETTE
+      PAL   FONT_2_PALETTE
+
+ Then the following code will load FONT_1_DATA as a FONT and return + FONT_1_PALETTE as the palette: +
+      FONT *f;
+      PALETTE pal;
+      char *names[] = { "FONT_1_DATA", "FONT_1_PALETTE" }
+      
+      f = load_dat_font("fonts.dat", pal, names);
+
+ If instead you want to load the second font, FONT_2, from the datafile, + you would use: +
+      FONT *f;
+      PALETTE pal;
+      char *names[] = { "FONT_2_DATA", "FONT_2_PALETTE" }
+      
+      f = load_dat_font("fonts.dat", pal, names);
+
+ If you want to load the third font, but not bother with a palette, use: +
+      FONT *f;
+      char *names[] = { "FONT_3_DATA", NULL }
+      
+      f = load_dat_font("fonts.dat", NULL, names);
+

Return value: + Returns a pointer to the font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +register_font_file_type, +load_font.
+
FONT *load_bios_font(const char *filename, RGB *pal, void *param)

+ Loads a 8x8 or 8x16 BIOS format font. You shouldn't normally call this + routine directly. +

Return value: + Returns a pointer to the font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +register_font_file_type, +load_font.
+
FONT *load_grx_font(const char *filename, RGB *pal, void *param)

+ Loads a GRX format font. You shouldn't normally call this routine + directly. +

Return value: + Returns a pointer to the font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +register_font_file_type, +load_font.
+
FONT *load_grx_or_bios_font(const char *filename, RGB *pal, void *param)

+ Loads either a BIOS or GRX format font. You shouldn't normally call this + routine directly. +

Return value: + Returns a pointer to the font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +register_font_file_type, +load_font.
+
FONT *load_bitmap_font(const char *filename, RGB *pal, void *param)

+ Tries to grab a font from a bitmap. The bitmap can be in any format that + load_bitmap understands. + +

+ The size of each character is determined by the layout of the image, which + should be a rectangular grid containing all the ASCII characters from + space (32) up to the tilde (126). The way the characters are separated + depends on the colordepth of the image file: +

+ +

+ Note that in each horizontal row the bounding boxes around the characters + should align and have the same height. + +

+ Probably the easiest way to get to grips with how this works is to load up + the `demo.dat' file and export the TITLE_FONT into a PCX file. Have a look + at the resulting picture in your paint program: that is the format a font + should be in. + +

+ Take care with high and true color fonts: Allegro will convert these to the + current colordepth when you load the font. If you try to use a font on + a bitmap with a different color depth Allegro will do color conversions on + the fly, which will be rather slow. For optimal performance you should + set the colordepth to the colordepth you want to use before loading any + fonts. +

Return value: + Returns a pointer to the font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +register_font_file_type, +load_font, +load_bitmap, +set_color_depth, +grab_font_from_bitmap.
+
FONT *grab_font_from_bitmap(BITMAP *bmp)

+ This function is the work-horse of load_bitmap_font, and can be used to + grab a font from a bitmap in memory. You can use this if you want to + generate or modify a font at runtime. The bitmap should follow the layout + described for load_bitmap_font. +

Return value: + Returns a pointer to the font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + +

See also: +load_bitmap_font.
+
FONT *load_txt_font(const char *filename, RGB *pal, void *param)

+ This function can be used to load scripted fonts. The script file + contains a number of lines in the format "filename start end", which + specify the source file for that range of characters, the Unicode value of + the first character in the range, and the end character in the range + (optional, if left out, the entire input file will be grabbed). If the + filename is replaced by a hyphen, more characters will be grabbed from the + previous input file. + For example, the script: +
+      ascii.fnt 0x20 0x7F
+      - 0xA0 0xFF
+      dingbats.fnt 0x1000
+   
+ would import the first 96 characters from ascii.fnt as the range + 0x20-0x7F, the next 96 characters from ascii.fnt as the range 0xA0-0xFF, + and the entire contents of dingbats.fnt starting at Unicode position + 0x1000. +

Return value: + Returns a pointer to the font or NULL on error. Remember that you are + responsible for destroying the font when you are finished with it to + avoid memory leaks. + + + + +

See also: +register_font_file_type, +load_font.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg018.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg018.html new file mode 100644 index 0000000..3b5d47b --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg018.html @@ -0,0 +1,258 @@ + + +Allegro Manual: Text output + + + + +

Text output

+ + + +

+Allegro provides text output routines that work with both monochrome and +color fonts, which can contain any number of Unicode character ranges. The +grabber program can create fonts from sets of characters drawn in a bitmap +file (see grabber.txt for more information), and can also import GRX or BIOS +format font files. The font structure contains a number of hooks that can be +used to extend it with your own custom drawing code: see the definition in +allegro/text.h for details. + +


+

extern FONT *font;

+ A simple 8x8 fixed size font (the mode 13h BIOS default). If you want to + alter the font used by the GUI routines, change this to point to one of + your own fonts. This font contains the standard ASCII (U+20 to U+7F), + Latin-1 (U+A1 to U+FF), and Latin Extended-A (U+0100 to U+017F) character + ranges. + + +
See also: +textout_ex, +textprintf_ex.
+ +
Examples using this: +Available Allegro examples.
+
extern int allegro_404_char;

+ When Allegro cannot find a glyph it needs in a font, it will instead + output the character given in allegro_404_char. By default, this is set to + the caret symbol, `^', but you can change this global to use any other + character instead. Example: +
+      /* Show unknown glyphs with an asterisk. */
+      allegro_404_char = '*';
+ + +
See also: +font.
+
int text_length(const FONT *f, const char *str);

+ Returns the length (in pixels) of a string in the specified font. Example: +
+      int width = text_length(font, "I love spam");
+      ...
+      bmp = create_bitmap(width, height);
+ + +
See also: +text_height.
+ +
Examples using this: +ex12bit, +exmidi, +expat, +exunicod.
+
int text_height(const FONT *f)

+ Returns the height (in pixels) of the specified font. Example: +
+      int height = text_height(font);
+      ...
+      bmp = create_bitmap(width, height);
+ + +
See also: +text_length.
+ +
Examples using this: +ex12bit, +exmidi, +expackf, +expat, +exsprite, +exsyscur, +exunicod.
+
void textout_ex(BITMAP *bmp, const FONT *f, const char *s, + int x, int y, int color, int bg);

+ Writes the string `s' onto the bitmap at position x, y, using the + specified font, foreground color and background color. If the background + color is -1, then the text is written transparently. If the foreground + color is -1 and a color font is in use, it will be drawn using the colors + from the original font bitmap (the one you imported into the grabber + program), which allows multicolored text output. For high and true color + fonts, the foreground color is ignored and always treated as -1. Example: +
+      /* Show the program's version in blue letters. */
+      textout_ex(screen, font, "v4.2.0-beta2", 10, 10,
+                 makecol(0, 0, 255), -1);
+ + +
See also: +font, +textout_centre_ex, +textout_right_ex, +textout_justify_ex, +textprintf_ex, +text_height, +text_length.
+ +
Examples using this: +Available Allegro examples.
+
void textout_centre_ex(BITMAP *bmp, const FONT *f, const char *s, + int x, y, int color, int bg);

+ Like textout_ex(), but interprets the x coordinate as the centre rather + than the left edge of the string. Example: +
+      /* Important texts go in the middle. */
+      width = text_length("GAME OVER");
+      textout_centre_ex(screen, font, "GAME OVER",
+                        SCREEN_W / 2, SCREEN_H / 2,
+                        makecol(255, 0, 0), makecol(0, 0, 0));
+ + +
See also: +textout_ex, +textprintf_centre_ex.
+ +
Examples using this: +Available Allegro examples.
+
void textout_right_ex(BITMAP *bmp, const FONT *f, const char *s, + int x, int y, int color, int bg);

+ Like textout_ex(), but interprets the x coordinate as the right rather + than the left edge of the string. Example: +
+      textout_right_ex(screen, font, "Look at this color!",
+                       SCREEN_W - 10, 10, my_yellow, -1);
+ + +
See also: +textout_ex, +textprintf_right_ex.
+
void textout_justify_ex(BITMAP *bmp, const FONT *f, const char *s, + int x1, int x2, int y, int diff, int color, + int bg);

+ Draws justified text within the region x1-x2. If the amount of spare + space is greater than the diff value, it will give up and draw regular + left justified text instead. Example: +
+      char *lines[] = {"Draws justified text",
+                       "within the specified",
+                       "x2-x1 area. But not",
+                       "T H I S !", NULL};
+      /* Show the justification marker. */
+      vline(screen, 200, 0, SCREEN_H-1, makecol(0, 0, 0));
+      /* Draw all the lines until we reach a NULL entry. */
+      for (num = 0, y = 0; lines[num]; num++, y += text_height(font))
+         textout_justify_ex(screen, font, lines[num], 0, 200,
+                            y, 80, makecol(0, 0, 0),
+                            makecol(255, 255, 255));
+ + +
See also: +textout_ex, +textprintf_justify_ex.
+
void textprintf_ex(BITMAP *bmp, const FONT *f, int x, int y, + int color, int bg, const char *fmt, ...);

+ Formatted text output, using a printf() style format string. Due to an + internal limitation, this function can't be used for extremely long texts. + If you happen to reach this limit, you can work around it by using + uszprintf() and textout_ex(), which don't have any. Example: +
+      int player_score;
+      ...
+      textprintf_ex(screen, font, 10, 10, makecol(255, 100, 200),
+                    -1, "Score: %d", player_score);
+ + +
See also: +font, +textout_ex, +textprintf_centre_ex, +textprintf_right_ex, +textprintf_justify_ex, +text_height, +text_length, +uszprintf.
+ +
Examples using this: +Available Allegro examples.
+
void textprintf_centre_ex(BITMAP *bmp, const FONT *f, int x, int y, + int color, int bg, const char *fmt, ...);

+ Like textprintf_ex(), but interprets the x coordinate as the centre rather + than the left edge of the string. This function shares the text length + limitation of textprintf_ex(). Example: +
+      textprintf_centre_ex(screen, font, SCREEN_W / 2, 120,
+                           makecol(0, 100, 243), -1,
+                           "Your best score so far was %d!",
+                           total_max_points);
+ + +
See also: +textprintf_ex, +textout_centre_ex.
+ +
Examples using this: +Available Allegro examples.
+
void textprintf_right_ex(BITMAP *bmp, const FONT *f, int x, y, color, bg, + const char *fmt, ...);

+ Like textprintf_ex(), but interprets the x coordinate as the right rather + than the left edge of the string. This function shares the text length + limitation of textprintf_ex(). Example: +
+      textprintf_right_ex(screen, font, SCREEN_W - 10, 10,
+                          makecol(200, 200, 20), -1,
+                          "%d bullets left", player_ammo);
+ + +
See also: +textprintf_ex, +textout_right_ex.
+
void textprintf_justify_ex(BITMAP *bmp, const FONT *f, int x1, x2, y, + diff, color, bg, const char *fmt, ...);

+ Like textout_justify_ex(), but using a printf() style format string. This + function shares the text length limitation of textprintf_ex(). Example: +
+      char *lines[] = {"Line %02d: Draws justified text",
+                       "Line %02d: within the specified",
+                       "Line %02d: x2-x1 area. But not",
+                       "Line %02d: T H I S !", NULL};
+      /* Show the justification marker. */
+      vline(screen, 300, 0, SCREEN_H-1, makecol(0, 0, 0));
+      /* Draw all the lines until we reach a NULL entry. */
+      for (num = 0, y = 0; lines[num]; num++, y += text_height(font))
+         textprintf_justify_ex(screen, font, 0, 300, y, 180,
+                               makecol(0, 0, 0), makecol(255, 255, 255),
+                               lines[num], num);
+ + + + +
See also: +textprintf_ex, +textout_justify_ex.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg019.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg019.html new file mode 100644 index 0000000..3aa3813 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg019.html @@ -0,0 +1,757 @@ + + +Allegro Manual: Polygon rendering + + + + +

Polygon rendering

+ + + +

+All the 3d functions that accept a `type' parameter are asking for a polygon +rendering mode, which can be any of the following POLYTYPE_* values. If the +CPU_MMX flag of the cpu_capabilities global variable is set, the GRGB and +truecolor *LIT routines will be optimised using MMX instructions. If the +CPU_3DNOW flag is set, the truecolor PTEX*LIT routines will take advantage of +the 3DNow! CPU extensions. + +

+Using MMX for *LIT routines has a side effect: normally (without MMX), these +routines use the blender functions used also for other lighting functions, +set with set_trans_blender() or set_blender_mode(). The MMX versions only use +the RGB value passed to set_trans_blender() and do the linear interpolation +themselves. Therefore a new set of blender functions passed to +set_blender_mode() is ignored. + +


+

#define POLYTYPE_FLAT

+ A simple flat shaded polygon, taking the color from the `c' value of the + first vertex. This polygon type is affected by the drawing_mode() function, + so it can be used to render XOR or translucent polygons. + + +
See also: +Polygon rendering, +polygon3d, +drawing_mode.
+ +
Examples using this: +ex3d, +excamera.
+
#define POLYTYPE_GCOL

+ A single-color gouraud shaded polygon. The colors for each vertex are taken + from the `c' value, and interpolated across the polygon. This is very fast, + but will only work in 256-color modes if your palette contains a smooth + gradient between the colors. In truecolor modes it interprets the color as + a packed, display-format value as produced by the makecol() function. + + +
See also: +Polygon rendering, +polygon3d, +makecol.
+ +
Examples using this: +ex3d, +exscn3d, +exzbuf.
+
#define POLYTYPE_GRGB

+ A gouraud shaded polygon which interpolates RGB triplets rather than a + single color. In 256-color modes this uses the global rgb_map table to + convert the result to an 8-bit paletted color, so it must only be used + after you have set up the RGB mapping table! The colors for each vertex are + taken from the `c' value, which is interpreted as a 24-bit RGB triplet + (0xFF0000 is red, 0x00FF00 is green, and 0x0000FF is blue). + + +
See also: +Polygon rendering, +polygon3d, +rgb_map.
+ +
Examples using this: +ex3d.
+
#define POLYTYPE_ATEX

+ An affine texture mapped polygon. This stretches the texture across the + polygon with a simple 2d linear interpolation, which is fast but not + mathematically correct. It can look ok if the polygon is fairly small or + flat-on to the camera, but because it doesn't deal with perspective + foreshortening, it can produce strange warping artifacts. To see what this + means, run Allegro's test program and see what happens to the polygon3d() + test when you zoom in very close to the cube. + + +
See also: +Polygon rendering, +polygon3d.
+ +
Examples using this: +ex3d.
+
#define POLYTYPE_PTEX

+ A perspective-correct texture mapped polygon. This uses the `z' value from + the vertex structure as well as the u/v coordinates, so textures are + displayed correctly regardless of the angle they are viewed from. Because + it involves division calculations in the inner texture mapping loop, this + mode is a lot slower than POLYTYPE_ATEX, and it uses floating point so it + will be very slow on anything less than a Pentium (even with an FPU, a 486 + can't overlap floating point division with other integer operations like + the Pentium can). + + +
See also: +Polygon rendering, +polygon3d, +POLYTYPE_ATEX.
+ +
Examples using this: +ex3d.
+
#define POLYTYPE_ATEX_MASK

+
#define POLYTYPE_PTEX_MASK

+ Like POLYTYPE_ATEX and POLYTYPE_PTEX, but zero texture map pixels are + skipped, allowing parts of the texture map to be transparent. + + +
See also: +Polygon rendering, +polygon3d, +POLYTYPE_ATEX, +POLYTYPE_PTEX.
+ +
Examples using this: +ex3d.
+
#define POLYTYPE_ATEX_LIT

+
#define POLYTYPE_PTEX_LIT

+ Like POLYTYPE_ATEX and POLYTYPE_PTEX, but the global color_map table (for + 256-color modes) or blender function (for non-MMX truecolor modes) is used + to blend the texture with a light level taken from the `c' value in the + vertex structure. This must only be used after you have set up the color + mapping table or blender functions! + + +
See also: +Polygon rendering, +polygon3d, +POLYTYPE_ATEX, +POLYTYPE_PTEX, +color_map, +Truecolor transparency.
+ +
Examples using this: +ex3d.
+
#define POLYTYPE_ATEX_MASK_LIT

+
#define POLYTYPE_PTEX_MASK_LIT

+ Like POLYTYPE_ATEX_LIT and POLYTYPE_PTEX_LIT, but zero texture map pixels + are skipped, allowing parts of the texture map to be transparent. + + +
See also: +Polygon rendering, +polygon3d, +POLYTYPE_ATEX_LIT, +POLYTYPE_PTEX_LIT.
+ +
Examples using this: +ex3d.
+
#define POLYTYPE_ATEX_TRANS

+
#define POLYTYPE_PTEX_TRANS

+ Render translucent textures. All the general rules for drawing + translucent things apply. However, these modes have a major + limitation: they only work with memory bitmaps or linear frame + buffers (not with banked frame buffers). Don't even try, they do not + check and your program will die horribly (or at least draw wrong + things). + + +
See also: +Polygon rendering, +polygon3d.
+ +
Examples using this: +ex3d.
+
#define POLYTYPE_ATEX_MASK_TRANS

+
#define POLYTYPE_PTEX_MASK_TRANS

+ Like POLYTYPE_ATEX_TRANS and POLYTYPE_PTEX_TRANS, but zero texture map + pixels are skipped. + + +
See also: +Polygon rendering, +polygon3d.
+ +
Examples using this: +ex3d.
+
void polygon3d(BITMAP *bmp, int type, BITMAP *texture, int vc, V3D *vtx[]);

+
void polygon3d_f(BITMAP *bmp, int type, BITMAP *texture, int vc, V3D_f *vtx[]);

+ Draw 3d polygons onto the specified bitmap, using the specified rendering + mode. Unlike the regular polygon() function, these routines don't support + concave or self-intersecting shapes, and they can't draw onto mode-X + screen bitmaps (if you want to write 3d code in mode-X, draw onto a + memory bitmap and then blit to the screen). The width and height of the + texture bitmap must be powers of two, but can be different, eg. a 64x16 + texture is fine, but a 17x3 one is not. The vertex count parameter (vc) + should be followed by an array containing the appropriate number of + pointers to vertex structures: polygon3d() uses the fixed point V3D + structure, while polygon3d_f() uses the floating point V3D_f structure. + These are defined as: +
+      typedef struct V3D
+      {
+         fixed x, y, z;       - position
+         fixed u, v;          - texture map coordinates
+         int c;               - color
+      } V3D;
+   
+      typedef struct V3D_f
+      {
+         float x, y, z;       - position
+         float u, v;          - texture map coordinates
+         int c;               - color
+      } V3D_f;
+
+ How the vertex data is used depends on the rendering mode: + +

+ The `x' and `y' values specify the position of the vertex in 2d screen + coordinates. + +

+ The `z' value is only required when doing perspective correct texture + mapping, and specifies the depth of the point in 3d world coordinates. + +

+ The `u' and `v' coordinates are only required when doing texture mapping, + and specify a point on the texture plane to be mapped on to this vertex. + The texture plane is an infinite plane with the texture bitmap tiled + across it. Each vertex in the polygon has a corresponding vertex on the + texture plane, and the image of the resulting polygon in the texture plane + will be mapped on to the polygon on the screen. + +

+ We refer to pixels in the texture plane as texels. Each texel is a block, + not just a point, and whole numbers for u and v refer to the top-left + corner of a texel. This has a few implications. If you want to draw a + rectangular polygon and map a texture sized 32x32 on to it, you would use + the texture coordinates (0,0), (0,32), (32,32) and (32,0), assuming the + vertices are specified in anticlockwise order. The texture will then be + mapped perfectly on to the polygon. However, note that when we set u=32, + the last column of texels seen on the screen is the one at u=31, and the + same goes for v. This is because the coordinates refer to the top-left + corner of the texels. In effect, texture coordinates at the right and + bottom on the texture plane are exclusive. + +

+ There is another interesting point here. If you have two polygons side + by side sharing two vertices (like the two parts of folded piece of + cardboard), and you want to map a texture across them seamlessly, the + values of u and v on the vertices at the join will be the same for both + polygons. For example, if they are both rectangular, one polygon may use + (0,0), (0,32), (32,32) and (32,0), and the other may use (32,0), (32,32), + (64,32), (64,0). This would create a seamless join. + +

+ Of course you can specify fractional numbers for u and v to indicate a + point part-way across a texel. In addition, since the texture plane is + infinite, you can specify larger values than the size of the texture. + This can be used to tile the texture several times across the polygon. + +

+ The `c' value specifies the vertex color, and is interpreted differently + by various rendering modes. Read the beginning of chapter "Polygon + rendering" for a list of rendering types you can use with this function. + + +

See also: +triangle3d, +quad3d, +polygon, +clip3d, +cpu_capabilities.
+ +
Examples using this: +excamera.
+
void triangle3d(BITMAP *bmp, int type, BITMAP *tex, V3D *v1, *v2, *v3);

+
void triangle3d_f(BITMAP *bmp, int type, BITMAP *tex, V3D_f *v1, *v2, *v3);

+ Draw 3d triangles, using either fixed or floating point vertex structures. + Unlike quad3d[_f](), triangle3d[_f]() functions are not wrappers of + polygon3d[_f](). The triangle3d[_f]() functions use their own routines + taking into account the constantness of the gradients. Therefore + triangle3d[_f](bmp, type, tex, v1, v2, v3) is faster than + polygon3d[_f](bmp, type, tex, 3, v[]). + +

+ Read the beginning of chapter "Polygon rendering" for a list of rendering + types you can use with this function. + + +

See also: +polygon3d, +quad3d, +triangle, +Polygon rendering.
+
void quad3d(BITMAP *bmp, int type, BITMAP *tex, V3D *v1, *v2, *v3, *v4);

+
void quad3d_f(BITMAP *bmp, int type, BITMAP *tex, V3D_f *v1, *v2, *v3, *v4);

+ Draw 3d quads, using either fixed or floating point vertex structures. + These are equivalent to calling polygon3d(bmp, type, tex, 4, v[]) or + polygon3d_f(bmp, type, tex, 4, v[]). + +

+ Read the beginning of chapter "Polygon rendering" for a list of rendering + types you can use with this function. + + +

See also: +polygon3d, +triangle3d, +Polygon rendering.
+ +
Examples using this: +ex3d.
+
int clip3d_f(int type, float min_z, float max_z, int vc, + const V3D_f *vtx[], V3D_f *vout[], V3D_f *vtmp[], int out[]);

+ Clips the polygon given in `vtx'. The number of vertices is `vc', the + result goes in `vout', and `vtmp' and `out' are needed for internal + purposes. The pointers in `vtx', `vout' and `vtmp' must point to valid + V3D_f structures. + +

+ As additional vertices may appear in the process of clipping, so the + size of `vout', `vtmp' and `out' should be at least vc * (1.5 ^ n), where + `n' is the number of clipping planes (5 or 6), and `^' denotes "to the + power of". + +

+ The frustum (viewing volume) is defined by -z<x<z, -z<y<z, + 0<min_z<z<max_z. If max_z<=min_z, the z<max_z clipping is + not done. As you can see, clipping is done in the camera space, with + perspective in mind, so this routine should be called after you apply + the camera matrix, but before the perspective projection. The routine + will correctly interpolate u, v, and c in the vertex structure. However, + no provision is made for high/truecolor GCOL. +

Return value: + Returns the number of vertices after clipping is done. + + +

See also: +polygon3d, +clip3d.
+ +
Examples using this: +excamera, +exscn3d.
+
int clip3d(int type, fixed min_z, fixed max_z, int vc, + const V3D *vtx[], V3D *vout[], V3D *vtmp[], int out[]);

+ Fixed point version of clip3d_f(). This function should be used with + caution, due to the limited precision of fixed point arithmetic and high + chance of rounding errors: the floating point code is better for most + situations. +

Return value: + Returns the number of vertices after clipping is done. + + +

See also: +polygon3d, +clip3d_f.
+

Zbuffered rendering

+A Z-buffer stores the depth of each pixel that is drawn on a viewport. +When a 3D object is rendered, the depth of each of its pixels is compared +against the value stored into the Z-buffer: if the pixel is closer it is +drawn, otherwise it is skipped. + +

+No polygon sorting is needed. However, backface culling should be done +because it prevents many invisible polygons being compared against the +Z-buffer. Z-buffered rendering is the only algorithm supported by Allegro +that directly solves penetrating shapes (see example exzbuf.c, for instance). +The price to pay is more complex (and slower) routines. + +

+Z-buffered polygons are designed as an extension of the normal POLYTYPE_* +rendering styles. Just OR the POLYTYPE with the value POLYTYPE_ZBUF, and +the normal polygon3d(), polygon3d_f(), quad3d(), etc. functions will +render z-buffered polygons. + +

+Example: +

+   polygon3d(bmp, POLYTYPE_ATEX | POLYTYPE_ZBUF, tex, vc, vtx);
+ +

+Of course, the z coordinates have to be valid regardless of rendering style. + +

+A Z-buffered rendering procedure looks like a double-buffered rendering +procedure. You should follow four steps: create a Z-buffer at the beginning +of the program and make the library use it by calling set_zbuffer(). Then, +for each frame, clear the Z-buffer and draw polygons with +POLYTYPE_* | POLYTYPE_ZBUF and finally destroy the Z-buffer when leaving the +program. + +

+Notes on Z-buffered renderers: +

+
ZBUFFER *create_zbuffer(BITMAP *bmp);

+ Creates a Z-buffer using the size of the BITMAP you are planning to draw + on. Several Z-buffers can be defined but only one can be used at the same + time, so you must call set_zbuffer() to make this Z-buffer active. +

Return value: + Returns the pointer to the ZBUFFER or NULL if there was an error. Remember + to destroy the ZBUFFER once you are done with it, to avoid having memory + leaks. + + +

See also: +create_sub_zbuffer, +set_zbuffer, +clear_zbuffer, +destroy_zbuffer.
+ +
Examples using this: +exzbuf.
+
ZBUFFER *create_sub_zbuffer(ZBUFFER *parent, int x, int y, int width, int height);

+ Creates a sub-z-buffer, ie. a z-buffer sharing drawing memory with a + pre-existing z-buffer, but possibly with a different size. The same rules + as for sub-bitmaps apply: the sub-z-buffer width and height can extend + beyond the right and bottom edges of the parent (they will be clipped), + but the origin point must lie within the parent region. + +

+ When drawing z-buffered to a bitmap, the top left corner of the bitmap is + always mapped to the top left corner of the current z-buffer. So this + function is primarily useful if you want to draw to a sub-bitmap and use + the corresponding sub-area of the z-buffer. In other cases, eg. if you + just want to draw to a sub-bitmap of screen (and not to other parts of + screen), then you would usually want to create a normal z-buffer (not + sub-z-buffer) the size of the visible screen. You don't need to first + create a z-buffer the size of the virtual screen and then a sub-z-buffer + of that. +

Return value: + Returns the pointer to the sub ZBUFFER or NULL if there was an error. + Remember to destroy the ZBUFFER once you are done with it, to avoid having + memory leaks. + + +

See also: +create_zbuffer, +create_sub_bitmap, +destroy_zbuffer.
+
void set_zbuffer(ZBUFFER *zbuf);

+ Makes the given Z-buffer be the active one. This should have been + previously created with create_zbuffer(). + + +
See also: +create_zbuffer, +clear_zbuffer, +destroy_zbuffer.
+ +
Examples using this: +exzbuf.
+
void clear_zbuffer(ZBUFFER *zbuf, float z);

+ Writes z into the given Z-buffer (0 means far away). This function should + be used to initialize the Z-buffer before each frame. Actually, low-level + routines compare depth of the current pixel with 1/z: for example, if you + want to clip polygons farther than 10, you must call + clear_zbuffer(zbuf, 0.1). + + +
See also: +create_zbuffer, +set_zbuffer, +destroy_zbuffer.
+ +
Examples using this: +exzbuf.
+
void destroy_zbuffer(ZBUFFER *zbuf);

+ Destroys the Z-buffer when you are finished with it. Use this to avoid + memory leaks in your program. + + +
See also: +create_zbuffer, +set_zbuffer, +clear_zbuffer.
+ +
Examples using this: +exzbuf.
+

Scene rendering

+Allegro provides two simple approaches to remove hidden surfaces: +

+ +

+The scene rendering has approximately the following steps: +

+ +

+For each horizontal line in the viewport an x-sorted edge list is used to +keep track of what polygons are "in" and which is the nearest. Vertical +coherency is used - the edge list for a scanline is sorted starting from +the previous one - it won't change much. The scene rendering routines use +the same low-level asm routines as normal polygon3d(). + +

+Notes on scene rendering: +

+Using a lot of *MASK* polygons drastically reduces performance, because +when a MASKed polygon is the first in line of sight, the polygons +underneath have to be drawn too. The same applies to FLAT polygons drawn +with DRAW_MODE_TRANS. + +

+Z-buffered rendering works also within the scene renderer. It may be +helpful when you have a few intersecting polygons, but most of the +polygons may be safely rendered by the normal scanline sorting algo. +Same as before: just OR the POLYTYPE with POLYTYPE_ZBUF. Also, you +have to clear the z-buffer at the start of the frame. Example: +

+   clear_scene(buffer);
+   if (some_polys_are_zbuf) clear_zbuffer(0.);
+   while (polygons) {
+      ...
+      if (this_poly_is_zbuf) type |= POLYTYPE_ZBUF;
+      scene_polygon3d(type, tex, vc, vtx);
+   }
+   render_scene();
+ +


+

int create_scene(int nedge, int npoly);

+ Allocates memory for a scene, `nedge' and `npoly' are your estimates of how + many edges and how many polygons you will render (you cannot get over the + limit specified here). If you use same values in succesive calls, the + space will be reused (no new malloc()). + +

+ The memory allocated is a little less than 150 * (nedge + npoly) bytes. +

Return value: + Returns zero on success, or a negative number if allocations fail. + + +

See also: +scene_polygon3d, +render_scene, +clear_scene, +destroy_scene, +scene_gap, +create_zbuffer.
+ +
Examples using this: +exscn3d.
+
void clear_scene(BITMAP *bmp);

+ Initializes a scene. The bitmap is the bitmap you will eventually render + on. + + +
See also: +create_scene, +scene_polygon3d, +render_scene, +destroy_scene, +scene_gap.
+ +
Examples using this: +exscn3d.
+
void destroy_scene();

+ Deallocate memory previously allocated by create_scene. Use this to avoid + memory leaks in your program. + + +
See also: +create_scene, +scene_polygon3d, +clear_scene, +render_scene, +scene_gap.
+ +
Examples using this: +exscn3d.
+
int scene_polygon3d(int type, BITMAP *texture, int vc, V3D *vtx[]);

+
int scene_polygon3d_f(int type, BITMAP *texture, int vc, V3D_f *vtx[]);

+ Puts a polygon in the rendering list. Nothing is really rendered at this + moment. Should be called between clear_scene() and render_scene(). + +

+ Arguments are the same as for polygon3d(), except the bitmap is missing. + The one passed to clear_scene() will be used. + +

+ Unlike polygon3d(), the polygon may be concave or self-intersecting. + Shapes that penetrate one another may look OK, but they are not really + handled by this code. + +

+ Note that the texture is stored as a pointer only, and you should keep + the actual bitmap around until render_scene(), where it is used. + +

+ Since the FLAT style is implemented with the low-level hline() funtion, + the FLAT style is subject to DRAW_MODEs. All these modes are valid. Along + with the polygon, this mode will be stored for the rendering moment, and + also all the other related variables (color_map pointer, pattern pointer, + anchor, blender values). + +

+ The settings of the CPU_MMX and CPU_3DNOW flags of the cpu_capabilities + global variable on entry in this routine affect the choice of low-level + asm routine that will be used by render_scene() for this polygon. +

Return value: + Returns zero on success, or a negative number if it won't be rendered for + lack of a rendering routine. + + +

See also: +create_scene, +clear_scene, +render_scene, +destroy_scene, +polygon3d, +cpu_capabilities.
+ +
Examples using this: +exscn3d.
+
void render_scene();

+ Renders all the specified scene_polygon3d()'s on the bitmap passed to + clear_scene(). Rendering is done one scanline at a time, with no pixel + being processed more than once. + +

+ Note that between clear_scene() and render_scene() you shouldn't change + the clip rectangle of the destination bitmap. For speed reasons, you + should set the clip rectangle to the minimum. + +

+ Note also that all the textures passed to scene_polygon3d() are stored as + pointers only and actually used in render_scene(). + + +

See also: +create_scene, +clear_scene, +destroy_scene, +scene_gap, +scene_polygon3d.
+ +
Examples using this: +exscn3d.
+
extern float scene_gap;

+ This number (default value = 100.0) controls the behaviour of the + z-sorting algorithm. When an edge is very close to another's polygon + plane, there is an interval of uncertainty in which you cannot tell which + object is visible (which z is smaller). This is due to cumulative + numerical errors for edges that have undergone a lot of transformations + and interpolations. + +

+ The default value means that if the 1/z values (in projected space) + differ by only 1/100 (one percent), they are considered to be equal and + the x-slopes of the planes are used to find out which plane is getting + closer when we move to the right. + +

+ Larger values means narrower margins, and increasing the chance of + missing true adjacent edges/planes. Smaller values means larger margins, + and increasing the chance of mistaking close polygons for adjacent ones. + The value of 100 is close to the optimum. However, the optimum shifts + slightly with resolution, and may be application-dependent. It is here + for you to fine-tune. + + + + +

See also: +create_scene, +clear_scene, +destroy_scene, +render_scene, +scene_polygon3d.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg020.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg020.html new file mode 100644 index 0000000..061d357 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg020.html @@ -0,0 +1,579 @@ + + +Allegro Manual: Transparency and patterned drawing + + + + +

Transparency and patterned drawing

+ + + +


+

void drawing_mode(int mode, BITMAP *pattern, int x_anchor, int y_anchor);

+ Sets the graphics drawing mode. This only affects the geometric routines + like putpixel, lines, rectangles, circles, polygons, floodfill, etc, not + the text output, blitting, or sprite drawing functions. The mode should + be one of the following constants: +
+      DRAW_MODE_SOLID               - the default, solid color
+                                      drawing
+      DRAW_MODE_XOR                 - exclusive-or drawing
+      DRAW_MODE_COPY_PATTERN        - multicolored pattern fill
+      DRAW_MODE_SOLID_PATTERN       - single color pattern fill
+      DRAW_MODE_MASKED_PATTERN      - masked pattern fill
+      DRAW_MODE_TRANS               - translucent color blending
+
+ In DRAW_MODE_SOLID, pixels of the bitmap being drawn onto are simply + replaced by those produced by the drawing function. + +

+ In DRAW_MODE_XOR, pixels are written to the bitmap with an exclusive-or + operation rather than a simple copy, so drawing the same shape twice will + erase it. Because it involves reading as well as writing the bitmap + memory, xor drawing is a lot slower than the normal replace mode. + +

+ With the patterned modes, you provide a pattern bitmap which is tiled + across the surface of the shape. Allegro stores a pointer to this bitmap + rather than copying it, so you must not destroy the bitmap while it is + still selected as the pattern. The width and height of the pattern must + be powers of two, but they can be different, eg. a 64x16 pattern is fine, + but a 17x3 one is not. The pattern is tiled in a grid starting at point + (x_anchor, y_anchor). Normally you should just pass zero for these + values, which lets you draw several adjacent shapes and have the patterns + meet up exactly along the shared edges. Zero alignment may look peculiar + if you are moving a patterned shape around the screen, however, because + the shape will move but the pattern alignment will not, so in some + situations you may wish to alter the anchor position. + +

+ When you select DRAW_MODE_COPY_PATTERN, pixels are simply copied from the + pattern bitmap onto the destination bitmap. This allows the use of + multicolored patterns, and means that the color you pass to the drawing + routine is ignored. This is the fastest of the patterned modes. + +

+ In DRAW_MODE_SOLID_PATTERN, each pixel in the pattern bitmap is compared + with the mask color, which is zero in 256-color modes or bright pink for + truecolor data (maximum red and blue, zero green). If the pattern pixel + is solid, a pixel of the color you passed to the drawing routine is + written to the destination bitmap, otherwise a zero is written. The + pattern is thus treated as a monochrome bitmask, which lets you use the + same pattern to draw different shapes in different colors, but prevents + the use of multicolored patterns. + +

+ DRAW_MODE_MASKED_PATTERN is almost the same as DRAW_MODE_SOLID_PATTERN, + but the masked pixels are skipped rather than being written as zeros, so + the background shows through the gaps. + +

+ In DRAW_MODE_TRANS, the global color_map table or truecolor blender + functions are used to overlay pixels on top of the existing image. This + must only be used after you have set up the color mapping table (for 256 + color modes) or blender functions (for truecolor modes). Because it + involves reading as well as writing the bitmap memory, translucent + drawing is very slow if you draw directly to video RAM, so wherever + possible you should use a memory bitmap instead. + + +

See also: +xor_mode, +solid_mode, +color_map, +set_trans_blender.
+ +
Examples using this: +exalpha, +excolmap, +exjoy, +expat, +extrans.
+
void xor_mode(int on);

+ This is a shortcut for toggling xor drawing mode on and off. Calling + xor_mode(TRUE) is equivalent to drawing_mode(DRAW_MODE_XOR, NULL, 0, 0). + Calling xor_mode(FALSE) is equivalent to + drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0). + + +
See also: +drawing_mode.
+ +
Examples using this: +exspline, +exupdate.
+
void solid_mode();

+ This is a shortcut for selecting solid drawing mode. It is equivalent to + calling drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0). + + +
See also: +drawing_mode.
+ +
Examples using this: +exalpha, +expat.
+

256-color transparency

+In paletted video modes, translucency and lighting are implemented with a +64k lookup table, which contains the result of combining any two colors c1 +and c2. You must set up this table before you use any of the translucency +or lighting routines. Depending on how you construct the table, a range of +different effects are possible. For example, translucency can be implemented +by using a color halfway between c1 and c2 as the result of the combination. +Lighting is achieved by treating one of the colors as a light level (0-255) +rather than a color, and setting up the table appropriately. A range of +specialised effects are possible, for instance replacing any color with any +other color and making individual source or destination colors completely +solid or invisible. Color mapping tables can be precalculated with the +colormap utility, or generated at runtime. Read chapter "Structures and types +defined by Allegro" for an internal description of the COLOR_MAP structure. + +


+

extern COLOR_MAP *color_map;

+ Global pointer to the color mapping table. You must allocate your own + COLOR_MAP either statically or dynamically and set color_map to it + before using any translucent or lit drawing functions in a 256-color + video mode! Example: +
+      color_map = malloc(sizeof(COLOR_MAP));
+      if (!color_map)
+         abort_on_error("Not enough memory for color map!");
+ + +
See also: +create_color_table, +create_light_table, +create_trans_table, +create_blender_table, +set_trans_blender, +draw_trans_sprite, +draw_lit_sprite, +draw_gouraud_sprite, +drawing_mode.
+ +
Examples using this: +ex3d, +excolmap, +exlights, +exshade, +extrans.
+
void create_trans_table(COLOR_MAP *table, const PALETTE pal, + int r, g, b, void (*callback)(int pos));

+ Fills the specified color mapping table with lookup data for doing + translucency effects with the specified palette. When combining the + colors c1 and c2 with this table, the result will be a color somewhere + between the two. The r, g, and b parameters specify the solidity of each + color component, ranging from 0 (totally transparent) to 255 (totally + solid). For 50% solidity, pass 128. + +

+ This function treats source color #0 as a special case, leaving the + destination unchanged whenever a zero source pixel is encountered, so that + masked sprites will draw correctly. This function will take advantage of + the global rgb_map variable to speed up color conversions. If the callback + function is not NULL, it will be called 256 times during the calculation, + allowing you to display a progress indicator. Example: +

+      COLOR_MAP trans_table;
+      ...
+      /* Build a color lookup table for translucent drawing. */
+      create_trans_table(&trans_table, pal, 128, 128, 128, NULL);
+ + +
See also: +color_map, +create_light_table, +create_color_table, +create_blender_table, +draw_trans_sprite, +draw_lit_sprite, +draw_gouraud_sprite, +rgb_map.
+ +
Examples using this: +ex3d, +extrans.
+
void create_light_table(COLOR_MAP *table, const PALETTE pal, + int r, g, b, void (*callback)(int pos));

+ Fills the specified color mapping table with lookup data for doing + lighting effects with the specified palette. When combining the colors c1 + and c2 with this table, c1 is treated as a light level from 0-255. At + light level 255 the table will output color c2 unchanged, at light level + 0 it will output the r, g, b value you specify to this function, and at + intermediate light levels it will output a color somewhere between the + two extremes. The r, g, and b values are in the range 0-63. + +

+ This function will take advantage of the global rgb_ap variable to speed + up color conversions. If the callback function is not NULL, it will be + called 256 times during the calculation, allowing you to display a + progress indicator. Example: +

+      COLOR_MAP light_table;
+      ...
+      /* Build a color lookup table for lighting effects. */
+      create_light_table(&light_table, pal, 0, 0, 0, NULL);
+ + +
See also: +color_map, +create_trans_table, +create_color_table, +create_blender_table, +draw_trans_sprite, +draw_lit_sprite, +draw_gouraud_sprite, +rgb_map.
+ +
Examples using this: +ex3d, +exshade, +extrans.
+
void create_color_table(COLOR_MAP *table, const PALETTE pal, + void (*blend)(PALETTE pal, int x, int y, RGB *rgb), + void (*callback)(int pos));

+ Fills the specified color mapping table with lookup data for doing + customised effects with the specified palette, calling the blend function + to determine the results of each color combination. + +

+ Your blend routine will be passed a pointer to the palette and the two + indices of the colors which are to be combined, and should fill in the RGB + structure with the desired result in 0-63 format. Allegro will then search + the palette for the closest match to the RGB color that you requested, so + it doesn't matter if the palette has no exact match for this color. + +

+ If the callback function is not NULL, it will be called 256 times during + the calculation, allowing you to display a progress indicator. Example: +

+      COLOR_MAP greyscale_table;
+      ...
+      void return_grey_color(const PALETTE pal,
+                             int x, int y, RGB *rgb)
+      {
+         ...
+      }
+      ...
+         /* Build a color lookup table for greyscale effect. */
+         create_color_table(&greyscale_table, pal,
+                            return_grey_color, NULL);
+ + +
See also: +color_map, +create_light_table, +create_trans_table, +create_blender_table, +draw_trans_sprite, +draw_lit_sprite, +draw_gouraud_sprite, +rgb_map.
+ +
Examples using this: +excolmap.
+
void create_blender_table(COLOR_MAP *table, const PALETTE pal, + void (*callback)(int pos));

+ Fills the specified color mapping table with lookup data for doing a + paletted equivalent of whatever truecolor blender mode is currently + selected. After calling set_trans_blender(), set_blender_mode(), or any + of the other truecolor blender mode routines, you can use this function + to create an 8-bit mapping table that will have the same results as + whatever 24-bit blending mode you have enabled. + + +
See also: +color_map, +create_light_table, +create_trans_table, +create_color_table, +draw_trans_sprite, +draw_lit_sprite, +draw_gouraud_sprite, +set_trans_blender, +set_blender_mode.
+

Truecolor transparency

+In truecolor video modes, translucency and lighting are implemented by a +blender function of the form: +

+   unsigned long (*BLENDER_FUNC)(unsigned long x, y, n);
+ +

+For each pixel to be drawn, this routine is passed two color parameters x +and y, decomposes them into their red, green and blue components, combines +them according to some mathematical transformation involving the +interpolation factor n, and then merges the result back into a single +return color value, which will be used to draw the pixel onto +the destination bitmap. + +

+The parameter x represents the blending modifier color and the parameter y +represents the base color to be modified. The interpolation factor n is in +the range [0-255] and controls the solidity of the blending. + +

+When a translucent drawing function is used, x is the color of the source, +y is the color of the bitmap being drawn onto and n is the alpha level +that was passed to the function that sets the blending mode (the RGB triplet +that was passed to this function is not taken into account). + +

+When a lit sprite drawing function is used, x is the color represented by +the RGB triplet that was passed to the function that sets the blending mode +(the alpha level that was passed to this function is not taken into +account), y is the color of the sprite and n is the alpha level that was +passed to the drawing function itself. + +

+Since these routines may be used from various different color depths, there +are three such callbacks, one for use with 15-bit 5.5.5 pixels, one for 16 +bit 5.6.5 pixels, and one for 24-bit 8.8.8 pixels (this can be shared +between the 24 and 32-bit code since the bit packing is the same). + +


+

void set_trans_blender(int r, int g, int b, int a);

+ Enables a linear interpolator blender mode for combining translucent + or lit truecolor pixels. + + +
See also: +set_blender_mode, +set_alpha_blender, +set_write_alpha_blender, +color_map, +draw_trans_sprite, +draw_lit_sprite, +drawing_mode, +set_add_blender, +set_burn_blender, +set_color_blender, +set_difference_blender, +set_dissolve_blender, +set_dodge_blender, +set_hue_blender, +set_invert_blender, +set_luminance_blender, +set_multiply_blender, +set_saturation_blender, +set_screen_blender.
+ +
Examples using this: +ex3d, +exblend, +exshade, +extrans, +exxfade.
+
void set_alpha_blender();

+ Enables the special alpha-channel blending mode, which is used for + drawing 32-bit RGBA sprites. After calling this function, you can use + draw_trans_sprite() or draw_trans_rle_sprite() to draw a 32-bit source + image onto any hicolor or truecolor destination. The alpha values will be + taken directly from the source graphic, so you can vary the solidity of + each part of the image. You can't use any of the normal translucency + functions while this mode is active, though, so you should reset to one + of the normal blender modes (eg. set_trans_blender()) before drawing + anything other than 32-bit RGBA sprites. + + +
See also: +set_trans_blender, +draw_trans_sprite, +draw_trans_rle_sprite, +set_write_alpha_blender.
+ +
Examples using this: +exalpha, +extrans.
+
void set_write_alpha_blender();

+ Enables the special alpha-channel editing mode, which is used for drawing + alpha channels over the top of an existing 32-bit RGB sprite, to turn it + into an RGBA format image. After calling this function, you can set the + drawing mode to DRAW_MODE_TRANS and then write draw color values (0-255) + onto a 32-bit image. This will leave the color values unchanged, but + alter the alpha to whatever values you are writing. After enabling this + mode you can also use draw_trans_sprite() to superimpose an 8-bit alpha + mask over the top of an existing 32-bit sprite. + + +
See also: +set_alpha_blender, +draw_trans_sprite, +drawing_mode.
+ +
Examples using this: +exalpha, +extrans.
+
void set_add_blender(int r, int g, int b, int a);

+ Enables an additive blender mode for combining translucent or lit + truecolor pixels. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_burn_blender(int r, int g, int b, int a);

+ Enables a burn blender mode for combining translucent or lit truecolor + pixels. Here the lightness values of the colours of the source image + reduce the lightness of the destination image, darkening the image. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_color_blender(int r, int g, int b, int a);

+ Enables a color blender mode for combining translucent or lit truecolor + pixels. Applies only the hue and saturation of the source image to the + destination image. The luminance of the destination image is not affected. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_difference_blender(int r, int g, int b, int a);

+ Enables a difference blender mode for combining translucent or lit + truecolor pixels. This makes an image which has colours calculated by the + difference between the source and destination colours. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_dissolve_blender(int r, int g, int b, int a);

+ Enables a dissolve blender mode for combining translucent or lit + truecolor pixels. Randomly replaces the colours of some pixels in the + destination image with those of the source image. The number of pixels + replaced depends on the alpha value (higher value, more pixels replaced; + you get the idea :). + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_dodge_blender(int r, int g, int b, int a);

+ Enables a dodge blender mode for combining translucent or lit truecolor + pixels. The lightness of colours in the source lighten the colours of the + destination. White has the most effect; black has none. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_hue_blender(int r, int g, int b, int a);

+ Enables a hue blender mode for combining translucent or lit truecolor + pixels. This applies the hue of the source to the destination. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_invert_blender(int r, int g, int b, int a);

+ Enables an invert blender mode for combining translucent or lit truecolor + pixels. Blends the inverse (or negative) colour of the source with the + destination. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_luminance_blender(int r, int g, int b, int a);

+ Enables a luminance blender mode for combining translucent or lit + truecolor pixels. Applies the luminance of the source to the destination. + The colour of the destination is not affected. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_multiply_blender(int r, int g, int b, int a);

+ Enables a multiply blender mode for combining translucent or lit + truecolor pixels. Combines the source and destination images, multiplying + the colours to produce a darker colour. If a colour is multiplied by + white it remains unchanged; when multiplied by black it also becomes + black. + + +
See also: +set_trans_blender, +drawing_mode.
+ +
Examples using this: +exalpha.
+
void set_saturation_blender(int r, int g, int b, int a);

+ Enables a saturation blender mode for combining translucent or lit + truecolor pixels. Applies the saturation of the source to the destination + image. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_screen_blender(int r, int g, int b, int a);

+ Enables a screen blender mode for combining translucent or lit truecolor + pixels. This blender mode lightens the colour of the destination image by + multiplying the inverse of the source and destination colours. Sort of + like the opposite of the multiply blender mode. + + +
See also: +set_trans_blender, +drawing_mode.
+
void set_blender_mode(BLENDER_FUNC b15, b16, b24, int r, g, b, a);

+ Specifies a custom set of truecolor blender routines, which can be used + to implement whatever special interpolation modes you need. This function + shares a single blender between the 24 and 32-bit modes. + + +
See also: +set_blender_mode_ex, +set_trans_blender, +color_map, +draw_trans_sprite, +draw_lit_sprite, +drawing_mode.
+
void set_blender_mode_ex(BLENDER_FUNC b15, b16, b24, b32, b15x, b16x, b24x, + int r, g, b, a);

+ Like set_blender_mode(), but allows you to specify a more complete set of + blender routines. The b15, b16, b24, and b32 routines are used when + drawing pixels onto destinations of the same format, while b15x, b16x, + and b24x are used by draw_trans_sprite() and draw_trans_rle_sprite() when + drawing RGBA images onto destination bitmaps of another format. These + blenders will be passed a 32-bit x parameter, along with a y value of a + different color depth, and must try to do something sensible in response. + + + + +
See also: +set_blender_mode, +set_alpha_blender.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg021.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg021.html new file mode 100644 index 0000000..b1dc0bf --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg021.html @@ -0,0 +1,137 @@ + + +Allegro Manual: Converting between color formats + + + + +

Converting between color formats

+ + + +

+In general, Allegro is designed to be used in only one color depth at a +time, so you will call set_color_depth() once and then store all your +bitmaps in the same format. If you want to mix several different pixel +formats, you can use create_bitmap_ex() in place of create_bitmap(), and +call bitmap_color_depth() to query the format of a specific image. Most of +the graphics routines require all their input parameters to be in the same +format (eg. you cannot stretch a 15-bit source bitmap onto a 24-bit +destination), but there are some exceptions: +

+Expanding a 256-color source onto a truecolor destination is fairly fast +(obviously you must set the correct palette before doing this conversion!). +Converting between different truecolor formats is slightly slower, and +reducing truecolor images to a 256-color destination is very slow (it can be +sped up significantly if you set up the global rgb_map table before doing +the conversion). + +


+

int bestfit_color(const PALETTE pal, int r, int g, int b);

+ Searches the specified palette for the closest match to the requested + color, which are specified in the VGA hardware 0-63 format. Normally you + should call makecol8() instead, but this lower level function may be + useful if you need to use a palette other than the currently selected + one, or specifically don't want to use the rgb_map lookup table. +

Return value: + Returns the index of the palette for the closest match to the requested + color. + + +

See also: +makecol8.
+
extern RGB_MAP *rgb_map;

+ To speed up reducing RGB values to 8-bit paletted colors, Allegro uses a + 32k lookup table (5 bits for each color component). You must set up this + table before using the gouraud shading routines, and if present the table + will also vastly accelerate the makecol8() and some create_*_table() + functions. RGB tables can be precalculated with the rgbmap utility, or + generated at runtime with create_rgb_table(). + + +
See also: +create_rgb_table, +makecol8, +create_trans_table, +create_light_table, +create_color_table.
+ +
Examples using this: +ex3d, +excolmap, +exrgbhsv, +exshade, +extrans.
+
void create_rgb_table(RGB_MAP *table, const PALETTE pal, + void (*callback)(int pos));

+ Fills the specified RGB mapping table with lookup data for the specified + palette. If the callback function is not NULL, it will be called 256 + times during the calculation, allowing you to display a progress + indicator. Example: +
+      RGB_MAP rgb_table;
+      
+      create_rgb_table(&rgb_table, palette, NULL);
+      rgb_map = &rgb_table;
+ + +
See also: +rgb_map.
+ +
Examples using this: +ex3d, +excolmap, +exrgbhsv, +exshade, +extrans.
+
void hsv_to_rgb(float h, float s, float v, int *r, int *g, int *b);

+
void rgb_to_hsv(int r, int g, int b, float *h, float *s, float *v);

+ Convert color values between the HSV and RGB colorspaces. The RGB values + range from 0 to 255, hue is from 0 to 360, and saturation and value are + from 0 to 1. Example: +
+      int r, g, b;
+      float hue, saturation, value;
+      ...
+      /* Convert a reddish color to HSV format. */
+      rgb_to_hsv(255, 0, 128, &hue, &saturation, &value);
+      
+      /* Now put our tin foil hat, and verify that. */
+      hsv_to_rgb(hue, saturation, value, &r, &g, &b);
+      ASSERT(r == 255);
+      ASSERT(g == 0);
+      ASSERT(b == 128);
+ + + + +
Examples using this: +exlights, +exrgbhsv.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg022.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg022.html new file mode 100644 index 0000000..508db08 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg022.html @@ -0,0 +1,190 @@ + + +Allegro Manual: Direct access to video memory + + + + +

Direct access to video memory

+ + + +

+Read chapter "Structures and types defined by Allegro" for an internal +description of the BITMAP structure. There are several ways to get direct +access to the image memory of a bitmap, varying in complexity depending on +what sort of bitmap you are using. + +

+The simplest approach will only work with memory bitmaps (obtained from +create_bitmap(), grabber datafiles, and image files) and sub-bitmaps of +memory bitmaps. This uses a table of char pointers, called `line', which is +a part of the bitmap structure and contains pointers to the start of each +line of the image. For example, a simple memory bitmap putpixel function is: +

+   void memory_putpixel(BITMAP *bmp, int x, int y, int color)
+   {
+      bmp->line[y][x] = color;
+   }
+
+For truecolor modes you need to cast the line pointer to the appropriate +type, for example: +
+   void memory_putpixel_15_or_16_bpp(BITMAP *bmp, int x, int y, int color)
+   {
+      ((short *)bmp->line[y])[x] = color;
+   }
+
+   void memory_putpixel_32(BITMAP *bmp, int x, int y, int color)
+   {
+      ((long *)bmp->line[y])[x] = color;
+   }
+
+If you want to write to the screen as well as to memory bitmaps, you need to +use some helper macros, because the video memory may not be part of your +normal address space. This simple routine will work for any linear screen, +eg. a VESA linear framebuffers: +
+   void linear_screen_putpixel(BITMAP *bmp, int x, int y, int color)
+   {
+      bmp_select(bmp);
+      bmp_write8((unsigned long)bmp->line[y]+x, color);
+   }
+
+For truecolor modes you should replace the bmp_write8() with bmp_write16(), +bmp_write24(), or bmp_write32(), and multiply the x offset by the number of +bytes per pixel. There are of course similar functions to read a pixel value +from a bitmap, namely bmp_read8(), bmp_read16(), bmp_read24() and +bmp_read32(). + +

+This still won't work in banked SVGA modes, however, or on platforms like +Windows that do special processing inside the bank switching functions. For +more flexible access to bitmap memory, you need to call the following +routines. They are implemented as inline assembler routines, so they are not +as inefficient as they might seem. If the bitmap doesn't require bank +switching (ie. it is a memory bitmap, mode 13h screen, etc), these functions +just return bmp->line[line]. + +


+

unsigned long bmp_write_line(BITMAP *bmp, int line);

+ Selects the line of a bitmap that you are going to draw onto. +

Return value: + Returns the address of the selected line for writing. + + +

Examples using this: +exflame, +exlights.
+
unsigned long bmp_read_line(BITMAP *bmp, int line);

+ Selects the line of a bitmap that you are going to read from. +

Return value: + Returns the address of the selected line for reading. + + +

Examples using this: +exflame.
+
void bmp_unwrite_line(BITMAP *bmp);

+ Releases the bitmap memory after you are finished with it. You only need + to call this once at the end of a drawing operation, even if you have + called bmp_write_line() or bmp_read_line() several times before it. + + +
Examples using this: +exflame, +exlights.
+

More on banked direct memory access

+ +

+Although SVGA bitmaps are banked, Allegro provides linear access to the +memory within each scanline, so you only need to pass a y coordinate to +these functions. Various x positions can be obtained by simply adding the x +coordinate to the returned address. The return value is an unsigned long +rather than a char pointer because the bitmap memory may not be in your data +segment, and you need to access it with far pointers. For example, a +putpixel using the bank switching functions is: +

+   void banked_putpixel(BITMAP *bmp, int x, int y, int color)
+   {
+      unsigned long address = bmp_write_line(bmp, y);
+      bmp_select(bmp);
+      bmp_write8(address+x, color);
+      bmp_unwrite_line(bmp);
+   }
+
+You will notice that Allegro provides separate functions for setting the +read and write banks. It is important that you distinguish between these, +because on some graphics cards the banks can be set individually, and on +others the video memory is read and written at different addresses. Life is +never quite as simple as we might wish it to be, though (this is true even +when we _aren't_ talking about graphics coding :-) and so of course some +cards only provide a single bank. On these the read and write bank functions +will behave identically, so you shouldn't assume that you can read from one +part of video memory and write to another at the same time. You can call +bmp_read_line(), and read whatever you like from that line, and then call +bmp_write_line() with the same or a different line number, and write +whatever you like to this second line, but you mustn't call bmp_read_line() +and bmp_write_line() together and expect to be able to read one line and +write the other simultaneously. It would be nice if this was possible, but +if you do it, your code won't work on single banked SVGA cards. + +

+And then there's mode-X. If you've never done any mode-X graphics coding, +you probably won't understand this, but for those of you who want to know +how Allegro sets up the mode-X screen bitmaps, here goes... + +

+The line pointers are still present, and they contain planar addresses, ie. +the actual location at which you access the first pixel in the line. These +addresses are guaranteed to be quad aligned, so you can just set the write +plane, divide your x coordinate by four, and add it to the line pointer. For +example, a mode-X putpixel is: +

+   void modex_putpixel(BITMAP *b, int x, int y, int color)
+   {
+      outportw(0x3C4, (0x100<<(x&3))|2);
+      bmp_select(bmp);
+      bmp_write8((unsigned long)bmp->line[y]+(x>>2), color);
+   }
+ +

+Oh yeah: the DJGPP nearptr hack. Personally I don't like this very much +because it disables memory protection and isn't portable to other platforms, +but a lot of people swear by it because it can give you direct access to the +screen memory via a normal C pointer. Warning: this method will only work +with the DJGPP library, when using VGA 13h or a linear framebuffer modes! + +

+In your setup code: +

+   #include <sys/nearptr.h>
+
+   unsigned char *screenmemory;
+   unsigned long screen_base_addr;
+
+   __djgpp_nearptr_enable();
+
+   __dpmi_get_segment_base_address(screen->seg, &screen_base_addr);
+
+   screenmemory = (unsigned char *)(screen_base_addr + 
+                                    screen->line[0] -
+                                    __djgpp_base_address);
+
+Then: +
+   void nearptr_putpixel(int x, int y, int color)
+   {
+      screenmemory[x + y*VIRTUAL_W] = color;
+   }
+
+ + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg023.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg023.html new file mode 100644 index 0000000..f6bb15d --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg023.html @@ -0,0 +1,277 @@ + + +Allegro Manual: FLIC routines + + + + +

FLIC routines

+ + + +

+There are two high level functions for playing FLI/FLC animations: +play_fli(), which reads the data directly from disk, and play_memory_fli(), +which uses data that has already been loaded into RAM. Apart from the +different sources of the data, these two functions behave identically. They +draw the animation onto the specified bitmap, which should normally be the +screen. Frames will be aligned with the top left corner of the bitmap: if +you want to position them somewhere else you will need to create a +sub-bitmap for the FLI player to draw onto. + +

+If the callback function is not NULL it will be called once for each frame, +allowing you to perform background tasks of your own. This callback should +normally return zero: if it returns non-zero the player will terminate (this +is the only way to stop an animation that is playing in looped mode). + +

+The FLI player returns FLI_OK if it reached the end of the file, FLI_ERROR +if something went wrong, and the value returned by the callback function if +that was what stopped it. If you need to distinguish between different return +values, your callback should return positive integers, since FLI_OK is zero +and FLI_ERROR is negative. + +

+Note that the FLI player will only work when the timer module is installed, +and that it will alter the palette according to whatever palette data is +present in the animation file. + +

+Occasionally you may need more detailed control over how an FLI is played, +for example if you want to superimpose a text scroller on top of the +animation, or to play it back at a different speed. You could do both of +these with the lower level functions described below. + +


+

int play_fli(const char *filename, BITMAP *bmp, int loop, int (*callback)());

+ Plays an Autodesk Animator FLI or FLC animation file on the specified + BITMAP, reading the data from disk as it is required. If `loop' is not + zero, the player will cycle when it reaches the end of the file, otherwise + it will play through the animation once and then return. Read the beginning + of chapter "FLIC routines" for a description of the callback parameter. + Example: +
+      /* Let users skip looped animations. */
+      int check_escape_key(void)
+      {
+         if (key[KEY_ESC])
+            return 1;
+         else
+            return 0;
+      }
+      ...
+         int ret = play_fli("animlogo.fli", screen, 1,
+                             check_escape_key);
+         if (ret == FLI_ERROR)
+            abort_on_error("Error playing intro!");
+

Return value: + The FLI player returns FLI_OK if it reached the end of the file, FLI_ERROR + if something went wrong, and the value returned by the callback function if + that was what stopped it. + + +

See also: +play_memory_fli, +install_timer, +fli_frame.
+
int play_memory_fli(const void *fli_data, BITMAP *bmp, int loop, + int (*callback)());

+ Plays an Autodesk Animator FLI or FLC animation on the specified BITMAP, + reading the data from a copy of the file which is held in memory. You can + obtain the `fli_data' pointer by mallocing a block of memory and reading + an FLI file into it, or by importing an FLI into a grabber datafile. If + `loop' is not zero, the player will cycle when it reaches the end of the + file, otherwise it will play through the animation once and then return. + Read the beginning of chapter "FLIC routines" for a description of the + callback parameter. + +

+ Playing animations from memory is obviously faster than cueing them + directly from disk, and is particularly useful with short, looped FLI's. + Animations can easily get very large, though, so in most cases you will + probably be better just using play_fli(). You can think of this function + as a wrapper on top of open_memory_fli(), next_fli_frame() and close_fli(). + Example: +

+      int ret = play_memory_fli(anim_data, screen, 0, NULL);
+      if (ret == FLI_ERROR)
+         abort_on_error("Corrupted animation data?");
+

Return value: + The FLI player returns FLI_OK if it reached the end of the file, FLI_ERROR + if something went wrong, and the value returned by the callback function if + that was what stopped it. + + +

See also: +play_fli, +install_timer, +fli_frame.
+
int open_fli(const char *filename);

+
int open_memory_fli(const void *fli_data);

+ Open FLI files ready for playing, reading the data from disk or memory + respectively. Information about the current FLI is held in the global + variables fli_bitmap and fli_palette, which you can use if this function + succeeds. However, you can only have one animation open at a time. + Example: +
+      if (open_fli("intro.fli") == FLI_ERROR)
+         abort_on_error("Error playing intro");
+

Return value: + Returns FLI_OK on success, FLI_ERROR if something went wrong, like trying + to open another FLI file without closing the previous one. + + +

See also: +close_fli, +next_fli_frame, +fli_bitmap, +fli_palette.
+
void close_fli();

+ Closes an FLI file when you have finished reading from it. Remember to do + this to avoid having memory leaks in your program. + + +
See also: +open_fli.
+
int next_fli_frame(int loop);

+ Reads the next frame of the current animation file. If `loop' is not zero, + the player will cycle when it reaches the end of the file, otherwise it + will return FLI_EOF. The frame is read into the global variables + fli_bitmap and fli_palette. Example: +
+      while (next_fli_frame(0) == FLI_OK) {
+         /* Do stuff, like play audio stream
+            or check keys to skip animation. */
+         /* Rest some time until next frame... */
+      }
+

Return value: + Returns FLI_OK on success, FLI_ERROR or FLI_NOT_OPEN on error, and FLI_EOF + on reaching the end of the file. + + +

See also: +open_fli, +fli_bitmap, +fli_palette, +fli_timer, +fli_frame.
+
extern BITMAP *fli_bitmap;

+ Contains the current frame of the FLI/FLC animation. If there is no open + animation, its value will be NULL. + + +
See also: +next_fli_frame, +fli_bmp_dirty_from, +fli_palette.
+
extern PALETTE fli_palette;

+ Contains the current FLI palette. + + +
See also: +next_fli_frame, +fli_pal_dirty_from, +fli_bitmap.
+
extern int fli_bmp_dirty_from;

+
extern int fli_bmp_dirty_to;

+ These variables are set by next_fli_frame() to indicate which part of the + fli_bitmap has changed since the last call to reset_fli_variables(). If + fli_bmp_dirty_from is greater than fli_bmp_dirty_to, the bitmap has not + changed, otherwise lines fli_bmp_dirty_from to fli_bmp_dirty_to + (inclusive) have altered. You can use these when copying the fli_bitmap + onto the screen, to avoid moving data unnecessarily. Example: +
+      if (fli_bmp_dirty_from <= fli_bmp_dirty_to)
+         blit(fli_bitmap, screen, 0, fli_bmp_dirty_from,
+              0, fli_bmp_dirty_from, fli_bitmap->w,
+              fli_bmp_dirty_to - fli_bmp_dirty_from + 1);
+ + +
See also: +fli_bitmap, +reset_fli_variables.
+
extern int fli_pal_dirty_from;

+
extern int fli_pal_dirty_to;

+ These variables are set by next_fli_frame() to indicate which part of the + fli_palette has changed since the last call to reset_fli_variables(). If + fli_pal_dirty_from is greater than fli_pal_dirty_to, the palette has not + changed, otherwise colors fli_pal_dirty_from to fli_pal_dirty_to + (inclusive) have altered. You can use these when updating the hardware + palette, to avoid unnecessary calls to set_palette(). Example: +
+      if (fli_pal_dirty_from <= fli_pal_dirty_to)
+         set_palette_range(fli_palette, fli_pal_dirty_from,
+                           fli_pal_dirty_to, 1);
+ + +
See also: +fli_palette, +reset_fli_variables.
+
void reset_fli_variables();

+ Once you have done whatever you are going to do with the fli_bitmap and + fli_palette, call this function to reset the fli_bmp_dirty_* and + fli_pal_dirty_* variables. + + +
See also: +fli_bmp_dirty_from, +fli_pal_dirty_from.
+
extern int fli_frame;

+ Global variable containing the current frame number in the FLI file. This + is useful for synchronising other events with the animation, for instance + you could check it in a play_fli() callback function and use it to + trigger a sample at a particular point. Example: +
+      while (next_fli_frame(0) == FLI_OK) {
+         if (fli_frame == 345)
+            play_sample(trumpet_sound, 255, 128, 1000, 0);
+         /* Rest some time until next frame... */
+      }
+ + +
See also: +play_fli, +play_memory_fli, +next_fli_frame.
+
extern volatile int fli_timer;

+ Global variable for timing FLI playback. When you open an FLI file, a + timer interrupt is installed which increments this variable every time a + new frame should be displayed. Calling next_fli_frame() decrements it, so + you can test it and know that it is time to display a new frame if it is + greater than zero. Example: +
+      while (next_fli_frame(0) == FLI_OK) {
+         /* Do stuff, like play audio stream
+            or check keys to skip animation. */
+         /* Rest some time until next frame... */
+         while (fli_timer <= 0)
+            rest(0);
+      }
+ + + + +
See also: +install_timer, +next_fli_frame.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg024.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg024.html new file mode 100644 index 0000000..ecbf0b2 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg024.html @@ -0,0 +1,276 @@ + + +Allegro Manual: Sound init routines + + + + +

Sound init routines

+ + + +

+Allegro allows you to use the sound hardware in two ways: automatic, or +manual. Usually you should try the automatic version first. This means +calling install_sound() with the autodetection parameters and using the rest +of the sound functions to play samples or music. In this situation, Allegro +will handle the sound devices and mix the samples and/or music the best way +it can. + +

+However, sound hardware has a limitation on the number of samples it may +play all at the same time (from now on, called hardware voices). When you +exceed this limit, Allegro will cut off one of the samples being played and +reproduce the new one. Depending on the type of sounds you are playing, how +many of them you need at the same time and their nature (e.g: vital audio +feedback to the user or useless "ping" when some shrapnel hits a rock in the +scenary) you will want to specify more carefully how hardware voices are +reserved and which samples have priority over others. + +

+The hardware voice reservation phase has to be done before the call to +install_sound(), since it directly affects how Allegro talks to the sound +drivers. + +


+

int detect_digi_driver(int driver_id);

+ Detects whether the specified digital sound device is available. This + function must be called _before_ install_sound(). +

Return value: + Returns the maximum number of voices that the driver can provide, or zero + if the hardware is not present. + + +

See also: +install_sound, +reserve_voices, +DIGI_*/DOS, +DIGI_*/Windows, +DIGI_*/Unix, +DIGI_*/BeOS, +DIGI_*/QNX, +DIGI_*/MacOSX.
+
int detect_midi_driver(int driver_id);

+ Detects whether the specified MIDI sound device is available. This function + must be called _before_ install_sound(). +

Return value: + Returns the maximum number of voices that the driver can provide, or zero + if the hardware is not present. + +

+ There are two special-case return values that you should watch out for: + if this function returns -1 it is a note-stealing driver (eg. DIGMID) that + shares voices with the current digital sound driver, and if it returns + 0xFFFF it is an external device like an MPU-401 where there is no way to + determine how many voices are available. + + +

See also: +install_sound, +reserve_voices, +MIDI_*/DOS, +MIDI_*/Windows, +MIDI_*/Unix, +MIDI_*/BeOS, +MIDI_*/QNX, +MIDI_*/MacOSX.
+
void reserve_voices(int digi_voices, int midi_voices);

+ Call this function to specify the number of voices that are to be used by + the digital and MIDI sound drivers respectively. This must be done + _before_ calling install_sound(). If you reserve too many voices, + subsequent calls to install_sound() will fail. How many voices are + available depends on the driver, and in some cases you will actually get + more than you reserve (eg. the FM synth drivers will always provide 9 + voices on an OPL2 and 18 on an OPL3, and the SB digital driver will round + the number of voices up to the nearest power of two). Pass negative + values to restore the default settings. You should be aware that the + sound quality is usually inversely related to how many voices you use, so + don't reserve any more than you really need. + + +
See also: +set_volume_per_voice, +install_sound, +detect_digi_driver, +detect_midi_driver, +get_mixer_voices.
+
void set_volume_per_voice(int scale);

+ By default, Allegro will play a centered sample at half volume on both + the left and right channel. A sample panned to the far right or left + will be played at maximum volume on that channel only. This is done so + you can play a single panned sample without distortion. If you play + multiple samples at full volume, the mixing process can result in + clipping, a noticeable form of distortion. The more samples, the more + likely clipping is to occur, and the more clipping, the worse the output + will sound. + +

+ If clipping is a problem - or if the output is too quiet - this function + can be used to adjust the volume of each voice. You should first check + that your speakers are at a reasonable volume, Allegro's global volume + is at maximum (see set_volume() below), and any other mixers such as the + Windows Volume Control are set reasonably. Once you are sure that + Allegro's output level is unsuitable for your application, use this + function to adjust it. + +

+ Each time you increase the parameter by one, the volume of each voice + will halve. For example, if you pass 4, you can play up to 16 centred + samples at maximum volume without distortion. + +

+ If you pass 0 to this function, each centred sample will play at the + maximum volume possible without distortion, as will all samples played + through a mono driver. Samples at the extreme left and right will distort + if played at full volume. If you wish to play panned samples at full + volume without distortion, you should pass 1 to this function. + Note: this is different from the function's behaviour in WIPs 3.9.34, + 3.9.35 and 3.9.36. If you used this function under one of these WIPs, + you will have to increase your parameter by one to get the same volume. + +

+ Note: The default behaviour has changed as of Allegro 4.1.15. If you + would like the behaviour of earlier versions of Allegro, pass -1 to this + function. Allegro will choose a value dependent on the number of voices, + so that if you reserve n voices, you can play up to n/2 normalised + samples with centre panning without risking distortion. The exception is + when you have fewer than 8 voices, where the volume remains the same as + for 8 voices. Here are the values, dependent on the number of voices: +

+     1-8 voices - set_volume_per_voice(2)
+      16 voices - set_volume_per_voice(3)
+      32 voices - set_volume_per_voice(4)
+      64 voices - set_volume_per_voice(5)
+
+ Of course this function does not override the volume you specify with + play_sample() or voice_set_volume(). It simply alters the overall output + of the program. If you play samples at lower volumes, or if they are not + normalised, then you can play more of them without distortion. + +

+ It is recommended that you hard-code the parameter into your program, + rather than offering it to the user. The user can alter the volume with + the configuration file instead, or you can provide for this with + set_volume(). + +

+ To restore volume per voice to its default behaviour, pass 1. + + +

See also: +reserve_voices, +set_volume, +install_sound, +detect_digi_driver, +detect_midi_driver.
+
int install_sound(int digi, int midi, const char *cfg_path);

+ Initialises the sound module. You should normally pass DIGI_AUTODETECT + and MIDI_AUTODETECT as the driver parameters to this function, in which + case Allegro will read hardware settings from the current configuration + file. This allows the user to select different values with the setup + utility: see the config section for details. Alternatively, see the + platform specific documentation for a list of the available drivers. The + cfg_path parameter is only present for compatibility with previous + versions of Allegro, and has no effect on anything. +

Return value: + Returns zero if the sound is successfully installed, and -1 on failure. + If it fails it will store a description of the problem in allegro_error. + + +

See also: +remove_sound, +reserve_voices, +detect_digi_driver, +detect_midi_driver, +set_volume, +play_sample, +Voice control, +play_midi, +play_audio_stream, +install_sound_input, +allegro_error, +Standard config variables, +set_mixer_quality, +DIGI_*/DOS, +DIGI_*/Windows, +DIGI_*/Unix, +DIGI_*/BeOS, +DIGI_*/QNX, +DIGI_*/MacOSX, +MIDI_*/DOS, +MIDI_*/Windows, +MIDI_*/Unix, +MIDI_*/BeOS, +MIDI_*/QNX, +MIDI_*/MacOSX.
+ +
Examples using this: +exmidi, +exsample, +exsprite, +exstream.
+
void remove_sound();

+ Cleans up after you are finished with the sound routines. You don't + normally need to call this, because allegro_exit() will do it for you. + + +
See also: +install_sound, +allegro_exit.
+
void set_volume(int digi_volume, int midi_volume);

+ Alters the global sound output volume. Specify volumes for both digital + samples and MIDI playback, as integers from 0 to 255, or pass a negative + value to leave one of the settings unchanged. Values bigger than 255 will + be reduced to 255. This routine will not alter the volume of the hardware + mixer if it exists (i.e. only your application will be affected). + + +
See also: +install_sound, +set_hardware_volume.
+
void set_hardware_volume(int digi_volume, int midi_volume);

+ Alters the hardware sound output volume. Specify volumes for both digital + samples and MIDI playback, as integers from 0 to 255, or pass a negative + value to leave one of the settings unchanged. Values bigger than 255 will + be reduced to 255. This routine will use the hardware mixer to control the + volume if it exists (i.e. the volume of all the applications on your + machine will be affected), otherwise do nothing. + + +
See also: +install_sound, +set_volume.
+
void get_volume(int *digi_volume, int *midi_volume);

+ Retrieves the global sound output volume, both for digital samples and MIDI + playback, as integers from 0 to 255. Parameters digi_volume and midi_volume + must be valid pointers to int, or NULL if not interested in specific value. + + +
See also: +set_volume, +get_hardware_volume.
+
void get_hardware_volume(int *digi_volume, int *midi_volume);

+ Retrieves the hardware sound output volume, both for digital samples and MIDI + playback, as integers from 0 to 255, or -1 if the information is not + available. Parameters digi_volume and midi_volume must be valid pointers to + int, or NULL if not interested in specific value. + + +
See also: +set_hardware_volume, +get_volume.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg025.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg025.html new file mode 100644 index 0000000..0d99f7e --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg025.html @@ -0,0 +1,77 @@ + + +Allegro Manual: Mixer routines + + + + +

Mixer routines

+ + + + + +


+

void set_mixer_quality(int quality);

+ Sets the resampling quality of the mixer. Valid values are the same as + the `quality' config variable. Please read chapter "Standard config + variables" for details. You can call this function at any point in your + program, even before allegro_init(). + + +
See also: +get_mixer_quality, +Standard config variables.
+
int get_mixer_quality(void);

+ Returns the current mixing quality, as specified by the `quality' config + variable, or a previous call to set_mixer_quality(). + + +
See also: +set_mixer_quality, +Standard config variables.
+
int get_mixer_frequency(void);

+ Returns the mixer frequency, in Hz. + + +
See also: +Standard config variables.
+
int get_mixer_bits(void);

+ Returns the mixer bitdepth (8 or 16). + + +
See also: +Standard config variables.
+
int get_mixer_channels(void);

+ Returns the number of output channels. 2 for stereo, 1 for mono, 0 if + the mixer isn't active. + + +
See also: +Standard config variables.
+
int get_mixer_voices(void);

+ Returns the number of voices allocated to the mixer. + + +
See also: +reserve_voices.
+
int get_mixer_buffer_length(void);

+ Returns the number of samples per channel in the mixer buffer. + + + + +
See also: +Standard config variables.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg026.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg026.html new file mode 100644 index 0000000..66a119b --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg026.html @@ -0,0 +1,545 @@ + + +Allegro Manual: Digital sample routines + + + + +

Digital sample routines

+ + + +


+

SAMPLE *load_sample(const char *filename);

+ Loads a sample from a file, supporting both mono and stereo WAV and mono + VOC files, in 8 or 16-bit formats, as well as formats handled by functions + registered using register_sample_file_type(). Example: +
+      SAMPLE *sample = load_sample(user_input);
+      if (!sample)
+         abort_on_error("Couldn't load sample!");
+

Return value: + Returns a pointer to the SAMPLE or NULL on error. Remember to free this + sample later to avoid memory leaks. + + +

See also: +destroy_sample, +load_voc, +load_wav, +play_sample, +save_sample, +register_sample_file_type, +Voice control.
+ +
Examples using this: +exsample.
+
SAMPLE *load_wav(const char *filename);

+ Loads a sample from a RIFF WAV file. Example: +
+      SAMPLE *sample = load_wav("scream.wav");
+      if (!sample)
+         abort_on_error("Couldn't scare user!");
+

Return value: + Returns a pointer to the SAMPLE or NULL on error. Remember to free this + sample later to avoid memory leaks. + + +

See also: +load_sample, +register_sample_file_type.
+
SAMPLE *load_wav_pf(PACKFILE *f);

+ A version of load_wav() which reads from a packfile. Example: +
+      PACKFILE *packfile;
+      SAMPLE *sample;
+   
+      packfile = pack_fopen("sound.wav", F_READ);
+      if (!packfile)
+         abort_on_error("Couldn't open sound.wav");
+   
+      sample = load_wav_pf(packfile);
+      if (!sample)
+         abort_on_error("Error loading sound.wav");
+

Return value: + Returns a pointer to the SAMPLE or NULL on error. Remember to free this + sample later to avoid memory leaks. + + +

See also: +load_wav.
+
SAMPLE *load_voc(const char *filename);

+ Loads a sample from a Creative Labs VOC file. Example: +
+      SAMPLE *sample = load_wav("alarm.wav");
+      if (!sample)
+         abort_on_error("Couldn't alert user!");
+

Return value: + Returns a pointer to the SAMPLE or NULL on error. Remember to free this + sample later to avoid memory leaks. + + +

See also: +load_sample, +register_sample_file_type.
+
SAMPLE *load_voc_pf(PACKFILE *f);

+ A version of load_voc() which reads from a packfile. Example: +
+      PACKFILE *packfile;
+      SAMPLE *sample;
+   
+      packfile = pack_fopen("sound.wav", F_READ);
+      if (!packfile)
+         abort_on_error("Couldn't open sound.wav");
+   
+      sample = load_wav_pf(packfile);
+      if (!sample)
+         abort_on_error("Error loading sound.wav");
+

Return value: + Returns a pointer to the SAMPLE or NULL on error. Remember to free this + sample later to avoid memory leaks. + + +

See also: +load_voc.
+
int save_sample(const char *filename, SAMPLE *spl);

+ Writes a sample into a file. The output format is determined from the + filename extension. At present Allegro does not natively support the + writing of any sample formats, so you must register a custom saver routine + with register_sample_file_type(). Example: +
+      if (save_sample("sound.wav", sample) != 0)
+         abort_on_error("Couldn't save sample!");
+

Return value: + Returns zero on success, non-zero otherwise. + + +

See also: +load_sample, +register_sample_file_type.
+
SAMPLE *create_sample(int bits, int stereo, int freq, int len);

+ Constructs a new sample structure of the specified type. Read chapter + "Structures and types defined by Allegro" for an internal description of + the SAMPLE structure. The `bits' parameter can be 8 or 16, `stereo' can be + zero for mono samples and non-zero for stereo samples, `freq' is the + frequency in hertz, and `len' is the number of samples you want to allocate + for the full sound buffer. +

Return value: + Returns a pointer to the created sample, or NULL if the sample could not + be created. Remember to free this sample later to avoid memory leaks. + + +

See also: +load_sample, +destroy_sample, +Structures and types defined by Allegro.
+
void destroy_sample(SAMPLE *spl);

+ Destroys a sample structure when you are done with it. It is safe to call + this even when the sample might be playing, because it checks and will + kill it off if it is active. Use this to avoid memory leaks in your + program. + + +
See also: +load_sample.
+ +
Examples using this: +exsample.
+
void lock_sample(SAMPLE *spl);

+ Under DOS, locks all the memory used by a sample. You don't normally need + to call this function because load_sample() and create_sample() do it for + you. + + +
See also: +load_sample, +create_sample.
+
void register_sample_file_type(const char *ext, + SAMPLE *(*load)(const char *filename), + int (*save)(const char *filename, SAMPLE *spl));

+ Informs the load_sample() function of a new sample file type, + providing routines to read and write samples in this format (either + function may be NULL). Example: +
+      SAMPLE *load_mp3(const char *filename)
+      {
+         ...
+      }
+      
+         register_sample_file_type("mp3", load_mp3, NULL);
+ + +
See also: +load_sample, +save_sample.
+
int play_sample(const SAMPLE *spl, int vol, int pan, int freq, int loop);

+ Triggers a sample at the specified volume, pan position, and frequency. + The parameters `vol' and `pan' range from 0 (min/left) to 255 (max/right). + Frequency is relative rather than absolute: 1000 represents the frequency + that the sample was recorded at, 2000 is twice this, etc. If `loop' is not + zero, the sample will repeat until you call stop_sample(), and can be + manipulated while it is playing by calling adjust_sample(). Example: +
+      /* Scream from the left speaker, twice the freq. */
+      int sound = play_sample(scream, 255, 0, 2000, 0);
+

Return value: + Returns the voice number that was allocated for the sample or negative if + no voices were available. + + +

See also: +install_sound, +load_sample, +adjust_sample, +stop_sample, +Voice control.
+ +
Examples using this: +exsample, +exsprite.
+
void adjust_sample(const SAMPLE *spl, int vol, int pan, int freq, int loop);

+ Alters the parameters of a sample while it is playing (useful for + manipulating looped sounds). You can alter the volume, pan, and frequency, + and can also clear the loop flag, which will stop the sample when it next + reaches the end of its loop. The values of the parameters are just like + those of play_sample(). If there are several copies of the same sample + playing, this will adjust the first one it comes across. If the sample is + not playing it has no effect. + + +
See also: +play_sample.
+ +
Examples using this: +exsample.
+
void stop_sample(const SAMPLE *spl);

+ Kills off a sample, which is required if you have set a sample going in + looped mode. If there are several copies of the sample playing, it will + stop them all. + + +
See also: +play_sample.
+

Voice control

+If you need more detailed control over how samples are played, you can use +the lower level voice functions rather than just calling play_sample(). This +is rather more work, because you have to explicitly allocate and free the +voices rather than them being automatically released when they finish +playing, but allows far more precise specification of exactly how you want +everything to sound. You may also want to modify a couple of fields from the +SAMPLE structure. Read chapter "Structures and types defined by Allegro" for +its definition. + + +

See also: +install_sound, +allocate_voice, +deallocate_voice, +reallocate_voice, +release_voice, +voice_start, +voice_set_priority, +voice_check, +voice_set_position, +voice_set_playmode, +voice_set_volume, +voice_set_frequency, +voice_set_pan, +SAMPLE.
+
int allocate_voice(const SAMPLE *spl);

+ Allocates a soundcard voice and prepares it for playing the specified + sample, setting up sensible default parameters (maximum volume, centre + pan, no change of pitch, no looping). When you are finished with the + voice you must free it by calling deallocate_voice() or release_voice(). + Allegro can manage up to 256 simultaneous voices, but that limit may be + lower due to hardware reasons. +

Return value: + Returns the voice number, or -1 if no voices are available. + + +

See also: +Voice control, +deallocate_voice, +reallocate_voice, +release_voice, +load_sample.
+
void deallocate_voice(int voice);

+ Frees a soundcard voice, stopping it from playing and releasing whatever + resources it is using. + + +
See also: +allocate_voice, +voice_stop.
+
void reallocate_voice(int voice, const SAMPLE *spl);

+ Switches an already-allocated voice to use a different sample. Calling + reallocate_voice(voice, sample) is equivalent to: +
+      deallocate_voice(voice);
+      voice = allocate_voice(sample);
+ + +
See also: +allocate_voice, +deallocate_voice, +load_sample.
+
void release_voice(int voice);

+ Releases a soundcard voice, indicating that you are no longer interested + in manipulating it. The sound will continue to play, and any resources + that it is using will automatically be freed when it finishes. This is + essentially the same as deallocate_voice(), but it waits for the sound to + stop playing before taking effect. + + +
See also: +allocate_voice, +deallocate_voice.
+
void voice_start(int voice);

+ Activates a voice, using whatever parameters have been set for it. + + +
See also: +Voice control, +allocate_voice, +voice_stop, +release_voice.
+ +
Examples using this: +exstream.
+
void voice_stop(int voice);

+ Stops a voice, storing the current position and state so that it may + later be resumed by calling voice_start(). + + +
See also: +voice_start, +deallocate_voice, +release_voice.
+ +
Examples using this: +exstream.
+
void voice_set_priority(int voice, int priority);

+ Sets the priority of a voice (range 0-255). This is used to decide which + voices should be chopped off, if you attempt to play more than the + soundcard driver can handle. + + +
See also: +Voice control.
+
SAMPLE *voice_check(int voice);

+ Checks whether a voice is currently allocated. +

Return value: + Returns a pointer to the sample that the voice is using, or NULL if the + voice is inactive (ie. it has been deallocated, or the release_voice() + function has been called and the sample has then finished playing). + + +

See also: +allocate_voice, +voice_start, +voice_get_position.
+
int voice_get_position(int voice);

+ Returns the current position of a voice, in sample units, or -1 if it has + finished playing. + + +
See also: +Voice control, +voice_set_position.
+
void voice_set_position(int voice, int position);

+ Sets the position of a voice, in sample units. + + +
See also: +Voice control, +voice_get_position, +voice_set_playmode.
+
void voice_set_playmode(int voice, int playmode);

+ Adjusts the loop status of the specified voice. This can be done while + the voice is playing, so you can start a sample in looped mode (having + set the loop start and end positions to the appropriate values), and then + clear the loop flag when you want to end the sound, which will cause it + to continue past the loop end, play the subsequent part of the sample, + and finish in the normal way. The mode parameter is a bitfield containing + the following values: + + +
See also: +Voice control.
+
int voice_get_volume(int voice);

+ Returns the current volume of the voice, range 0-255. Otherwise it + returns -1 if that cannot be determined (because it has finished or + been preempted by a different sound). + + +
See also: +Voice control, +voice_set_volume.
+
void voice_set_volume(int voice, int volume);

+ Sets the volume of the voice, range 0-255. + + +
See also: +Voice control, +voice_get_volume, +voice_ramp_volume.
+
void voice_ramp_volume(int voice, int time, int endvol);

+ Starts a volume ramp (crescendo or diminuendo) from the current volume to + the specified ending volume, lasting for time milliseconds. The volume is + a value in the range 0-255. + + +
See also: +Voice control, +voice_set_volume.
+
void voice_stop_volumeramp(int voice);

+ Interrupts a volume ramp operation. + + +
See also: +voice_ramp_volume.
+
int voice_get_frequency(int voice);

+ Returns the current pitch of the voice, in Hz. + + +
See also: +Voice control, +voice_set_frequency.
+
void voice_set_frequency(int voice, int frequency);

+ Sets the pitch of the voice, in Hz. + + +
See also: +Voice control, +voice_get_frequency, +voice_sweep_frequency.
+
void voice_sweep_frequency(int voice, int time, int endfreq);

+ Starts a frequency sweep (glissando) from the current pitch to the + specified ending pitch, lasting for time milliseconds. + + +
See also: +Voice control, +voice_set_frequency.
+
void voice_stop_frequency_sweep(int voice);

+ Interrupts a frequency sweep operation. + + +
See also: +voice_sweep_frequency.
+
int voice_get_pan(int voice);

+ Returns the current pan position, from 0 (left) to 255 (right). + + +
See also: +Voice control, +voice_set_pan.
+
void voice_set_pan(int voice, int pan);

+ Sets the pan position, ranging from 0 (left) to 255 (right). + + +
See also: +Voice control, +voice_get_pan, +voice_sweep_pan.
+
void voice_sweep_pan(int voice, int time, int endpan);

+ Starts a pan sweep (left <-> right movement) from the current position to + the specified ending position, lasting for time milliseconds. + + +
See also: +Voice control, +voice_set_pan.
+
void voice_stop_pan_sweep(int voice);

+ Interrupts a pan sweep operation. + + +
See also: +voice_sweep_pan.
+
void voice_set_echo(int voice, int strength, int delay);

+ Sets the echo parameters for a voice (not currently implemented). + + +
See also: +Voice control.
+
void voice_set_tremolo(int voice, int rate, int depth);

+ Sets the tremolo parameters for a voice (not currently implemented). + + +
See also: +Voice control.
+
void voice_set_vibrato(int voice, int rate, int depth);

+ Sets the vibrato parameters for a voice (not currently implemented). + + + + +
See also: +Voice control.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg027.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg027.html new file mode 100644 index 0000000..ed44672 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg027.html @@ -0,0 +1,308 @@ + + +Allegro Manual: Music routines (MIDI) + + + + +

Music routines (MIDI)

+ + + +

+Allegro allows you to play MIDI files. MIDI files basically contain notes and +the type of instrument that is meant to play them, so they are usually very +small in size. However, it's up to the soundcard of the end user to play the +notes, and soundcards have been historically known to have poor MIDI +performance (at least those oriented to the consumer market). Few consumer +cards feature decent MIDI playback. Still, as a game creator you can never be +sure if the music of your game will be played as you meant it, because it +totally depends on the hardware of the user. + +

+For this reason Allegro also provides a DIGMID driver. This is a software +implementation of the so called Wavetable synthesis. Soundcards featuring this +store digital samples of real instruments at different pitches, interpolating +those that are not recorded, thus achieving a high sound quality. Implementing +this in software makes you sure that the quality you hear on your computer is +that which will be heard by end users using the same driver. + +

+The disadvantage of the DIGMID driver is that it uses more CPU than simple +MIDI playback, and it steals some hardware voices from the soundcard, which +might be more critical for the end user experience than the background music. +At the Allegro homepage (http://alleg.sourceforge.net/) you can find more +information about DIGMID and where to download digital samples for your MIDI +files. + +


+

MIDI *load_midi(const char *filename);

+ Loads a MIDI file (handles both format 0 and format 1). Example: +
+      MIDI *music;
+      music = load_midi("backmus.mid");
+      if (!music)
+         abort_on_error("Couldn't load background music!");
+

Return value: + Returns a pointer to a MIDI structure, or NULL on error. Remember to free + this MIDI file later to avoid memory leaks. + + +

See also: +destroy_midi, +play_midi, +get_midi_length.
+ +
Examples using this: +exmidi.
+
void destroy_midi(MIDI *midi);

+ Destroys a MIDI structure when you are done with it. It is safe to call + this even when the MIDI file might be playing, because it checks and will + kill it off if it is active. Use this to avoid memory leaks in your + program. + + +
See also: +load_midi.
+ +
Examples using this: +exmidi.
+
void lock_midi(MIDI *midi);

+ Under DOS, locks all the memory used by a MIDI file. You don't normally + need to call this function because load_midi() does it for you. + + +
See also: +load_midi.
+
int play_midi(MIDI *midi, int loop);

+ Starts playing the specified MIDI file, first stopping whatever music was + previously playing. If the loop flag is set to non-zero, the data will be + repeated until replaced with something else, otherwise it will stop at the + end of the file. Passing a NULL pointer will stop whatever music is + currently playing. +

Return value: + Returns non-zero if an error occurs (this may happen if a patch-caching + wavetable driver is unable to load the required samples, or at least it + might in the future when somebody writes some patch-caching wavetable + drivers :-) + + +

See also: +install_sound, +load_midi, +play_looped_midi, +stop_midi, +midi_pause, +midi_seek, +midi_pos, +midi_time, +midi_msg_callback.
+ +
Examples using this: +exmidi.
+
int play_looped_midi(MIDI *midi, int loop_start, int loop_end);

+ Starts playing a MIDI file with a user-defined loop position. When the + player reaches the loop end position or the end of the file (loop_end may + be -1 to only loop at EOF), it will wind back to the loop start point. + Both positions are specified in the same beat number format as the + midi_pos variable. +

Return value: + The return value has the same meaning as that of play_midi(): non-zero if + an error occurs, zero otherwise. + + +

See also: +play_midi, +midi_pos, +midi_loop_start.
+
void stop_midi();

+ Stops whatever music is currently playing. This is the same thing as + calling play_midi(NULL, FALSE). + + +
See also: +play_midi, +midi_pause.
+
void midi_pause();

+ Pauses the MIDI player. + + +
See also: +play_midi, +stop_midi, +midi_resume, +midi_seek.
+ +
Examples using this: +exmidi.
+
void midi_resume();

+ Resumes playback of a paused MIDI file. + + +
See also: +midi_pause.
+ +
Examples using this: +exmidi.
+
int midi_seek(int target);

+ Seeks to the given midi_pos in the current MIDI file. If the target is + earlier in the file than the current midi_pos it seeks from the + beginning; otherwise it seeks from the current position. +

Return value: + Returns zero if it could successfully seek to the requested position. + Otherwise, a return value of 1 means it stopped playing, and midi_pos is + set to the negative length of the MIDI file (so you can use this function + to determine the length of a MIDI file). A return value of 2 means the + MIDI file looped back to the start. + + +

See also: +play_midi, +midi_pos.
+
int get_midi_length(MIDI *midi);

+ This function will simulate playing the given MIDI, from start to end, to + determine how long it takes to play. After calling this function, midi_pos + will contain the negative number of beats, and midi_time the length of the + midi, in seconds. + +

+ Note that any currently playing midi is stopped when you call this function. + Usually you would call it before play_midi, to get the length of the midi to + be played, like in this example: +

+      length = get_midi_length(my_midi);
+      play_midi(my_midi);
+      do {
+         pos = midi_time;
+         textprintf_ex(screen, font, 0, 0, c, -1, "%d:%02d / %d:%02d\n",
+            pos / 60, pos % 60, length / 60, length % 60);
+         rest(100);
+      } while(pos <= length);
+

Return value: + Returns the value of midi_time, the length of the midi. + + +

See also: +load_midi, +midi_time, +midi_pos.
+ +
Examples using this: +exmidi.
+
void midi_out(unsigned char *data, int length);

+ Streams a block of MIDI commands into the player in realtime, allowing + you to trigger notes, jingles, etc, over the top of whatever MIDI file is + currently playing. + + +
See also: +install_sound, +load_midi_patches, +midi_recorder.
+
int load_midi_patches();

+ Forces the MIDI driver to load the entire set of patches ready for use. + You will not normally need to call this, because Allegro automatically + loads whatever data is required for the current MIDI file, but you must + call it before sending any program change messages via the midi_out() + command. +

Return value: + Returns non-zero if an error occurred. + + +

See also: +install_sound, +midi_out.
+
extern volatile long midi_pos;

+ Stores the current position (beat number) in the MIDI file, or contains + a negative number if no music is currently playing. Useful for + synchronising animations with the music, and for checking whether a MIDI + file has finished playing. + + +
See also: +play_midi, +midi_msg_callback.
+ +
Examples using this: +exmidi.
+
extern volatile long midi_time;

+ Contains the position in seconds in the currently playing midi. This is + useful if you want to display the current song position in seconds, not as + beat number. + + +
See also: +play_midi, +midi_pos, +get_midi_length.
+ +
Examples using this: +exmidi.
+
extern long midi_loop_start;

+
extern long midi_loop_end;

+ The loop start and end points, set by the play_looped_midi() function. + These may safely be altered while the music is playing, but you should be + sure they are always set to sensible values (start < end). If you are + changing them both at the same time, make sure to alter them in the right + order in case a MIDI interrupt happens to occur in between your two + writes! Setting these values to -1 represents the start and end of the + file respectively. + + +
See also: +play_looped_midi.
+
extern void (*midi_msg_callback)(int msg, int byte1, int byte2);

+
extern void (*midi_meta_callback)(int type, const unsigned char *data, int length);

+
extern void (*midi_sysex_callback)(const unsigned char *data, int length);

+ Hook functions allowing you to intercept MIDI player events. If set to + anything other than NULL, these routines will be called for each MIDI + message, meta-event, and system exclusive data block respectively. They + will execute in an interrupt handler context, so all the code and data + they use should be locked, and they must not call any operating system + functions. In general you just use these routines to set some flags and + respond to them later in your mainline code. + + +
See also: +play_midi.
+
int load_ibk(char *filename, int drums);

+ Reads in a .IBK patch definition file for use by the Adlib driver. If + drums is set, it will load it as a percussion patch set, otherwise it + will use it as a replacement set of General MIDI instruments. You may + call this before or after initialising the sound code, or can simply set + the ibk_file and ibk_drum_file variables in the configuration file to + have the data loaded automatically. Note that this function has no effect + on any drivers other than the Adlib one! +

Return value: + Returns non-zero on error. + + + + +

See also: +install_sound.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg028.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg028.html new file mode 100644 index 0000000..560241d --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg028.html @@ -0,0 +1,146 @@ + + +Allegro Manual: Audio stream routines + + + + +

Audio stream routines

+ + + +

+The audio stream functions are for playing digital sounds that are too big +to fit in a regular SAMPLE structure, either because they are huge files +that you want to load in pieces as the data is required, or because you are +doing something clever like generating the waveform on the fly. + +

+You can think of an AUDIOSTREAM structure as a wrapper around two audio +buffers. The first thing you do is fill both buffers with sound data and let +Allegro play them. Once the first buffer has been played, the second starts, +and Allegro lets you know you have to fill the other one (i.e. graphics +double buffering applied to sounds too big to fit into memory). + +

+The implementation of the sound buffers uses normal SAMPLE structures, so you +can use all the voice_*() functions to modify the audio streams. Read chapter +"Digital sample routines", section "Voice control" for a list of additional +functions you can use. Read chapter "Structures and types defined by Allegro" +for the internals of the AUDIOSTREAM structure. + +


+

AUDIOSTREAM *play_audio_stream(int len, int bits, int stereo, + int freq, int vol, int pan);

+ This function creates a new audio stream and starts playing it. The + length is the size of each transfer buffer in sample frames (not bytes), + where a sample frame is a single sample value for mono data or a pair of + interleaved sample values (left first) for stereo data. The length should + normally be (but doesn't have to be) a power of 2 somewhere around 1k in + size. Larger buffers are more efficient and require fewer updates, but + result in more latency between you providing the data and it actually + being played. + +

+ The `bits' parameter must be 8 or 16. `freq' is the sample rate of the + data in Hertz. The `vol' and `pan' values use the same 0-255 ranges as the + regular sample playing functions. The `stereo' parameter should be set to + 1 for stereo streams, or 0 otherwise. + +

+ If you want to adjust the pitch, volume, or panning of a stream once it is + playing, you can use the regular voice_*() functions with stream->voice + as a parameter. The format of the sample data is described in the SAMPLE + entry of the "Structures and types defined by Allegro" chapter. The formula + to get the size of the buffers in bytes could be: +

+      bytes = length * (bits / 8) * (stereo ? 2 : 1)
+ Example: +
+      /* Create a 22KHz 8bit mono audio stream. */
+      stream = play_audio_stream(1024, 8, FALSE, 22050, 255, 128);
+      if (!stream)
+         abort_on_error("Error creating audio stream!\n");
+

Return value: + This function returns a pointer to the audio stream or NULL if it could + not be created. + + +

See also: +install_sound, +get_audio_stream_buffer, +stop_audio_stream, +AUDIOSTREAM, +Voice control.
+ +
Examples using this: +exstream.
+
void stop_audio_stream(AUDIOSTREAM *stream);

+ Destroys an audio stream when it is no longer required. + + +
See also: +play_audio_stream.
+ +
Examples using this: +exstream.
+
void *get_audio_stream_buffer(AUDIOSTREAM *stream);

+ You must call this function at regular intervals while an audio stream is + playing, to provide the next buffer of sample data (the smaller the + stream buffer size, the more often it must be called). This function should + not be called from a timer handler. Example: +
+      void *mem_chunk;
+      ...
+      while (TRUE) {
+         ...
+         mem_chunk = get_audio_stream_buffer(buffer);
+         if (mem_chunk != NULL) {
+            /* Refill the stream buffer. */
+         }
+      }
+

Return value: + If it returns NULL, the stream is still playing the previous lot of data, + so you don't need to do anything. If it returns a value, that is the + location of the next buffer to be played, and you should load the + appropriate number of samples (however many you specified when creating the + stream) to that address, for example using an fread() from a disk file. + After filling the buffer with data, call free_audio_stream_buffer() to + indicate that the new data is now valid. + + +

See also: +play_audio_stream, +free_audio_stream_buffer.
+ +
Examples using this: +exstream.
+
void free_audio_stream_buffer(AUDIOSTREAM *stream);

+ Call this function after get_audio_stream_buffer() returns a non-NULL + address, to indicate that you have loaded a new block of samples to that + location and the data is now ready to be played. Example: +
+      mem_chunk = get_audio_stream_buffer(buffer);
+      if (mem_chunk != NULL) {
+         /* Refill the stream buffer. */
+         ...
+         free_audio_stream_buffer(buffer);
+      }
+ + + + +
See also: +get_audio_stream_buffer.
+ +
Examples using this: +exstream.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg029.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg029.html new file mode 100644 index 0000000..1a06996 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg029.html @@ -0,0 +1,250 @@ + + +Allegro Manual: Recording routines + + + + +

Recording routines

+ + + +

+Allegro provides routines to capture sound from the soundcard, be it digital +samples or MIDI notes. Ideally this would allow you to create games where +basic speech recognition could be implemented, or voice messages in +multiplayer games over a network. However, many old sound cards are not full +duplex. This means, that the sound device can only be playing or recording, +but not both at the same time. + +

+Any Windows 2000 or better machine comes with a full duplex soundcard and +updated drivers. All MacOS X machines allow full duplex recording. Under Unix +your mileage may vary: you can have the right hardware for the task, but the +drivers might not support this feature. Under DOS you should forget about full +duplex altogether. + +

+To find out if your system allows this feature, use the akaitest program, +distributed along with Allegro, in the `tests' directory. + +


+

int install_sound_input(int digi, int midi);

+ Initialises the sound recorder module. You must install the normal sound + playback system before calling this routine. The two card parameters should + use the same constants as install_sound(), including DIGI_NONE and + MIDI_NONE to disable parts of the module, or DIGI_AUTODETECT and + MIDI_AUTODETECT to guess the hardware. +

Return value: + This function returns zero on success, and any other value if the machine + or driver doesn't support sound recording. + + +

See also: +install_sound, +start_sound_input, +midi_recorder, +Standard config variables, +DIGI_*/DOS, +DIGI_*/Windows, +DIGI_*/Unix, +DIGI_*/BeOS, +DIGI_*/QNX, +DIGI_*/MacOSX, +MIDI_*/DOS, +MIDI_*/Windows, +MIDI_*/Unix, +MIDI_*/BeOS, +MIDI_*/QNX, +MIDI_*/MacOSX.
+
void remove_sound_input();

+ Cleans up after you are finished with the sound input routines. You don't + normally need to call this, because remove_sound() and/or allegro_exit() + will do it for you. + + +
See also: +install_sound_input, +remove_sound, +allegro_exit.
+
int get_sound_input_cap_bits();

+ Checks which sample formats are supported by the current audio input + driver, returning one of the bitfield values: +
+      0 = audio input not supported
+      8 = eight bit audio input is supported
+      16 = sixteen bit audio input is supported
+      24 = both eight and sixteen bit audio input are supported
+ Example: +
+      cap = get_sound_input_cap_bits();
+      if (cap == 0) {
+         /* Ugh, no audio input supported? */
+      } else {
+         if (cap & 8) {
+            /* We have eight bit audio input. */
+         }
+         if (cap & 16) {
+            /* We have sixteen bit audio input. */
+         }
+      }
+ + +
See also: +start_sound_input, +get_sound_input_cap_parm, +get_sound_input_cap_rate, +get_sound_input_cap_stereo.
+
int get_sound_input_cap_stereo();

+ Checks whether the current audio input driver is capable of stereo + recording. +

Return value: + Returns non-zero if the driver is capable of stereo recording. + + +

See also: +start_sound_input, +get_sound_input_cap_parm, +get_sound_input_cap_bits, +get_sound_input_cap_rate.
+
int get_sound_input_cap_rate(int bits, int stereo);

+ Returns the maximum possible sample frequency for recording in the + specified format, or zero if these settings are not supported. The bits + parameter is the number of bits of the audio, and stereo is a boolean + parameter. Pass zero for mono, non-zero for stereo input. Example: +
+      int max_freq;
+      ...
+      /* What frequency can we record 8 bits mono at? */
+      max_freq = get_sound_input_cap_rate(8, 0);
+      if (max_freq > 22000) {
+         /* Ok, 22KHz and above is good enough. */
+      }
+ + +
See also: +start_sound_input, +get_sound_input_cap_parm, +get_sound_input_cap_bits, +get_sound_input_cap_stereo.
+
int get_sound_input_cap_parm(int rate, int bits, int stereo);

+ Checks whether the specified recording frequency, number of bits, and + mono/stereo mode are supported (and how) by the current audio driver. +

Return value: + The function returns one of the following possible values: +

+      0  = It is impossible to record in this format.
+      1  = Recording is possible, but audio output
+           will be suspended.
+      2  = Recording is possible at the same time as
+           playing other sounds (full duplex soundcard).
+      -n = Sampling rate not supported, but rate 'n'
+           would work instead.
+ + +
See also: +start_sound_input, +get_sound_input_cap_bits, +get_sound_input_cap_rate, +get_sound_input_cap_stereo.
+
int set_sound_input_source(int source);

+ Selects the audio input source. The parameter should be one of the values: +
+      SOUND_INPUT_MIC
+      SOUND_INPUT_LINE
+      SOUND_INPUT_CD
+

Return value: + The function returns zero on success, or -1 if the hardware does not + provide an input select register (ie. you have no control over the input + source). + + +

See also: +start_sound_input.
+
int start_sound_input(int rate, int bits, int stereo);

+ Starts recording in the specified format, suspending audio playback as + necessary if the card is not full duplex. +

Return value: + Returns the buffer size in bytes if successful, or zero on error. + + +

See also: +install_sound_input, +read_sound_input, +stop_sound_input, +digi_recorder, +set_sound_input_source, +get_sound_input_cap_parm, +get_sound_input_cap_bits, +get_sound_input_cap_rate, +get_sound_input_cap_stereo.
+
void stop_sound_input();

+ Stops audio recording, switching the card back into the normal playback + mode. + + +
See also: +start_sound_input.
+
int read_sound_input(void *buffer);

+ Retrieves the most recently recorded audio buffer into the specified + location. The buffer size can be obtained by checking the return value + from start_sound_input(). You must be sure to call this + function at regular intervals during the recording (typically around 100 + times a second), or some data will be lost. If you are unable to do this + often enough from the mainline code, use the digi_recorder() callback to + store the waveform into a larger buffer of your own. + +

+ Note: many cards produce a click or popping sound when switching between + record and playback modes, so it is often a good idea to discard the + first buffer after you start a recording. The waveform is always stored + in unsigned format, with stereo data consisting of alternate left/right + samples. +

Return value: + The function will return non-zero if a buffer has been copied or zero if + no new data is yet available (you were too fast checking the input). + + +

See also: +start_sound_input.
+
extern void (*digi_recorder)();

+ If set, this function is called by the input driver whenever a new sample + buffer becomes available, at which point you can use read_sound_input() + to copy the data into a more permanent location. It runs in an interrupt + context, so it must execute very quickly, the code and all memory that it + touches must be locked, and you cannot call any operating system routines + or access disk files. This currently works only under DOS. + + +
See also: +install_sound_input, +start_sound_input.
+
extern void (*midi_recorder)(unsigned char data);

+ If set, this function is called by the MIDI input driver whenever a new + byte of MIDI data becomes available. It runs in an interrupt context, so + it must execute very quickly and all the code/data must be locked. This + currently works only under DOS and Windows. + + + + +
See also: +install_sound_input, +midi_out.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg030.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg030.html new file mode 100644 index 0000000..09a999b --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg030.html @@ -0,0 +1,1055 @@ + + +Allegro Manual: File and compression routines + + + + +

File and compression routines

+ + + +

+The following routines implement a fast buffered file I/O system, which +supports the reading and writing of compressed files using a ring buffer +algorithm based on the LZSS compressor by Haruhiko Okumura. This does not +achieve quite such good compression as programs like zip and lha, but +unpacking is very fast and it does not require much memory. Packed files +always begin with the 32-bit value F_PACK_MAGIC, and autodetect files with +the value F_NOPACK_MAGIC. + +

+The following FA_* flags are guaranteed to work: +

+      FA_NONE           - Exclude files that have any attribute set
+      FA_RDONLY         - Directory entries that are unwritable for current user
+      FA_HIDDEN         - Hidden flag
+      FA_DIREC          - Directories
+      FA_SYSTEM         - Files with system flag set (DOS/Windows only)
+      FA_LABEL          - Files with volume label flag set (DOS/Windows only)
+      FA_ARCH           - Files with archive flag set (DOS/Windows only)
+      FA_ALL            - Match all attributes
+Do not use any other flags from DOS/Windows or your code will not compile on +another platform. +FA_RDONLY is for directory entries with read-only flag on DOS-like systems or +unwritable by current user on Unix-like systems. Hidden files are directory +entries that have the hidden flag set (DOS/Windows) or have names starting with +'.' (UNIX, excluding '.' and '..'). +Flags can be combined using '|' (binary OR operator). + +

+When passed to the functions as the 'attrib' parameter, these flags +represent an upper set in which the actual flag set of a matching file must +be included. That is, in order for a file to be matching, its attributes +may contain any of the specified flags but must not contain any of the +unspecified flags. In other words, you explictly exclude the flags that you +do not specify. Thus if you pass 'FA_DIREC | FA_RDONLY', normal files +and directories will be included as well as read-only files and +directories, but not hidden files and directories. Similarly, if you pass +'FA_ARCH' then both archived and non-archived files will be included. If +FA_NONE is passed all attributes are excluded and only files with no attributes +are returned. Conversely, if you pass FA_ALL, no attributes are excluded so all +files are returned (which is what you would usually want). + +

+Functions which accept wildcards as file names support the meta characters +`*' (which means, zero or any quantity of characters) and `?' (which means +any character, but only one). + +


+

void get_executable_name(char *buf, int size);

+ Fills `buf' with the full path to the current executable, writing at most + `size' bytes. This generally comes from `argv[0]' but on Unix systems it + tries to get the information from the `/proc' filesystem first, searching + the directories specified in `$PATH' if necessary. If this fails too, it + tries to find the executable name from the output of the `ps' command, + using `argv[0]' only as a last resort if all other options fail. Example: +
+      char name[200];
+      ...
+      get_executable_name(name, sizeof(name));
+      allegro_message("Running `%s'\n", name);
+ +


+

char *fix_filename_case(char *path);

+ Converts the filename stored in `path' to a standardised case. On DOS + platforms, they will be entirely uppercase. On other platforms this + function doesn't do anything. Example: +
+      get_executable_name(name, sizeof(name));
+      fix_filename_case(name);
+      allegro_message("Running `%s'\n", name);
+

Return value: + Returns a copy of the `path' parameter. + + +

See also: +fix_filename_slashes, +canonicalize_filename.
+
char *fix_filename_slashes(char *path);

+ Converts all the directory separators in the filename stored in `path' to + a standard character. On DOS and Windows platforms, this is a backslash. + On most other platforms this is a slash. Example: +
+      char buf[200] = "c:/dos\\backup/weirdo\\test";
+      ...
+      fix_filename_slashes(buf);
+      /* Under DOS we would have c:\dos\backup\weirdo\test.
+         Under Unix we would have c:/dos/backup/weirdo/test. */
+

Return value: + Returns a copy of the `path' parameter. + + +

See also: +fix_filename_case, +canonicalize_filename.
+
char *canonicalize_filename(char *dest, const char *filename, int size);

+ Converts any filename into its canonical form, i.e. the minimal absolute + filename describing the same file and fixing incorrect forward/backward + slashes for the current platform, storing at most `size' bytes into the + `dest' buffer. You can use the same buffer both as input and output + because Allegro internally works on a copy of the input before touching + `dest'. Example: +
+      char buf[256];
+      ...
+      canonicalize_filename(buf, "~/../s22/..\\t3st///hi.c",
+                            sizeof(buf));
+      /* Running this under Unix would
+         return: /home/t3st/hi.c */
+
+ Note that this function won't work as expected if the path to canonicalize + comes from another platform (eg. a "c:\something" path will canonicalize + into something really wrong under Unix: "/current/path/c:/something"). +

Return value: + Returns a copy of the `dest' parameter. + + +

See also: +fix_filename_case, +fix_filename_slashes.
+
char *make_absolute_filename(char *dest, const char *path, const char *filename, int size);

+ Makes an absolute filename from an absolute path and a relative filename, + storing at most `size' bytes into the `dest' buffer. This is like calling + replace_filename() and then canonicalize_filename(). Example: +
+      char buf[256];
+      ...
+      make_absolute_filename(buf, "/usr/games/",
+                             "../temp.txt", sizeof(buf));
+      /* This would create /usr/temp.txt */
+

Return value: + Returns a copy of the `dest' parameter. + + +

See also: +make_relative_filename, +is_relative_filename, +replace_filename, +canonicalize_filename.
+
char *make_relative_filename(char *dest, const char *path, const char *filename, int size);

+ Attempts to make a relative filename from an absolute path and an absolute + filename, storing at most `size' bytes into the `dest' buffer. This + function won't work if the paths are not canonical under the current + platform (see canonicalize_filename()). Also, `dest' cannot be used as + input value for `path' or `filename'. Example: +
+      char base[] = "/long/absolute/path/program.exe";
+      char user_input[] = "/nice/and/short.txt";
+      ...
+      make_relative_filename(buf, base, user_input, sizeof(buf));
+      /* Under Unix buf would contain:
+         ../../../nice/and/short.txt */
+

Return value: + Returns a copy of the `dest' parameter if it succeeds or NULL if it fails + (eg. under DOS, one path starts with "C:\" and another with "A:\"). + + +

See also: +make_absolute_filename, +is_relative_filename, +canonicalize_filename.
+
int is_relative_filename(const char *filename);

+ Returns TRUE if the filename is relative or FALSE if it is absolute. Note + that an absolute filename under DOS (with a device separator) will be + considered as relative under Unix, because there absolute paths always + start with a slash. + + +
See also: +make_absolute_filename, +make_relative_filename.
+
char *replace_filename(char *dest, const char *path, + const char *filename, int size);

+ Replaces the specified path+filename with a new filename tail, storing + at most `size' bytes into the `dest' buffer. You can use the same buffer + both as input and output because Allegro internally works on a copy of + the input before touching `dest'. Example: +
+      char name[200];
+      ...
+      get_executable_name(name, sizeof(name));
+      replace_filename(name, name, "sound.dat", sizeof(name));
+

Return value: + Returns a copy of the `dest' parameter. + + +

See also: +get_filename, +replace_extension, +append_filename.
+ +
Examples using this: +Available Allegro examples.
+
char *replace_extension(char *dest, const char *filename, + const char *ext, int size);

+ Replaces the specified filename+extension with a new extension tail, + storing at most `size' bytes into the `dest' buffer. If the filename + doesn't have any extension at all, `ext' will be appended to it, adding + a dot character if needed. You can use the same buffer both as input and + output because Allegro internally works on a copy of the input before + touching `dest'. Example: +
+      replace_extension(buf, "C:\\game\\prog.exe",
+                        "dat", sizeof(buf));
+

Return value: + Returns a copy of the `dest' parameter. + + +

See also: +get_extension, +replace_filename.
+
char *append_filename(char *dest, const char *path, + const char *filename, int size);

+ Concatenates the specified filename onto the end of the specified path, + storing at most `size' bytes into the `dest' buffer. If `path' doesn't + have a trailing path separator, the function will append one if needed. + You can use the same buffer both as input and output because Allegro + internally works on a copy of the input before touching `dest'. Example: +
+      append_filename(buf, "/home/user",
+                      "prog.bin", sizeof(buf));
+

Return value: + Returns a copy of the `dest' parameter. + + +

See also: +replace_filename.
+
char *get_filename(const char *path);

+ Finds out the filename portion of a completely specified file path. Both + `\' and `/' are recognized as directory separators under DOS and Windows. + However, only `/' is recognized as directory separator under other + platforms. Example: +
+      get_executable_name(name, sizeof(name));
+      allegro_message("Running `%s'\n", get_filename(name));
+
+ Note that Allegro won't perform any IO operations during the verification. + This means that if you have `/a/path/like/this/', which doesn't have a + filename, the function will return a pointer to the trailing null + character. However, if you have `/a/path/like/this', Allegro will return + a pointer to `this', even if it is a valid directory. +

Return value: + Returns a pointer to the portion of `path' where the filename starts, or + the beginning of `path' if no valid filename is found (eg. you are + processing a path with backslashes under Unix). + + +

See also: +get_extension, +put_backslash, +replace_filename.
+ +
Examples using this: +exmidi.
+
char *get_extension(const char *filename);

+ Finds out the extension of the filename (with or without path + information). Example: +
+      get_executable_name(name, sizeof(name));
+      allegro_message("The binary has the extension `%s'\n",
+                      get_extension(name));
+

Return value: + Returns a pointer to the portion of `filename' where the extension starts, + or a pointer to the trailing null character if there is no filename or it + doesn't have extension. + + +

See also: +get_filename, +put_backslash, +replace_extension.
+
void put_backslash(char *filename);

+ If the last character of the filename is not a `\', `/', `#' or a device + separator (ie. `:' under DOS), this routine will concatenate either a `\' + or `/' on to it (depending on the platform). Note: ignore the function + name, it's out of date. + + +
See also: +get_extension, +get_filename.
+
int file_exists(const char *filename, int attrib, int *aret);

+ Checks whether a file matching the given name and attributes (see + beginning of this chapter) exists. If `aret' is not NULL, it will be set + to the attributes of the matching file. Example: +
+      /* Check for a normal file. */
+      if (file_exists("franken.dat", 0, NULL))
+         allegro_message("It is alive!\n");
+

Return value: + Returns non-zero if the file exists, or zero if it doesn't or the + specified attributes mask it out. + + +

See also: +exists, +file_size_ex, +file_time.
+
int exists(const char *filename);

+ Shortcut version of file_exists(), which checks for normal files, which + may have the archive or read-only bits set, but are not hidden, + directories, system files, etc. +

Return value: + Returns non-zero if the file exists, or zero if it doesn't. + + +

See also: +file_exists, +file_size_ex, +file_time.
+
uint64_t file_size_ex(const char *filename);

+ Returns the size of a file, in bytes. If the file does not exist or an + error occurs, it will return zero and store the system error code in + errno. + + +
See also: +file_exists, +file_time.
+ +
Examples using this: +expackf.
+
time_t file_time(const char *filename);

+ Returns the modification time (number of seconds since 00:00:00 GMT + 1/1/1970) of a file. If the file does not exist or an error occurs, it + will return zero and store the system error code in errno. + + +
See also: +file_exists, +file_size_ex.
+
int delete_file(const char *filename);

+ Removes a file from the disk. You can't delete directories, though. +

Return value: + Returns zero on success, non-zero on failure. + +


+

int for_each_file_ex(const char *name, int in_attrib, int out_attrib, + int (*callback)(const char *filename, int attrib, + void *param), void *param);

+ Finds all the files on disk which match the given wildcard specification + and file attributes, and executes callback() once for each. Basically, this + is a convenient wrapper around al_findfirst(), al_findnext() and + al_findclose(). `in_attrib' is a bitmask specifying the attributes the + files must carry, `out_attrib' is a bitmask specifying the attributes the + files must not carry; attributes which are not specified in either bitmasks + are not taken into account for deciding whether callback() is invoked or + not. + +

+ The callback function will be passed three arguments: the first is a string + which contains the completed filename (exactly the same string you passed + to for_each_file_ex() but with meta characters), the second is the actual + attributes of the file, and the third is a void pointer which is simply a + copy of `param' (you can use this for whatever you like). The callback must + return zero to let the enumeration proceed, or any non-zero value to stop + it. If an error occurs, the error code will be stored in `errno' but the + enumeration won't stop. Example: +

+      int show_name(const char *filename, int attrib, void *param)
+      {
+         allegro_message("Caught `%s', attribs %d\n",
+                         filename, attrib);
+         return 0;
+      }
+      ...
+         count = for_each_file_ex("data/level*", FA_DIREC,
+                                  0, show_name, 0);
+         allegro_message("%d game directories\n", count);
+

Return value: + Returns the number of successful calls made to callback(), that is, the + number of times callback() was called and returned 0. + + +

See also: +al_findfirst, +al_findnext, +al_findclose.
+
int al_findfirst(const char *pattern, struct al_ffblk *info, int attrib);

+ Low-level function for searching files. This function finds the first + file which matches the given wildcard specification and file attributes + (see above). The information about the file (if any) will be put in the + al_ffblk structure which you have to provide. The al_ffblk structure + looks like: +
+      struct al_ffblk
+      {
+         int attrib;       - actual attributes of the file found
+         time_t time;      - modification time of file
+         char name[512];   - name of file
+      };
+
+ There is some other stuff in the structure as well, but it is there for + internal use only. Example: +
+      struct al_ffblk info;
+
+      if (al_findfirst("*.pcx", &info, FA_ALL) != 0) {
+         /* Tell user there are no PCX files. */
+         return;
+      }
+

Return value: + The function returns non-zero if no match is found or if an error occurred + and, in the latter case, sets `errno' accordingly. It returns zero if a + match is found, allocating some memory for internal use in the structure. + Therefore you have to close your search when you are finished to avoid + memory leaks in your program. + + +

See also: +al_findnext, +al_findclose, +al_ffblk_get_size.
+
int al_findnext(struct al_ffblk *info);

+ This finds the next file in a search started by al_findfirst(). Example: +
+      if (al_findfirst("*.pcx", &info, 0) != 0)
+         return;
+
+      do {
+         /* Do something useful here with info.name. */
+      } while (al_findnext(&info) == 0);
+
+      al_findclose(&info);
+

Return value: + Returns zero if a match is found, non-zero if none is found or if an + error occurred and, in the latter case, sets errno accordingly. + + +

See also: +al_findfirst, +al_findclose.
+
void al_findclose(struct al_ffblk *info);

+ This closes a previously opened search with al_findfirst(). You need to + call this on all successfully opened searches to avoid memory leaks in + your program. + + +
See also: +al_findfirst, +al_findnext.
+
uint64_t al_ffblk_get_size(struct al_ffblk *info);

+ This returns the size of the file returned by al_findfirst or al_findnext. + + +
See also: +al_findfirst, +al_findnext, +al_ffblk.
+
int find_allegro_resource(char *dest, const char *resource, + const char *ext, const char *datafile, + const char *objectname, const char *envvar, + const char *subdir, int size);

+ Searches for a support file, eg. `allegro.cfg' or `language.dat'. Passed a + resource string describing what you are looking for, along with extra + optional information such as the default extension, what datafile to look + inside, what the datafile object name is likely to be, any special + environment variable to check, and any subdirectory that you would like + to check as well as the default location, this function looks in a hell + of a lot of different places :-). Pass NULL for the parameters you are not + using. + +

+ Check the documentation chapter specific to your platform for information + on additional paths this function might search for. Also, don't forget + about set_allegro_resource_path() to extend the searches. Example: +

+      char path[256];
+      int ret;
+      ret = find_allegro_resource(path, "scores.cfg", NULL, NULL,
+                                  NULL, NULL, NULL, sizeof(path));
+      if (ret == 0) {
+         /* Found system wide scores file. */
+      } else {
+         /* No previous scores, create our own file. */
+      }
+

Return value: + Returns zero on success, and stores a full path to the file (at most size + bytes) into the dest buffer. + + +

See also: +set_allegro_resource_path.
+
int set_allegro_resource_path(int priority, const char *path);

+ Sometimes Allegro doesn't look in enough places to find a resource. For + those special cases, you can call this function before loading your + resource with additional paths to search for. You set up the priorities, + higher numbers are searched for first. To modify an already setup path, + call this function with the same priority and the new path. To remove an + already setup path, call this function with the priority of the path and + NULL as the path parameter. Example: +
+      set_allegro_resource_path(10, "my_game/configs");
+      set_allegro_resource_path(0, "users/configs/");
+      set_allegro_resource_path(-45, "temp");
+
+ These custom paths will be valid until you call allegro_exit(). You can + call this function before install_allegro(), but after set_uformat() if + you want to use a text encoding format other than the default. +

Return value: + Returns non-zero on success, zero if the path could not be added or you + wanted to remove a path and the priority used didn't have any associated + path. Modification of existing paths always succeeds. + + +

See also: +find_allegro_resource.
+
void packfile_password(const char *password);

+ Sets the encryption password to be used for all read/write operations + on files opened in future using Allegro's packfile functions (whether + they are compressed or not), including all the save, load and config + routines. Files written with an encryption password cannot be read + unless the same password is selected, so be careful: if you forget the + key, nobody can make your data come back again! Pass NULL or an empty + string to return to the normal, non-encrypted mode. If you are using + this function to prevent people getting access to your datafiles, be + careful not to store an obvious copy of the password in your executable: + if there are any strings like "I'm the password for the datafile", it + would be fairly easy to get access to your data :-) + +

+ Note #1: when writing a packfile, you can change the password to whatever + you want after opening the file, without affecting the write operation. + On the contrary, when writing a sub-chunk of a packfile, you must make + sure that the password that was active at the time the sub-chunk was + opened is still active before closing the sub-chunk. This is guaranteed + to be true if you didn't call the packfile_password() routine in the + meantime. Read operations, either on packfiles or sub-chunks, have no + such restriction. + +

+ Note #2: as explained above, the password is used for all read/write + operations on files, including for several functions of the library that + operate on files without explicitly using packfiles (e.g. load_bitmap()). + The unencrypted mode is mandatory in order for those functions to work. + Therefore remember to call packfile_password(NULL) before using them if + you previously changed the password. As a rule of thumb, always call + packfile_password(NULL) when you are done with operations on packfiles. + The only exception to this is custom packfiles created with + pack_fopen_vtable(). + + +

See also: +pack_fopen, +load_datafile, +pack_fopen_vtable.
+
PACKFILE *pack_fopen(const char *filename, const char *mode);

+ Opens a file according to mode, which may contain any of the flags: + + Instead of these flags, one of the constants F_READ, F_WRITE, + F_READ_PACKED, F_WRITE_PACKED or F_WRITE_NOPACK may be used as the mode + parameter. + +

+ The packfile functions also understand several "magic" filenames that are + used for special purposes. These are: +

+ With these special filenames, the contents of a datafile object or + appended file can be read in an identical way to a normal disk file, so + any of the file access functions in Allegro (eg. load_pcx() and + set_config_file()) can be used to read from them. Note that you can't + write to these special files, though: the fake file is read only. Also, + you must save your datafile uncompressed or with per-object compression + if you are planning on loading individual objects from it (otherwise + there will be an excessive amount of seeking when it is read). + +

+ Finally, be aware that the special Allegro object types aren't the same + format as the files you import the data from. When you import data like + bitmaps or samples into the grabber, they are converted into a special + Allegro-specific format, but the `#' marker file syntax reads the objects + as raw binary chunks. This means that if, for example, you want to use + load_pcx() to read an image from a datafile, you should import it as a + binary block rather than as a BITMAP object. + +

+ Example: +

+      PACKFILE *input_file;
+
+      input_file = pack_fopen("scores.dat", "rp");
+      if (!input_file)
+         abort_on_error("Couldn't read `scores.dat'!");
+

Return value: + On success, pack_fopen() returns a pointer to a PACKFILE structure, and on + error it returns NULL and stores an error code in `errno'. An attempt to + read a normal file in packed mode will cause `errno' to be set to EDOM. + + +

See also: +pack_fclose, +pack_fopen_chunk, +packfile_password, +pack_fread, +pack_getc, +file_select_ex, +pack_fopen_vtable.
+ +
Examples using this: +expackf.
+
PACKFILE *pack_fopen_vtable(const PACKFILE_VTABLE *vtable, void *userdata);

+ Creates a new packfile structure that uses the functions specified in + the vtable instead of the standard functions. The data pointer by `vtable' + and `userdata' must remain available for the lifetime of the created + packfile. + +

+ While the created packfile structure can be used with other Allegro + functions, there are two limitations. First, opening chunks using + pack_fopen_chunk() on top of the returned packfile is not possible at this + time. And packfile_password() does not have any effect on packfiles opened + with pack_fopen_vtable(). +

Return value: + On success, it returns a pointer to a PACKFILE structure, and on error it + returns NULL and stores an error code in `errno'. + + +

See also: +pack_fopen, +pack_fopen_chunk, +packfile_password.
+ +
Examples using this: +expackf.
+
int pack_fclose(PACKFILE *f);

+ Closes the stream `f' previously opened with pack_fopen() or + pack_fopen_vtable(). After you have closed the stream, performing + operations on it will yield errors in your application (e.g. crash it) or + even block your OS. +

Return value: + Returns zero on success. On error, returns an error code which is also + stored in `errno'. This function can fail only when writing to files: if + the file was opened in read mode, it will always succeed. + + +

See also: +pack_fopen, +pack_fopen_vtable, +packfile_password.
+ +
Examples using this: +expackf.
+
int pack_fseek(PACKFILE *f, int offset);

+ Moves the position indicator of the stream `f'. Unlike the standard fseek() + function, this only supports forward movements relative to the current + position and in read-only streams, so don't use negative offsets. Note that + seeking is very slow when reading compressed files, and so should be + avoided unless you are sure that the file is not compressed. Example: +
+      input_file = pack_fopen("data.bin", "r");
+      if (!input_file)
+         abort_on_error("Couldn't open binary data!");
+      /* Skip some useless header before reading data. */
+      pack_fseek(input_file, 32);
+

Return value: + Returns zero on success or a negative number on error, storing the error + code in `errno'. + + +

See also: +pack_fopen, +pack_fopen_chunk.
+ +
Examples using this: +expackf.
+
int pack_feof(PACKFILE *f);

+ Finds out if you have reached the end of the file. It does not wait for you + to attempt to read beyond the end of the file, contrary to the ISO C feof() + function. The only way to know whether you have read beyond the end of the + file is to check the return value of the read operation you use (and be + wary of pack_*getl() as EOF is also a valid return value with these + functions). +

Return value: + Returns non-zero if you are at the end of the file, zero otherwise. + + +

See also: +pack_fopen, +pack_fopen_chunk, +pack_ferror.
+
int pack_ferror(PACKFILE *f);

+ Since EOF is used to report errors by some functions, it's often better to + use the pack_feof() function to check explicitly for end of file and + pack_ferror() to check for errors. Both functions check indicators that + are part of the internal state of the stream to detect correctly the + different situations. +

Return value: + Returns nonzero if the error indicator for the stream is set, meaning + that an error has occurred during a previous operation on the stream. + + +

See also: +pack_fopen, +pack_fopen_chunk.
+
int pack_getc(PACKFILE *f);

+ Returns the next character from the stream `f', or EOF if the end of the + file has been reached. + + +
See also: +pack_fopen, +pack_fopen_chunk.
+
int pack_putc(int c, PACKFILE *f);

+ Puts a character in the stream f. +

Return value: + Returns the character written on success, or EOF on error. + + +

See also: +pack_fopen, +pack_fopen_chunk.
+
int pack_igetw(PACKFILE *f);

+ Like pack_getc, but reads a 16-bit word from a file, using Intel byte + ordering (least significant byte first, a.k.a. little-endian). + + +
See also: +pack_getc.
+
int pack_iputw(int c, PACKFILE *f);

+ Like pack_putc, but writes a 16-bit word to a file, using Intel byte + ordering (least significant byte first, a.k.a. little-endian). + + +
See also: +pack_putc.
+
long pack_igetl(PACKFILE *f);

+ Like pack_getc, but reads a 32-bit long from a file, using Intel byte + ordering (least significant byte first, a.k.a. little-endian). + + +
See also: +pack_getc.
+
long pack_iputl(long c, PACKFILE *f);

+ Like pack_putc, but writes a 32-bit long to a file, using Intel byte + ordering (least significant byte first, a.k.a. little-endian). + + +
See also: +pack_putc.
+
int pack_mgetw(PACKFILE *f);

+ Like pack_getc, but reads a 16-bit word from a file, using Motorola byte + ordering (most significant byte first, a.k.a. big-endian). + + +
See also: +pack_getc.
+
int pack_mputw(int c, PACKFILE *f);

+ Like pack_putc, but writes a 16-bit word to a file, using Motorola byte + ordering (most significant byte first, a.k.a. big-endian). + + +
See also: +pack_putc.
+
long pack_mgetl(PACKFILE *f);

+ Like pack_getc, but reads a 32-bit long from a file, using Motorola byte + ordering (most significant byte first, a.k.a. big-endian). + + +
See also: +pack_getc.
+
long pack_mputl(long c, PACKFILE *f);

+ Like pack_putc, but writes a 32-bit long to a file, using Motorola byte + ordering (most significant byte first, a.k.a. big-endian). + + +
See also: +pack_putc.
+
long pack_fread(void *p, long n, PACKFILE *f);

+ Reads `n' bytes from the stream `f', storing them at the memory location + pointed to by `p'. Example: +
+      unsigned char buf[256];
+      ...
+      if (pack_fread(buf, 256, input_file) != 256)
+         abort_on_error("Truncated input file!");
+

Return value: + Returns the number of bytes read, which will be less than `n' if EOF is + reached or an error occurs. Error codes are stored in errno. + + +

See also: +pack_fopen, +pack_fopen_chunk, +pack_feof.
+ +
Examples using this: +expackf.
+
long pack_fwrite(const void *p, long n, PACKFILE *f);

+ Writes `n' bytes to the stream `f' from memory location pointed to by `p'. +

Return value: + Returns the number of bytes written, which will be less than n if an + error occurs. Error codes are stored in errno. + + +

See also: +pack_fopen, +pack_fopen_chunk, +pack_feof.
+
char *pack_fgets(char *p, int max, PACKFILE *f);

+ Reads a line from the stream `f', storing it at location pointed to by + `p'. Stops when a linefeed is encountered, or `max' bytes have been read. + The end of line is handled by detecting the right combination of characters + for the platform. This supports CR-LF (DOS/Windows), LF (Unix), and CR + (Mac) formats. However, the trailing carriage return is not included in the + returned string, in order to provide easy code portability across + platforms. If you need the carriage return, use pack_fread() and/or + pack_getc() instead. Example: +
+      char buf[256];
+      ...
+      while (pack_fgets(buf, sizeof(buf), input_file)) {
+         /* Process input line. */
+      }
+      fclose(input_file);
+

Return value: + Returns the pointer `p' on success, or NULL on error. + + +

See also: +pack_fopen, +pack_fopen_chunk, +pack_fread, +pack_getc.
+
int pack_fputs(const char *p, PACKFILE *f);

+ Writes a string to the stream `f'. The input string is converted from the + current text encoding format to UTF-8 before writing. Newline characters + are written as `\r\n' on DOS and Windows platforms. If you don't want this + behaviour, use pack_fwrite() and/or pack_putc() instead. +

Return value: + Returns zero on success or a negative number on error. + + +

See also: +pack_fopen, +pack_fopen_chunk, +pack_fwrite, +pack_putc.
+
PACKFILE *pack_fopen_chunk(PACKFILE *f, int pack);

+ Opens a sub-chunk of a file. Chunks are primarily intended for use by the + datafile code, but they may also be useful for your own file routines. A + chunk provides a logical view of part of a file, which can be compressed + as an individual entity and will automatically insert and check length + counts to prevent reading past the end of the chunk. The PACKFILE + parameter is a previously opened file, and `pack' is a boolean parameter + which will turn compression on for the sub-chunk if it is non-zero. + Example: +
+      PACKFILE *output = pack_fopen("out.raw", "w!");
+      ...
+      /* Create a sub-chunk with compression. */
+      output = pack_fopen(chunk(output, 1);
+      if (!output)
+         abort_on_error("Error saving data!");
+      /* Write some data to the sub-chunk. */
+      ...
+      /* Close the sub-chunk, recovering parent file. */
+      output = pack_fclose_chunk(output);
+
+ The data written to the chunk will be prefixed with two length counts + (32-bit, a.k.a. big-endian). For uncompressed chunks these will both be + set to the size of the data in the chunk. For compressed chunks (created + by setting the `pack' flag), the first length will be the raw size of the + chunk, and the second will be the negative size of the uncompressed data. + +

+ To read the chunk, use the following code: +

+      PACKFILE *input = pack_fopen("out.raw", "rp");
+      ...
+      input = pack_fopen_chunk(input, 1);
+      /* Read data from the sub-chunk and close it. */
+      ...
+      input = pack_fclose_chunk(input);
+
+ This sequence will read the length counts created when the chunk was + written, and automatically decompress the contents of the chunk if it + was compressed. The length will also be used to prevent reading past the + end of the chunk (Allegro will return EOF if you attempt this), and to + automatically skip past any unread chunk data when you call + pack_fclose_chunk(). + +

+ Chunks can be nested inside each other by making repeated calls to + pack_fopen_chunk(). When writing a file, the compression status is + inherited from the parent file, so you only need to set the pack flag if + the parent is not compressed but you want to pack the chunk data. If the + parent file is already open in packed mode, setting the pack flag will + result in data being compressed twice: once as it is written to the + chunk, and again as the chunk passes it on to the parent file. +

Return value: + Returns a pointer to the sub-chunked PACKFILE, or NULL if there was some + error (eg. you are using a custom PACKFILE vtable). + + +

See also: +pack_fclose_chunk, +pack_fopen.
+
PACKFILE *pack_fclose_chunk(PACKFILE *f);

+ Closes a sub-chunk of a file, previously obtained by calling + pack_fopen_chunk(). +

Return value: + Returns a pointer to the parent of the sub-chunk you just closed. Returns + NULL if there was some error (eg. you tried to close a PACKFILE which + wasn't sub-chunked). + + +

See also: +pack_fopen_chunk.
+
LZSS_PACK_DATA *create_lzss_pack_data(void);

+ Creates an LZSS_PACK_DATA structure, which can be used for LZSS + compression with PACKFILEs. +

Return value: + Returns a pointer to the structure, or NULL if there was an error. + + +

See also: +free_lzss_pack_data.
+
void free_lzss_pack_data(LZSS_PACK_DATA *dat);

+ Frees an LZSS_PACK_DATA structure created with create_lzss_pack_data(). + + +
See also: +create_lzss_pack_data.
+
int lzss_write(PACKFILE *file, LZSS_PACK_DATA *dat, int size, + unsigned char *buf, int last);

+ Packs `size' bytes from `buf', using the pack information contained in + `dat'. The compressed bytes will be stored in `file'. +

Return value: + Returns 0 on success, or EOF if there was an error. + + +

See also: +create_lzss_pack_data, +free_lzss_pack_data.
+
LZSS_UNPACK_DATA *create_lzss_unpack_data(void);

+ Creates an LZSS_UNPACK_DATA structure, which can be used for LZSS + decompression reading PACKFILEs. +

Return value: + Returns a pointer to the structure, or NULL if there was an error. + + +

See also: +free_lzss_unpack_data.
+
void free_lzss_unpack_data(LZSS_UNPACK_DATA *dat);

+ Frees an LZSS_UNPACK_DATA structure created with create_lzss_pack_data. + + +
See also: +create_lzss_unpack_data.
+
int lzss_read(PACKFILE *file, LZSS_UNPACK_DATA *dat, int s, + unsigned char *buf);

+ Unpacks from `dat' into `buf', until either EOF is reached or `s' bytes + have been extracted from `file'. +

Return value: + Returns the number of bytes added to the buffer `buf'. + + + + +

See also: +free_lzss_unpack_data.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg031.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg031.html new file mode 100644 index 0000000..68af272 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg031.html @@ -0,0 +1,658 @@ + + +Allegro Manual: Datafile routines + + + + +

Datafile routines

+ + + +

+Datafiles are created by the grabber utility (see grabber.txt for more +information), and have a `.dat' extension. They can contain bitmaps, palettes, +fonts, samples, MIDI music, FLI/FLC animations, and any other binary data that +you import. You could distribute your bitmaps and samples in a myriad of +separate files, but packing them in a few `.dat' binaries has a few +advantages: +

+Allegro allows you to load datafiles once and forget about them. But if you +have many levels it can be wise to load only the resources required for the +current level. You can accomplish the later by separating levels in different +datafiles, or using functions like load_datafile_object() to avoid loading +everything at once. You can even read directly from a specific datafile object +with the pack_fopen() function. + +

+On some platforms you can attach datafiles to your binary, potentially +reducing your game distribution down to a single executable file. Try the +example exexedat on your platform to see if this is possible. However, this +is not recommended for big programs: a single update to your code or binary +data would force end users to download again a potentially big file, no matter +how small your change is. The same warning goes for the tools dat2s or dat2c, +which convert datafiles into assembler and C code respectively, prepared to be +included directly in your binary. + +

+Remember that with Allegro truecolor images can only be loaded after you have +set a graphics mode. This is true for datafiles too. Load all your data after +you have set the graphics mode, otherwise the pixel format (RGB or BGR) will +not be known and the datafile may be converted wrongly. Oh, and read carefully +the warning of fixup_datafile() if you plan on switching resolutions during +runtime. + +

+Note: even though Allegro datafiles provide encryption, you should consider +it weak, so don't plan on hiding there the plans for a Death Star or +something. Determinate knowledgeable users will be able to rip your resources +no matter how hard you try to hide them! Use the encryption only as a slight +deterrent towards unwanted tampering of your data. How to crack an encrypted +datafile is left as an exercise to the reader, though. + +

+Using datafiles once they are loaded is quite simple: you access the elements +of the DATAFILE as a normal array. Read below the section "Using datafiles" +below for several examples on how to access their data. + +


+

DATAFILE *load_datafile(const char *filename);

+ Loads a datafile into memory in one go. If the datafile has been encrypted, + you must first call packfile_password() to set the appropriate key. If the + datafile contains truecolor graphics, you must set the video mode or call + set_color_conversion() before loading it. Example: +
+      /* Load the resources for our game. */
+      DATAFILE *dat = load_datafile("game.dat");
+      if (!dat)
+         abort_on_error("Couldn't load sound resources!");
+      /* Use resources. */
+      ...
+      /* Destroy them when we don't need them any more. */
+      unload_datafile(dat);
+

Return value: + Returns a pointer to the DATAFILE, or NULL on error. Remember to free this + DATAFILE later to avoid memory leaks. + + +

See also: +load_datafile_callback, +unload_datafile, +load_datafile_object, +set_color_conversion, +fixup_datafile, +packfile_password, +find_datafile_object, +register_datafile_object, +Using datafiles.
+ +
Examples using this: +excustom, +exdata, +exexedat, +exgui, +exsprite, +exunicod.
+
DATAFILE *load_datafile_callback(const char *filename, + void (*callback)(DATAFILE *d));

+ Loads a datafile into memory, calling the specified hook function once for + each object in the file, passing it a pointer to the object just read. You + can use this to implement very simple loading screens where every time the + hook is called, the screen is updated to let the user know your program is + still loading from disk: +
+      void load_callback(DATAFILE *dat_obj)
+      {
+         static const char indicator[] = "-\\|/-.oOXOo.";
+         static int current = 0;
+          
+         /* Show a different character every time. */
+         textprintf_ex(screen, font, 0, 0, makecol(0, 0, 0),
+                       makecol(255, 255, 255), "%c Loading %c",
+                       indicator[current], indicator[current]);
+         /* Increase index and check if we need to reset it. */
+         current++;
+         if (!indicator[current])
+            current = 0;
+      }
+         ...
+         dat = load_datafile_callback("data.dat", load_callback);
+

Return value: + Returns a pointer to the DATAFILE or NULL on error. Remember to free this + DATAFILE later to avoid memory leaks. + + +

See also: +load_datafile, +unload_datafile, +load_datafile_object, +set_color_conversion, +fixup_datafile, +packfile_password, +find_datafile_object, +register_datafile_object.
+
void unload_datafile(DATAFILE *dat);

+ Frees all the objects in a datafile. Use this to avoid memory leaks in + your program. + + +
See also: +load_datafile.
+ +
Examples using this: +excustom, +exdata, +exexedat, +exgui, +exsprite, +exunicod.
+
DATAFILE *load_datafile_object(const char *filename, + const char *objectname);

+ Loads a specific object from a datafile. This won't work if you strip the + object names from the file, and it will be very slow if you save the file + with global compression. Example: +
+      /* Load only the music from the datafile. */
+      music_object = load_datafile_object("datafile.dat",
+                                          "MUSIC");
+      /* Play it and wait a moment for it. */
+      play_midi(music_object->dat);
+      ...
+      /* Destroy unneeded music. */
+      unload_datafile_object(music_object);
+

Return value: + Returns a pointer to a single DATAFILE element whose `dat' member points to + the object, or NULL if there was an error or there was no object with the + requested name. Remember to free this DATAFILE later to avoid memory leaks, + but use the correct unloading function! + + +

See also: +unload_datafile_object, +load_datafile, +set_color_conversion, +find_datafile_object, +register_datafile_object, +Using datafiles.
+
void unload_datafile_object(DATAFILE *dat);

+ Frees an object previously loaded by load_datafile_object(). Use this to + avoid memory leaks in your program. + + +
See also: +load_datafile_object.
+
DATAFILE *find_datafile_object(const DATAFILE *dat, const char *objectname);

+ Searches an already loaded datafile for an object with the specified + name. In the name you can use `/' and `#' separators for nested datafile + paths. Example: +
+      char level_name[10];
+      DATAFILE *dat, *level;
+      ...
+      uszprintf(level_name, sizeof(buffer),
+                "LEVEL_%02d", level_number);
+      level = find_datafile_object(dat, level_name);
+      if (!level)
+         abort_on_error("That level doesn't exist!");
+

Return value: + Returns a pointer to a single DATAFILE element whose `dat' member points to + the object, or NULL if the object could not be found. + + +

See also: +load_datafile, +load_datafile_object.
+
DATAFILE_INDEX *create_datafile_index(const char *filename);

+ Creates an index for a datafile, to speed up loading single objects out of + it. This is mostly useful for big datafiles, which you don't want to load as + a whole. The index will store the offset of all objects inside the datafile, + and then you can load it quickly with "load_datafile_object_indexed" later. + Use destroy_datafile_index to free the memory used by it again. + +

+ Note: If the datafile uses global compression, there is no performance gain + from using an index, because seeking to the offset still requires to + uncompress the whole datafile up to that offset. + Example: +

+   DATAFILE_INDEX *index = create_datafile_index("huge.dat");
+   DATAFILE *object = load_datafile_object_indexed(index, 1234);
+   ...
+   unload_datafile_object(object);
+   destroy_datafile_index(index);
+

Return value: + A pointer value which you can pass to load_datafile_object_indexed. + + +

See also: +destroy_datafile_index, +load_datafile_object_indexed, +Using datafiles.
+
DATAFILE *load_datafile_object_indexed(const DATAFILE_INDEX *index, int item)

+ This loads a single object, using the index created previously with + create_datafile_index. See create_datafile_index for an example. +

Return value: + Returns a pointer to a single DATAFILE element whose "dat" member points to + the object, or NULL if the object could not be loaded. + + +

See also: +create_datafile_index, +load_datafile_object, +unload_datafile_object.
+
void destroy_datafile_index(DATAFILE_INDEX *index)

+ This function frees the memory used by a datafile index created with + create_datafile_index earlier. + + +
See also: +create_datafile_index.
+
const char *get_datafile_property(const DATAFILE *dat, int type);

+ Finds the property type of a DATAFILE object. The type parameter must be a + value created with the DAT_ID() macro. Example: +
+      const char *name;
+      ...
+      name = get_datafile_property(game_data,
+                                   DAT_ID('N','A','M','E'));
+      if (name == empty_string)
+         abort_on_error("Object doesn't have a name!");
+

Return value: + Returns a pointer to the text string for the object, or a pointer to the + variable empty_string if the property isn't present. + + +

See also: +Using datafiles, +DAT_ID, +empty_string.
+
void register_datafile_object(int id, void *(*load)(PACKFILE *f, long size), + void (*destroy)(void *data));

+ Used to add custom object types, specifying functions to load and destroy + objects of this type. + + +
See also: +load_datafile, +load_datafile_object, +DAT_ID, +Custom datafile objects.
+
void fixup_datafile(DATAFILE *data);

+ If you are using compiled datafiles (produced by the dat2s and dat2c + utilities) on a platform that doesn't support constructors (currently any + non GCC-based platform), or if the datafiles contain truecolor images, you + must call this function once after your set the video mode that you will + be using. This will ensure the datafiles are properly initialised in the + first case and convert the color values into the appropriate format in + the second case. It handles flipping between RGB and BGR formats, and + converting between different color depths whenever that can be done + without changing the size of the image (ie. changing 15<->16-bit + hicolor for both bitmaps and RLE sprites, and 24<->32-bit truecolor + for RLE sprites). + +

+ Note that you can only call this once and expect it to work correctly, + because after the call the DATAFILE you fixed up is permanently converted + to whatever is the current component ordering for your screen mode. If you + call fixup_datafile again, the function assumes you have a freshly loaded + datafile. It cannot "undo" the previous conversion. + +

+ If your program supports changing resolution and/or color depth during + runtime, you have two choices: either call fixup_datafile() just once and + hope that the component ordering and bit depth doesn't change when the + screen mode changes (unlikely). Or, you can reload your datafiles when the + screen mode changes. + + +

See also: +set_gfx_mode, +set_color_conversion, +Differences between platforms.
+
Macro DAT_ID(a, b, c, d);

+ Every object or property in a datafile is identified by a 4 letter ID, + which can be created with this macro. For example, to access the NAME + property of a datafile object, you could use: +
+      get_datafile_property(datob, DAT_ID('N','A','M','E'));
+
+ + + +
See also: +register_datafile_object, +get_datafile_property, +Custom datafile objects, +Using datafiles.
+

Using datafiles

+ +

+In order to access the contents of a datafile, you will need to know where +each object is located. The easiest way to do this is by integer index, +using an automatically generated header file. With the grabber, type a name +into the "Header:" field, and the object indexes will be written to this +file whenever the datafile is saved. With the dat utility, use the '-h' +option, eg. "dat filename.dat -h filename.h". The header will define C +preprocessor symbols for each object in the datafile, for example: +

+   #define SOME_DATA                        0        /* DATA */
+   #define SOME_MORE_DATA                   1        /* DATA */
+
+To prevent name conflicts, you can specify a prefix string for these +definitions by typing it into the "Prefix:" field in the grabber or using +the '-p' option to dat. + +

+To load a datafile into memory, call the function: +

+   DATAFILE *load_datafile(char *filename);
+
+This will load the entire file, returning a pointer to it, or NULL on error. +When the data is no longer required, the entire thing can be destroyed by +calling: +
+   void unload_datafile(DATAFILE *dat);
+
+When you load a datafile, you will obtain a pointer to an array of DATAFILE +structures: +
+   typedef struct DATAFILE
+   {
+      void *dat;                    - pointer to the actual data
+      int type;                     - object type ID
+      long size;                    - size of the data, in bytes
+      DATAFILE_PROPERTY *prop;      - list of object properties
+   } DATAFILE;
+ +

+The only really important piece of information here is the `dat' field, which +points to the contents of the object. What type of data this is will depend +on the type of object: for bitmaps it will be an Allegro BITMAP structure, +for RLE sprites an RLE_SPRITE, for fonts a FONT structure, etc. If you are +programming in C you can pass this pointer directly to the relevant Allegro +library functions, but if you are using C++ you will need to cast it to the +appropriate type to prevent the compiler giving a warning. + +

+For example, if you have a datafile called `myfile.dat', which contains a +bitmap called COOL_PICTURE, and you have used it to produce a header called +`myfile.h', you could display the bitmap with the code: +

+   #include "myfile.h"
+
+   void show_the_bitmap()
+   {
+      DATAFILE *dat;
+      BITMAP *bmp;
+
+      dat = load_datafile("myfile.dat");
+      if (!dat) {
+         /* report an error! */
+         return;
+      }
+
+      bmp = (BITMAP *)dat[COOL_PICTURE].dat;
+      blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
+      unload_datafile(dat);
+   }
+ +

+If a datafile contains nested child datafiles, the header will prefix the +names of objects in the sub-files with the name of their parent datafile. It +will also define a count of the number of objects in the child file, which +may be useful if for example the child datafile contains several bitmaps +which form a 'run' animation, and you want your code to automatically +adjust to the number of frames in the datafile. + +

+For example, the following datafile: +

+   "FILE" - NESTED_FILE
+            |- "BMP" - A_BITMAP
+            |- "FONT" - A_FONT
+   "DATA" - SOME_DATA
+   "DATA" - SOME_MORE_DATA
+
+Will produce the header: +
+   #define NESTED_FILE                      0        /* FILE */
+
+   #define NESTED_FILE_A_BITMAP             0        /* BMP  */
+   #define NESTED_FILE_A_FONT               1        /* FONT */
+   #define NESTED_FILE_COUNT                2
+
+   #define SOME_DATA                        1        /* DATA */
+   #define SOME_MORE_DATA                   2        /* DATA */
+
+The main datafile contains three objects (NESTED_FILE, SOME_DATA, and +SOME_MORE_DATA) with consecutive indexes, while the child datafile contains +the two objects A_BITMAP and A_FONT. To access these objects you need to +reference both the parent and child datafiles, eg: +
+   DATAFILE *dat = load_datafile("whatever.dat");
+   DATAFILE *nested = (DATAFILE *)dat[NESTED_FILE].dat;
+   FONT *thefont = (FONT *)nested[NESTED_FILE_A_FONT].dat;
+
+If you need to access object property strings from within your program, you +can use the function: +
+   char *get_datafile_property(DATAFILE *dat, int type);
+
+This will return a pointer to the property string if it can be found, and an +empty string (not null!) if it does not exist. One possible use of this +function is to locate objects by name, rather than using the indexes from a +header file. The datafile array is ended by an object of type DAT_END, so to +search the datafile dat for the object "my_object" you could use the code: +
+   const int name_type = DAT_ID('N','A','M','E');
+   for (i=0; dat[i].type != DAT_END; i++) {
+      if (stricmp(get_datafile_property(dat+i, name_type),
+                  "my_object") == 0) {
+         /* found the object at index i */
+      }
+   }
+   /* not found... */
+
+If you prefer to access objects by name rather than index number, you can +use the function: +
+   DATAFILE *find_datafile_object(DATAFILE *dat, char *objectname);
+
+This will search an already loaded datafile for an object with the specified +name, returning a pointer to it, or NULL if the object cannot be found. It +understands '/' and '#' separators for nested datafile paths. + +

+It is also possible to selectively load individual objects from a datafile, +with the function: +

+   DATAFILE *load_datafile_object(char *filename, char *objectname);
+
+This searches the datafile for an object with the specified name, so +obviously it won't work if you strip the name properties out of the file. +Because this function needs to seek through the data, it will be extremely +slow if you have saved the file with global compression. If you are planning +to load objects individually, you should save the file uncompressed or with +individual compression per-object. Because the returned datafile points to a +single object rather than an array of objects, you should access it with the +syntax datafile->dat, rather than datafile[index].dat, and when you are done +you should free the object with the function: +
+   void unload_datafile_object(DATAFILE *dat);
+
+Example: +
+   music_object = load_datafile_object("datafile.dat", "MUSIC");
+   play_midi(music_object->dat);
+   ...
+   unload_datafile_object(music_object);
+
+Alternatively, the packfile functions can open and read directly from the +contents of a datafile object. You do this by calling pack_fopen() with a +fake filename in the form "filename.dat#object_name". The contents of the +object can then be read in an identical way to a normal disk file, so any of +the file access functions in Allegro (eg. load_pcx() and set_config_file()) +can be used to read from datafile objects. Note that you can't write to +datafiles in this way: the fake file is read only. Also, you should save the +file uncompressed or with per-object compression if you are planning on +using this feature. Finally, be aware that the special Allegro object types +aren't the same format as the files you import the data from, so if for +example you want to use load_pcx to read an image from a datafile, you +should import it as a binary data chunk rather than as a BITMAP object. + +

+If you have appended a datafile to the end of your executable with the +exedat utility, use load_datafile("#") to read the entire thing into memory, +load_datafile_object("#", "object_name") to load a specific object, and +pack_fopen("#object_name", F_READ) to read one of the objects directly with +your own code. Note that unless you use the previous functions to load the +appended data, the OS will not load it into memory just because you are +running the program, so you shouldn't have problems attaching datafiles to +your binary larger than the available system memory. + +

+By default, all graphic objects loaded from a datafile will be converted +into the current color depth. This conversion may be both lossy and very +slow, particularly when reducing from truecolor to 256 color formats, so you +may wish to disable it by calling set_color_conversion(COLORCONV_NONE) or +set_color_conversion(COLORCONV_PARTIAL) before your call to load_datafile(). + + + +


+

Custom datafile objects

+ +

+Some of the objects in a datafile, for example palettes and FLI animations, +are simply treated as blocks of binary data, but others are loaded into +special formats such as bitmap structures or compiled sprites. It is +possible to extend the datafile system to support your own custom object +types, eg. map objects for a tile based engine, or level data for a platform +game. Obviously the grabber has no way of understanding this data, but it +will allow you to import binary data from external files, so you can grab +information produced by your own utilities. If you are happy with the data +being loaded as a simple binary block, that is all you need to do, but if +you need to load it into a specific structure, read on... + +

+Your custom objects must be given a unique type ID, which is formed from +four ASCII characters (by convention all uppercase A-Z). If you don't use +all four characters, the string should be padded with spaces (ASCII 32). You +should use this ID when creating the objects in the grabber (select +New/Other and type in the ID string), and in your code you should define an +identifier for the type, eg: +

+   #define DAT_MAPDATA  DAT_ID('M','A','P','D')
+
+You then need to write functions for loading and destroying objects of this +type, in the form: +
+   void *load_mapdata(PACKFILE *f, long size)
+   {
+      /* Allegro will call this function whenever an object of your custom 
+       * type needs to be loaded from a datafile. It will be passed a 
+       * pointer to the file from which the data is to be read, and the size 
+       * of the object in bytes. It should return a pointer to the loaded 
+       * data, which will be stored in the dat field of the datafile object 
+       * structure, or NULL if an error occurs. The file will have been 
+       * opened as a sub-chunk of the main datafile, so it is safe to read 
+       * past the end of the object (if you attempt this, Allegro will 
+       * return EOF), and it is also safe to return before reading all the 
+       * data in the chunk (if you do this, Allegro will skip any unused 
+       * bytes before starting to read the next object). You should _not_ 
+       * close the file when you are done: this will be handled by the 
+       * calling function. To clarify how all this works, here's an example 
+       * implementation of a null-terminated string object:
+       */
+
+      #define MAX_LEN  256
+
+      char buf[MAX_LEN];
+      char *p;
+      int i, c;
+
+      for (i=0; i<;MAX_LEN-1; i++) {
+         if ((c = pack_getc(f)) == EOF)
+            break;
+
+         buf[i] = c;
+      }
+
+      buf[i] = 0;
+
+      p = malloc(i+1);
+      strcpy(p, buf);
+
+      return p;
+   }
+
+   void destroy_mapdata(void *data)
+   {
+      /* Allegro will call this function whenever an object of your custom 
+       * type needs to be destroyed. It will be passed a pointer to the 
+       * object (as returned by the load function), and should free whatever 
+       * memory the object is using. For example, the simple string object 
+       * returned by the above loader could be destroyed with the code:
+       */
+
+      if (data)
+         free(data);
+   }
+
+Finally, before you load your datafile you must tell Allegro about the +custom format, by calling: +
+   register_datafile_object(DAT_MAPDATA, load_mapdata, destroy_mapdata);
+
+It is also possible to integrate support for custom object types directly +into the grabber and dat utilities, by copying some special files into the +tools/plugins directory. This can be used to add whole new object types and +menu commands, or to provide additional import/export routines for the +existing formats. See `tools/plugins/plugins.txt' for an overview of how to +write your own grabber plugins. + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg032.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg032.html new file mode 100644 index 0000000..dc87db4 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg032.html @@ -0,0 +1,561 @@ + + +Allegro Manual: Fixed point math routines + + + + +

Fixed point math routines

+ + + +

+Allegro provides some routines for working with fixed point numbers, and +defines the type `fixed' to be a signed 32-bit integer. The high word is +used for the integer part and the low word for the fraction, giving a range +of -32768 to 32767 and an accuracy of about four or five decimal places. +Fixed point numbers can be assigned, compared, added, subtracted, negated and +shifted (for multiplying or dividing by powers of two) using the normal +integer operators, but you should take care to use the appropriate conversion +routines when mixing fixed point with integer or floating point values. +Writing `fixed_point_1 + fixed_point_2' is OK, but `fixed_point + integer' is +not. + +

+Unfortunately the only advantage of fixed point math routines is that you +don't require a floating point coprocessor to use them. This was great in the +time period of i386 and i486 machines, but stopped being so useful with the +coming of the Pentium class of processors. From Pentium onwards, CPUs have +increased their strength in floating point operations, equaling or even +surpassing integer math performance. + +

+Depending on the type of operations your program may need, using floating +point types may be faster than fixed types if you are targeting a specific +machine class. Allegro comes with a test program in the `allegro/tests' +directory. Its `Misc' menu contains a basic profile test which can give you +an idea of the speed difference between fixed and float types for a few basic +operations on your machine. However, don't forget to profile your program in +real life conditions, tight loop benchmarks are after all artificial. + +

+Fixed point math is considered "add-on" material and is kept only for +backwards compatibility. Whenever a future release of Allegro breaks backwards +compatibility, fixed point math will likely be moved to a separate add-on +package for the very few users who still find it convenient and useful, and +Allegro functions using fixed point math will use other types. + +


+

fixed itofix(int x);

+ Converts an integer to fixed point. This is the same thing as x<<16. + Remember that overflows (trying to convert an integer greater than 32767) + and underflows (trying to convert an integer lesser than -32768) are not + detected even in debug builds! The values simply "wrap around". Example: +
+      fixed number;
+      /* This conversion is OK. */
+      number = itofix(100);
+      ASSERT(fixtoi(number) == 100);
+      number = itofix(64000);
+      /* This check will fail in debug builds. */
+      ASSERT(fixtoi(number) == 64000);
+

Return value: + Returns the value of the integer converted to fixed point ignoring + overflows. + + +

See also: +fixtoi, +ftofix, +fixtof.
+ +
Examples using this: +ex12bit, +ex3buf, +ex3d, +exblend, +excustom, +exfixed, +exlights, +exspline, +exsprite, +exstars.
+
int fixtoi(fixed x);

+ Converts fixed point to integer, rounding as required to the nearest + integer. Example: +
+      int result;
+      /* This will put 33 into `result'. */
+      result = fixtoi(itofix(100) / 3);
+      /* But this will round up to 17. */
+      result = fixtoi(itofix(100) / 6);
+ + +
See also: +itofix, +ftofix, +fixtof, +fixfloor, +fixceil.
+ +
Examples using this: +ex12bit, +ex3buf, +ex3d, +exblend, +excustom, +exlights, +exspline, +exstars, +exupdate.
+
int fixfloor(fixed x);

+ Returns the greatest integer not greater than x. That is, it rounds + towards negative infinity. Example: +
+      int result;
+      /* This will put 33 into `result'. */
+      result = fixfloor(itofix(100) / 3);
+      /* And this will round down to 16. */
+      result = fixfloor(itofix(100) / 6);
+ + +
See also: +fixtoi, +fixceil.
+
int fixceil(fixed x);

+ Returns the smallest integer not less than x. That is, it rounds towards + positive infinity. Example: +
+      int result;
+      /* This will put 34 into `result'. */
+      result = fixceil(itofix(100) / 3);
+      /* This will round up to 17. */
+      result = fixceil(itofix(100) / 6);
+ + +
See also: +fixtoi, +fixfloor.
+
fixed ftofix(double x);

+ Converts a floating point value to fixed point. Unlike itofix(), this + function clamps values which could overflow the type conversion, setting + `errno' to ERANGE in the process if this happens. Example: +
+      fixed number;
+      number = itofix(-40000);
+      ASSERT(fixfloor(number) == -32768);
+      number = itofix(64000);
+      ASSERT(fixfloor(number) == 32767);
+      ASSERT(!errno); /* This will fail. */
+

Return value: + Returns the value of the floating point value converted to fixed point + clamping overflows (and setting `errno'). + + +

See also: +fixtof, +itofix, +fixtoi.
+ +
Examples using this: +exfixed, +exspline, +exupdate.
+
double fixtof(fixed x);

+ Converts fixed point to floating point. Example: +
+      float result;
+      
+      /* This will put 33.33333 into `result'. */
+      result = fixtof(itofix(100) / 3);
+      /* This will put 16.66666 into `result'. */
+      result = fixtof(itofix(100) / 6);
+ + +
See also: +ftofix, +itofix, +fixtoi.
+ +
Examples using this: +exfixed, +exspline, +exstars.
+
fixed fixmul(fixed x, fixed y);

+ A fixed point value can be multiplied or divided by an integer with the + normal `*' and `/' operators. To multiply two fixed point values, though, + you must use this function. + +

+ If an overflow occurs, `errno' will be set and the maximum possible value + will be returned, but `errno' is not cleared if the operation is + successful. This means that if you are going to test for overflow you + should set `errno=0' before calling fixmul(). Example: +

+      fixed result;
+
+      /* This will put 30000 into `result'. */
+      result = fixmul(itofix(10), itofix(3000));
+      /* But this overflows, and sets `errno'. */
+      result = fixmul(itofix(100), itofix(3000));
+      ASSERT(!errno);
+

Return value: + Returns the clamped result of multiplying `x' by `y', setting `errno' to + ERANGE if there was an overflow. + + +

See also: +fixadd, +fixsub, +fixdiv.
+ +
Examples using this: +ex3buf, +excustom, +exfixed, +exspline, +exstars, +exupdate.
+
fixed fixdiv(fixed x, fixed y);

+ A fixed point value can be divided by an integer with the normal `/' + operator. To divide two fixed point values, though, you must use this + function. If a division by zero occurs, `errno' will be set and the + maximum possible value will be returned, but `errno' is not cleared if the + operation is successful. This means that if you are going to test for + division by zero you should set `errno=0' before calling fixdiv(). Example: +
+      fixed result;
+      /* This will put 0.06060 `result'. */
+      result = fixdiv(itofix(2), itofix(33));
+      /* This will put 0 into `result'. */
+      result = fixdiv(0, itofix(-30));
+      /* Sets `errno' and puts -32768 into `result'. */
+      result = fixdiv(itofix(-100), itofix(0));
+      ASSERT(!errno); /* This will fail. */
+

Return value: + Returns the result of dividing `x' by `y'. If `y' is zero, returns the + maximum possible fixed point value and sets `errno' to ERANGE. + + +

See also: +fixadd, +fixsub, +fixmul.
+ +
Examples using this: +exfixed.
+
fixed fixadd(fixed x, fixed y);

+ Although fixed point numbers can be added with the normal '+' integer + operator, that doesn't provide any protection against overflow. If overflow + is a problem, you should use this function instead. It is slower than using + integer operators, but if an overflow occurs it will set `errno' and clamp + the result, rather than just letting it wrap. Example: +
+      fixed result;
+      /* This will put 5035 into `result'. */
+      result = fixadd(itofix(5000), itofix(35));
+      /* Sets `errno' and puts -32768 into `result'. */
+      result = fixadd(itofix(-31000), itofix(-3000));
+      ASSERT(!errno); /* This will fail. */
+

Return value: + Returns the clamped result of adding `x' to `y', setting `errno' to ERANGE + if there was an overflow. + + +

See also: +fixsub, +fixmul, +fixdiv.
+
fixed fixsub(fixed x, fixed y);

+ Although fixed point numbers can be subtracted with the normal '-' integer + operator, that doesn't provide any protection against overflow. If overflow + is a problem, you should use this function instead. It is slower than using + integer operators, but if an overflow occurs it will set `errno' and clamp + the result, rather than just letting it wrap. Example: +
+      fixed result;
+      /* This will put 4965 into `result'. */
+      result = fixsub(itofix(5000), itofix(35));
+      /* Sets `errno' and puts -32768 into `result'. */
+      result = fixsub(itofix(-31000), itofix(3000));
+      ASSERT(!errno); /* This will fail. */
+

Return value: + Returns the clamped result of subtracting `y' from `x', setting `errno' to + ERANGE if there was an overflow. + + +

See also: +fixadd, +fixmul, +fixdiv.
+

Fixed point trig

+The fixed point square root, sin, cos, tan, inverse sin, and inverse cos +functions are implemented using lookup tables, which are very fast but not +particularly accurate. At the moment the inverse tan uses an iterative +search on the tan table, so it is a lot slower than the others. Note that on +machines with very good floating point processors using these functions could +be slower in real life code due to cache misses: it may be faster to wait +a few extra cicles for a floating point sine result rather than wait for the +CPU to fetch the precalculated table from main memory. Always profile your +code. + +

+Angles are represented in a binary format with 256 equal to a full circle, +64 being a right angle and so on. This has the advantage that a simple +bitwise 'and' can be used to keep the angle within the range zero to a full +circle, eliminating all those tiresome 'if (angle >= 360)' checks. + +


+

extern const fixed fixtorad_r;

+ This constant gives a ratio which can be used to convert a fixed point + number in binary angle format to a fixed point number in radians. Example: +
+      fixed rad_angle, binary_angle;
+      /* Set the binary angle to 90 degrees. */
+      binary_angle = 64;
+      /* Now convert to radians (about 1.57). */
+      rad_angle = fixmul(binary_angle, fixtorad_r);
+ + +
See also: +fixmul, +radtofix_r.
+
extern const fixed radtofix_r;

+ This constant gives a ratio which can be used to convert a fixed point + number in radians to a fixed point number in binary angle format. Example: +
+      fixed rad_angle, binary_angle;
+      ...
+      binary_angle = fixmul(rad_angle, radtofix_r);
+ + +
See also: +fixmul, +fixtorad_r.
+
fixed fixsin(fixed x);

+ This function finds the sine of a value using a lookup table. The input + value must be a fixed point binary angle. Example: +
+      fixed angle;
+      int result;
+
+      /* Set the binary angle to 90 degrees. */
+      angle = itofix(64);
+      /* The sine of 90 degrees is one. */
+      result = fixtoi(fixsin(angle));
+      ASSERT(result == 1);
+

Return value: + Returns the sine of a fixed point binary format angle. The return value + will be in radians. + + +

See also: +Fixed point trig.
+ +
Examples using this: +ex12bit, +ex3buf, +exblend, +excustom, +exspline, +exupdate.
+
fixed fixcos(fixed x);

+ This function finds the cosine of a value using a lookup table. The input + value must be a fixed point binary angle. Example: +
+      fixed angle;
+      float result;
+
+      /* Set the binary angle to 45 degrees. */
+      angle = itofix(32);
+      /* The cosine of 45 degrees is about 0.7071. */
+      result = fixtof(fixcos(angle));
+      ASSERT(result > 0.7 && result < 0.71);
+

Return value: + Returns the cosine of a fixed point binary format angle. The return value + will be in radians. + + +

See also: +Fixed point trig.
+ +
Examples using this: +ex12bit, +ex3buf, +exblend, +excustom, +exspline, +exupdate.
+
fixed fixtan(fixed x);

+ This function finds the tangent of a value using a lookup table. The input + value must be a fixed point binary angle. Example: +
+      fixed angle, res_a, res_b;
+      float dif;
+      
+      angle = itofix(37);
+      /* Prove that tan(angle) == sin(angle) / cos(angle). */
+      res_a = fixdiv(fixsin(angle), fixcos(angle));
+      res_b = fixtan(angle);
+      dif = fixtof(fixsub(res_a, res_b));
+      allegro_message("Precision error: %f\n", dif);
+

Return value: + Returns the tangent of a fixed point binary format angle. The return value + will be in radians. + + +

See also: +Fixed point trig.
+
fixed fixasin(fixed x);

+ This function finds the inverse sine of a value using a lookup table. The + input value must be a fixed point value. The inverse sine is defined only + in the domain from `-1' to `1'. Outside of this input range, the function + will set `errno' to EDOM and return zero. Example: +
+      float angle;
+      fixed val;
+
+      /* Sets `val' to a right binary angle (`64'). */
+      val = fixasin(itofix(1));
+      /* Sets `angle' to 0.2405. */
+      angle = fixtof(fixmul(fixasin(ftofix(0.238)), fixtorad_r));
+      /* This will trigger the assert. */
+      val = fixasin(ftofix(-1.09));
+      ASSERT(!errno);
+

Return value: + Returns the inverse sine of a fixed point value, measured as fixed point + binary format angle, or zero if the input was out of the range. All return + values of this function will be in the range `-64' to `64'. + + +

See also: +Fixed point trig.
+
fixed fixacos(fixed x);

+ This function finds the inverse cosine of a value using a lookup table. The + input value must be a fixed point radian. The inverse cosine is defined + only in the domain from `-1' to `1'. Outside of this input range, the + function will set `errno' to EDOM and return zero. Example: +
+      fixed result;
+
+      /* Sets `result' to binary angle 128. */
+      result = fixacos(itofix(-1));
+

Return value: + Returns the inverse sine of a fixed point value, measured as fixed point + binary format angle, or zero if the input was out of range. All return + values of this function will be in the range `0' to `128'. + + +

See also: +Fixed point trig.
+
fixed fixatan(fixed x);

+ This function finds the inverse tangent of a value using a lookup table. + The input value must be a fixed point radian. The inverse tangent is the + value whose tangent is `x'. Example: +
+      fixed result;
+
+      /* Sets `result' to binary angle 13. */
+      result = fixatan(ftofix(0.326));
+

Return value: + Returns the inverse tangent of a fixed point value, measured as a fixed + point binary format angle. + + +

See also: +Fixed point trig.
+
fixed fixatan2(fixed y, fixed x);

+ This is a fixed point version of the libc atan2() routine. It computes the + arc tangent of `y / x', but the signs of both arguments are used to + determine the quadrant of the result, and `x' is permitted to be zero. This + function is useful to convert Cartesian coordinates to polar coordinates. + Example: +
+      fixed result;
+      
+      /* Sets `result' to binary angle 64. */
+      result = fixatan2(itofix(1), 0);
+      /* Sets `result' to binary angle -109. */
+      result = fixatan2(itofix(-1), itofix(-2));
+      /* Fails the assert. */
+      result = fixatan2(0, 0);
+      ASSERT(!errno);
+

Return value: + Returns the arc tangent of `y / x' in fixed point binary format angle, + from `-128' to `128'. If both `x' and `y' are zero, returns zero and sets + `errno' to EDOM. + + +

See also: +Fixed point trig.
+ +
Examples using this: +exlights, +exspline.
+
fixed fixsqrt(fixed x);

+ This finds out the non negative square root of `x'. If `x' is negative, + `errno' is set to EDOM and the function returns zero. + + +
See also: +Fixed point trig.
+ +
Examples using this: +exfixed, +exlights, +exspline.
+
fixed fixhypot(fixed x, fixed y);

+ Fixed point hypotenuse (returns the square root of `x*x + y*y'). This + should be better than calculating the formula yourself manually, since + the error is much smaller. + + +
See also: +Fixed point trig.
+

Fix class

+If you are programming in C++ you can ignore all the above and use the fix +class instead, which overloads a lot of operators to provide automatic +conversion to and from integer and floating point values, and calls the +above routines as they are required. You should not mix the fix class with +the fixed typedef though, because the compiler will mistake the fixed values +for regular integers and insert unnecessary conversions. For example, if x +is an object of class fix, calling fixsqrt(x) will return the wrong result. +You should use the overloaded sqrt(x) or x.sqrt() instead. + +

+On top of that, the Fix class may be slower than using directly the C +functions because of implicit internal conversions from one type to another +which you otherwise could avoid or minimise. Finally, this is the only bit +of C++ in the whole Allegro library, and the developers are certainly going +to move it into add-on space in the next version of Allegro which breaks +source backwards compatibility. + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg033.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg033.html new file mode 100644 index 0000000..670cc00 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg033.html @@ -0,0 +1,530 @@ + + +Allegro Manual: 3D math routines + + + + +

3D math routines

+ + + +

+Allegro contains some 3d helper functions for manipulating vectors, +constructing and using transformation matrices, and doing perspective +projections from 3d space onto the screen. It is not, and never will be, a +fully fledged 3d library (the goal is to supply generic support routines, +not shrink-wrapped graphics code :-) but these functions may be useful for +developing your own 3d code. + +

+Allegro uses a right-handed coordinate system, i.e. if you point the thumb +of your right hand along the x axis, and the index finger along the y axis, +your middle finger points in the direction of the z axis. + +

+Allegro's world coordinate system typically has the positive x axis right, +the positive y axis up, and the positive z axis out of the screen. What +all this means is this: Assume, the viewer is located at the origin (0/0/0) +in world space, looks along the negative z axis (0/0/-1), and is oriented +so up is along the positive y axis (0/1/0). Then something located at +(100/200/-300) will be 100 to the right, 200 above, and 300 in front of the +viewer. Just like in OpenGL. (Of course, both OpenGL and Allegro allow to +use a different system.) Here's a short piece of code demonstrating the +transformation pipeline of a point from world space to the screen. + +

+   /* First, set up the projection viewport. */
+   set_projection_viewport (0, 0, SCREEN_W, SCREEN_H);
+  
+   /* Next, get a camera matrix, depending on the
+    * current viewer position and orientation.
+    */
+   get_camera_matrix_f (&m,
+      0, 0, 0,  /* Viewer position, in this case, 0/0/0. */
+      0, 0, -1, /* Viewer direction, in this case along negative z. */
+      0, 1, 0,  /* Up vector, in this case positive y. */
+      32,       /* The FOV, here 45°. */
+      (float)SCREEN_W / (float)SCREEN_H)); /* Aspect ratio. */
+  
+   /* Applying the matrix transforms the point 100/200/-300
+    * from world space into camera space. The transformation
+    * moves and rotates the point so it is relative to the
+    * camera, scales it according to the FOV and aspect
+    * parameters, and also flips up and front direction -
+    * ready to project the point to the viewport.
+    */
+   apply_matrix_f (&m, 100, 200, -300, &x, &y, &z);
+  
+   /* Finally, the point is projected from
+    * camera space to the screen.
+    */
+   persp_project_f (cx, cy, cz, &sx, &sy);
+ +

+For more details, look at the function descriptions of +set_projection_viewport(), get_camera_matrix(), and persp_project(), as well +as the relevant example programs. + +

+All the 3d math functions are available in two versions: one which uses +fixed point arithmetic, and another which uses floating point. The syntax +for these is identical, but the floating point functions and structures are +postfixed with '_f', eg. the fixed point function cross_product() has a +floating point equivalent cross_product_f(). If you are programming in C++, +Allegro also overloads these functions for use with the 'fix' class. + +

+3d transformations are accomplished by the use of a modelling matrix. This +is a 4x4 array of numbers that can be multiplied with a 3d point to produce +a different 3d point. By putting the right values into the matrix, it can be +made to do various operations like translation, rotation, and scaling. The +clever bit is that you can multiply two matrices together to produce a third +matrix, and this will have the same effect on points as applying the +original two matrices one after the other. For example, if you have one +matrix that rotates a point and another that shifts it sideways, you can +combine them to produce a matrix that will do the rotation and the shift in +a single step. You can build up extremely complex transformations in this +way, while only ever having to multiply each point by a single matrix. + +

+Allegro actually cheats in the way it implements the matrix structure. +Rotation and scaling of a 3d point can be done with a simple 3x3 matrix, but +in order to translate it and project it onto the screen, the matrix must be +extended to 4x4, and the point extended into 4d space by the addition of an +extra coordinate, w=1. This is a bad thing in terms of efficiency, but +fortunately an optimisation is possible. Given the 4x4 matrix: +

+   ( a, b, c, d )
+   ( e, f, g, h )
+   ( i, j, k, l )
+   ( m, n, o, p )
+
+a pattern can be observed in which parts of it do what. The top left 3x3 +grid implements rotation and scaling. The three values in the top right +column (d, h, and l) implement translation, and as long as the matrix is +only used for affine transformations, m, n and o will always be zero and p +will always be 1. If you don't know what affine means, read Foley & Van +Damme: basically it covers scaling, translation, and rotation, but not +projection. Since Allegro uses a separate function for projection, the +matrix functions only need to support affine transformations, which means +that there is no need to store the bottom row of the matrix. Allegro +implicitly assumes that it contains (0,0,0,1), and optimises the matrix +manipulation functions accordingly. Read chapter "Structures and types +defined by Allegro" for an internal view of the MATRIX/_f structures. + +


+

extern MATRIX identity_matrix;

+
extern MATRIX_f identity_matrix_f;

+ Global variables containing the 'do nothing' identity matrix. Multiplying + by the identity matrix has no effect. + +


+

void get_translation_matrix(MATRIX *m, fixed x, fixed y, fixed z);

+
void get_translation_matrix_f(MATRIX_f *m, float x, float y, float z);

+ Constructs a translation matrix, storing it in m. When applied to the + point (px, py, pz), this matrix will produce the point (px+x, py+y, + pz+z). In other words, it moves things sideways. + + +
See also: +apply_matrix, +get_transformation_matrix, +qtranslate_matrix.
+ +
Examples using this: +exstars.
+
void get_scaling_matrix(MATRIX *m, fixed x, fixed y, fixed z);

+
void get_scaling_matrix_f(MATRIX_f *m, float x, float y, float z);

+ Constructs a scaling matrix, storing it in m. When applied to the point + (px, py, pz), this matrix will produce the point (px*x, py*y, pz*z). In + other words, it stretches or shrinks things. + + +
See also: +apply_matrix, +get_transformation_matrix, +qscale_matrix.
+
void get_x_rotate_matrix(MATRIX *m, fixed r);

+
void get_x_rotate_matrix_f(MATRIX_f *m, float r);

+ Construct X axis rotation matrices, storing them in m. When applied to a + point, these matrices will rotate it about the X axis by the specified + angle (given in binary, 256 degrees to a circle format). + + +
See also: +apply_matrix, +get_rotation_matrix, +get_y_rotate_matrix, +get_z_rotate_matrix.
+
void get_y_rotate_matrix(MATRIX *m, fixed r);

+
void get_y_rotate_matrix_f(MATRIX_f *m, float r);

+ Construct Y axis rotation matrices, storing them in m. When applied to a + point, these matrices will rotate it about the Y axis by the specified + angle (given in binary, 256 degrees to a circle format). + + +
See also: +apply_matrix, +get_rotation_matrix, +get_x_rotate_matrix, +get_z_rotate_matrix.
+
void get_z_rotate_matrix(MATRIX *m, fixed r);

+
void get_z_rotate_matrix_f(MATRIX_f *m, float r);

+ Construct Z axis rotation matrices, storing them in m. When applied to a + point, these matrices will rotate it about the Z axis by the specified + angle (given in binary, 256 degrees to a circle format). + + +
See also: +apply_matrix, +get_rotation_matrix, +get_x_rotate_matrix, +get_y_rotate_matrix.
+
void get_rotation_matrix(MATRIX *m, fixed x, fixed y, fixed z);

+
void get_rotation_matrix_f(MATRIX_f *m, float x, float y, float z);

+ Constructs a transformation matrix which will rotate points around all + three axes by the specified amounts (given in binary, 256 degrees to a + circle format). The direction of rotation can simply be found out with + the right-hand rule: Point the dumb of your right hand towards the + origin along the axis of rotation, and the fingers will curl in the + positive direction of rotation. E.g. if you rotate around the y axis, + and look at the scene from above, a positive angle will rotate in + clockwise direction. + + +
See also: +apply_matrix, +get_transformation_matrix, +get_vector_rotation_matrix, +get_x_rotate_matrix, +get_y_rotate_matrix, +get_z_rotate_matrix, +get_align_matrix.
+ +
Examples using this: +ex12bit, +exquat, +exstars.
+
void get_align_matrix(MATRIX *m, fixed xfront, yfront, zfront, + fixed xup, fixed yup, fixed zup);

+ Rotates a matrix so that it is aligned along the specified coordinate + vectors (they need not be normalized or perpendicular, but the up and + front must not be equal). A front vector of 0,0,-1 and up vector of 0,1,0 + will return the identity matrix. + + +
See also: +apply_matrix, +get_camera_matrix.
+
void get_align_matrix_f(MATRIX *m, float xfront, yfront, zfront, + float xup, yup, zup);

+ Floating point version of get_align_matrix(). + + +
See also: +get_align_matrix.
+
void get_vector_rotation_matrix(MATRIX *m, fixed x, y, z, fixed a);

+
void get_vector_rotation_matrix_f(MATRIX_f *m, float x, y, z, float a);

+ Constructs a transformation matrix which will rotate points around the + specified x,y,z vector by the specified angle (given in binary, 256 + degrees to a circle format). + + +
See also: +apply_matrix, +get_rotation_matrix, +get_align_matrix.
+ +
Examples using this: +excamera.
+
void get_transformation_matrix(MATRIX *m, fixed scale, + fixed xrot, yrot, zrot, x, y, z);

+ Constructs a transformation matrix which will rotate points around all + three axes by the specified amounts (given in binary, 256 degrees to a + circle format), scale the result by the specified amount (pass 1 for no + change of scale), and then translate to the requested x, y, z position. + + +
See also: +apply_matrix, +get_rotation_matrix, +get_scaling_matrix, +get_translation_matrix.
+ +
Examples using this: +ex3d, +exstars.
+
void get_transformation_matrix_f(MATRIX_f *m, float scale, + float xrot, yrot, zrot, x, y, z);

+ Floating point version of get_transformation_matrix(). + + +
See also: +get_transformation_matrix.
+ +
Examples using this: +exzbuf.
+
void get_camera_matrix(MATRIX *m, fixed x, y, z, xfront, yfront, zfront, + fixed xup, yup, zup, fov, aspect);

+ Constructs a camera matrix for translating world-space objects into a + normalised view space, ready for the perspective projection. The x, y, + and z parameters specify the camera position, xfront, yfront, and zfront + are the 'in front' vector specifying which way the camera is facing + (this can be any length: normalisation is not required), and xup, yup, + and zup are the 'up' direction vector. + +

+ The fov parameter specifies the field of view (ie. width of the camera + focus) in binary, 256 degrees to the circle format. For typical + projections, a field of view in the region 32-48 will work well. 64 + (90°) applies no extra scaling - so something which is one unit away + from the viewer will be directly scaled to the viewport. A bigger FOV + moves you closer to the viewing plane, so more objects will appear. A + smaller FOV moves you away from the viewing plane, which means you see a + smaller part of the world. + +

+ Finally, the aspect ratio is used to scale the Y dimensions of the image + relative to the X axis, so you can use it to adjust the proportions of + the output image (set it to 1 for no scaling - but keep in mind that the + projection also performs scaling according to the viewport size). + Typically, you will pass (float)w/(float)h, where w and h are the + parameters you passed to set_projection_viewport. + +

+ Note that versions prior to 4.1.0 multiplied this aspect ratio by 4/3. + + +

See also: +apply_matrix, +get_align_matrix, +set_projection_viewport, +persp_project.
+
void get_camera_matrix_f(MATRIX_f *m, float x, y, z, xfront, yfront, zfront, + float xup, yup, zup, fov, aspect);

+ Floating point version of get_camera_matrix(). + + +
See also: +get_camera_matrix.
+ +
Examples using this: +excamera, +exquat.
+
void qtranslate_matrix(MATRIX *m, fixed x, fixed y, fixed z);

+
void qtranslate_matrix_f(MATRIX_f *m, float x, float y, float z);

+ Optimised routine for translating an already generated matrix: this + simply adds in the translation offset, so there is no need to build two + temporary matrices and then multiply them together. + + +
See also: +get_translation_matrix.
+
void qscale_matrix(MATRIX *m, fixed scale);

+
void qscale_matrix_f(MATRIX_f *m, float scale);

+ Optimised routine for scaling an already generated matrix: this simply + adds in the scale factor, so there is no need to build two temporary + matrices and then multiply them together. + + +
See also: +get_scaling_matrix.
+
void matrix_mul(const MATRIX *m1, const MATRIX *m2, MATRIX *out);

+
void matrix_mul_f(const MATRIX_f *m1, const MATRIX_f *m2, MATRIX_f *out);

+ Multiplies two matrices, storing the result in out (this may be a + duplicate of one of the input matrices, but it is faster when the inputs + and output are all different). The resulting matrix will have the same + effect as the combination of m1 and m2, ie. when applied to a point p, (p + * out) = ((p * m1) * m2). Any number of transformations can be + concatenated in this way. Note that matrix multiplication is not + commutative, ie. matrix_mul(m1, m2) != matrix_mul(m2, m1). + + +
See also: +apply_matrix.
+ +
Examples using this: +exquat, +exscn3d.
+
fixed vector_length(fixed x, fixed y, fixed z);

+
float vector_length_f(float x, float y, float z);

+ Calculates the length of the vector (x, y, z), using that good 'ole + Pythagoras theorem. + + +
See also: +normalize_vector.
+
void normalize_vector(fixed *x, fixed *y, fixed *z);

+
void normalize_vector_f(float *x, float *y, float *z);

+ Converts the vector (*x, *y, *z) to a unit vector. This points in the + same direction as the original vector, but has a length of one. + + +
See also: +vector_length, +dot_product, +cross_product.
+ +
Examples using this: +exstars.
+
fixed dot_product(fixed x1, y1, z1, x2, y2, z2);

+
float dot_product_f(float x1, y1, z1, x2, y2, z2);

+ Calculates the dot product (x1, y1, z1) . (x2, y2, z2), returning the + result. + + +
See also: +cross_product, +normalize_vector.
+ +
Examples using this: +exstars.
+
void cross_product(fixed x1, y1, z1, x2, y2, z2, *xout, *yout, *zout);

+
void cross_product_f(float x1, y1, z1, x2, y2, z2, *xout, *yout, *zout);

+ Calculates the cross product (x1, y1, z1) x (x2, y2, z2), storing the + result in (*xout, *yout, *zout). The cross product is perpendicular to + both of the input vectors, so it can be used to generate polygon normals. + + +
See also: +dot_product, +polygon_z_normal, +normalize_vector.
+ +
Examples using this: +exstars.
+
fixed polygon_z_normal(const V3D *v1, const V3D *v2, const V3D *v3);

+
float polygon_z_normal_f(const V3D_f *v1, const V3D_f *v2, const V3D_f *v3);

+ Finds the Z component of the normal vector to the specified three + vertices (which must be part of a convex polygon). This is used mainly in + back-face culling. The back-faces of closed polyhedra are never visible + to the viewer, therefore they never need to be drawn. This can cull on + average half the polygons from a scene. If the normal is negative the + polygon can safely be culled. If it is zero, the polygon is perpendicular + to the screen. + +

+ However, this method of culling back-faces must only be used once the X and + Y coordinates have been projected into screen space using persp_project() + (or if an orthographic (isometric) projection is being used). Note that + this function will fail if the three vertices are co-linear (they lie on + the same line) in 3D space. + + +

See also: +cross_product.
+ +
Examples using this: +ex3d.
+
void apply_matrix(const MATRIX *m, fixed x, y, z, *xout, *yout, *zout);

+
void apply_matrix_f(const MATRIX_f *m, float x, y, z, *xout, *yout, *zout);

+ Multiplies the point (x, y, z) by the transformation matrix m, storing + the result in (*xout, *yout, *zout). + + +
See also: +matrix_mul.
+ +
Examples using this: +ex12bit, +ex3d, +exstars.
+
void set_projection_viewport(int x, int y, int w, int h);

+ Sets the viewport used to scale the output of the persp_project() + function. Pass the dimensions of the screen area you want to draw onto, + which will typically be 0, 0, SCREEN_W, and SCREEN_H. Also don't forget + to pass an appropriate aspect ratio to get_camera_matrix later. The + width and height you specify here will determine how big your viewport + is in 3d space. So if an object in your 3D space is w units wide, it + will fill the complete screen when you run into it (i.e., if it has a + distance of 1.0 after the camera matrix was applied. The fov and + aspect-ratio parameters to get_camera_matrix also apply some scaling + though, so this isn't always completely true). If you pass -1/-1/2/2 as + parameters, no extra scaling will be performed by the projection. + + +
See also: +persp_project, +get_camera_matrix.
+ +
Examples using this: +ex3d, +excamera, +exquat, +exscn3d, +exstars, +exzbuf.
+
void persp_project(fixed x, fixed y, fixed z, fixed *xout, fixed *yout);

+
void persp_project_f(float x, float y, float z, float *xout, float *yout);

+ Projects the 3d point (x, y, z) into 2d screen space, storing the result + in (*xout, *yout) and using the scaling parameters previously set by + calling set_projection_viewport(). This function projects from the + normalized viewing pyramid, which has a camera at the origin and facing + along the positive z axis. The x axis runs left/right, y runs up/down, + and z increases with depth into the screen. The camera has a 90 degree + field of view, ie. points on the planes x=z and -x=z will map onto the + left and right edges of the screen, and the planes y=z and -y=z map to + the top and bottom of the screen. If you want a different field of view + or camera location, you should transform all your objects with an + appropriate viewing matrix, eg. to get the effect of panning the camera + 10 degrees to the left, rotate all your objects 10 degrees to the right. + + + + +
See also: +set_projection_viewport, +get_camera_matrix.
+ +
Examples using this: +ex3d, +exstars.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg034.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg034.html new file mode 100644 index 0000000..358a5e3 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg034.html @@ -0,0 +1,136 @@ + + +Allegro Manual: Quaternion math routines + + + + +

Quaternion math routines

+ + + +

+Quaternions are an alternate way to represent the rotation part of a +transformation, and can be easier to manipulate than matrices. As with a +matrix, you can encode a geometric transformations in one, concatenate +several of them to merge multiple transformations, and apply them to a +vector, but they can only store pure rotations. The big advantage is that +you can accurately interpolate between two quaternions to get a part-way +rotation, avoiding the gimbal problems of the more conventional euler angle +interpolation. + +

+Quaternions only have floating point versions, without any _f suffix. Other +than that, most of the quaternion functions correspond with a matrix +function that performs a similar operation. + +

+Quaternion means 'of four parts', and that's exactly what it is. Here is the +structure: +

+   typedef struct QUAT
+   {
+      float w, x, y, z;
+   }
+
+You will have lots of fun figuring out what these numbers actually mean, but +that is beyond the scope of this documentation. Quaternions do work -- trust +me. + +


+

extern QUAT identity_quat;

+ Global variable containing the 'do nothing' identity quaternion. + Multiplying by the identity quaternion has no effect. + +


+

void get_x_rotate_quat(QUAT *q, float r);

+
void get_y_rotate_quat(QUAT *q, float r);

+
void get_z_rotate_quat(QUAT *q, float r);

+ Construct axis rotation quaternions, storing them in q. When applied to a + point, these quaternions will rotate it about the relevant axis by the + specified angle (given in binary, 256 degrees to a circle format). + +


+

void get_rotation_quat(QUAT *q, float x, float y, float z);

+ Constructs a quaternion that will rotate points around all three axes by + the specified amounts (given in binary, 256 degrees to a circle format). + + +
Examples using this: +exquat.
+
void get_vector_rotation_quat(QUAT *q, float x, y, z, float a);

+ Constructs a quaternion that will rotate points around the specified + x,y,z vector by the specified angle (given in binary, 256 degrees to a + circle format). + +


+

void quat_to_matrix(const QUAT *q, MATRIX_f *m);

+ Constructs a rotation matrix from a quaternion. + + +
Examples using this: +exquat.
+
void matrix_to_quat(const MATRIX_f *m, QUAT *q);

+ Constructs a quaternion from a rotation matrix. Translation is discarded + during the conversion. Use get_align_matrix_f() if the matrix is not + orthonormalized, because strange things may happen otherwise. + +


+

void quat_mul(const QUAT *p, const QUAT *q, QUAT *out);

+ Multiplies two quaternions, storing the result in out. The resulting + quaternion will have the same effect as the combination of p and q, ie. + when applied to a point, (point * out) = ((point * p) * q). Any number of + rotations can be concatenated in this way. Note that quaternion + multiplication is not commutative, ie. quat_mul(p, q) != quat_mul(q, p). + +


+

void apply_quat(const QUAT *q, float x, y, z, *xout, *yout, *zout);

+ Multiplies the point (x, y, z) by the quaternion q, storing the result in + (*xout, *yout, *zout). This is quite a bit slower than apply_matrix_f(), + so only use it to translate a few points. If you have many points, it is + much more efficient to call quat_to_matrix() and then use + apply_matrix_f(). + +


+

void quat_interpolate(const QUAT *from, const QUAT *to, float t, QUAT *out);

+ Constructs a quaternion that represents a rotation between from and to. + The argument t can be anything between 0 and 1 and represents where + between from and to the result will be. 0 returns from, 1 returns to, and + 0.5 will return a rotation exactly in between. The result is copied to + out. This function will create the short rotation (less than 180 degrees) + between from and to. + + +
Examples using this: +exquat.
+
void quat_slerp(const QUAT *from, const QUAT *to, float t, QUAT *out, int how);

+ The same as quat_interpolate(), but allows more control over how the + rotation is done. The how parameter can be any one of the values: +
+      QUAT_SHORT  - like quat_interpolate(), use shortest path
+      QUAT_LONG   - rotation will be greater than 180 degrees
+      QUAT_CW     - rotate clockwise when viewed from above
+      QUAT_CCW    - rotate counterclockwise when viewed from above
+      QUAT_USER   - the quaternions are interpolated exactly as
+                    given
+
+ + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg035.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg035.html new file mode 100644 index 0000000..998bce6 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg035.html @@ -0,0 +1,1058 @@ + + +Allegro Manual: GUI routines + + + + +

GUI routines

+ + + +

+Allegro contains an object-oriented dialog manager, which was originally +based on the Atari GEM system (form_do(), objc_draw(), etc: old ST +programmers will know what we are talking about :-) You can use the GUI as-is +to knock out simple interfaces for things like the test program and grabber +utility, or you can use it as a basis for more complicated systems of your +own. Allegro lets you define your own object types by writing new dialog +procedures, so you can take complete control over the visual aspects of the +interface while still using Allegro to handle input from the mouse, +keyboard, joystick, etc. + +

+A GUI dialog is stored as an array of DIALOG objects, read chapter +"Structures and types defined by Allegro" for an internal description of the +DIALOG structure. The array should end with an object which has the proc +pointer set to NULL. Each object has a flags field which may contain any +combination of the bit flags: +

+   D_EXIT          - this object should close the dialog when it is
+                     clicked
+   D_SELECTED      - this object is selected
+   D_GOTFOCUS      - this object has got the input focus
+   D_GOTMOUSE      - the mouse is currently on top of this object
+   D_HIDDEN        - this object is hidden and inactive
+   D_DISABLED      - this object is greyed-out and inactive
+   D_DIRTY         - this object needs to be redrawn
+   D_INTERNAL      - don't use this! It is for internal use by the
+                     library...
+   D_USER          - any powers of two above this are free for your
+                     own use
+
+Each object is controlled by a dialog procedure, which is stored in the proc +pointer. This will be called by the dialog manager whenever any action +concerning the object is required, or you can call it directly with the +object_message() function. The dialog procedure should follow the form: +
+   int foo(int msg, DIALOG *d, int c);
+
+It will be passed a flag (msg) indicating what action it should perform, a +pointer to the object concerned (d), and if msg is MSG_CHAR or MSG_XCHAR, +the key that was pressed (c). Note that d is a pointer to a specific object, +and not to the entire dialog. + +

+The dialog procedure should return one of the values: +

+   D_O_K          - normal return status
+   D_CLOSE        - tells the dialog manager to close the dialog
+   D_REDRAW       - tells the dialog manager to redraw the entire
+                    dialog
+   D_REDRAWME     - tells the dialog manager to redraw the current
+                    object
+   D_WANTFOCUS    - requests that the input focus be given to this
+                    object
+   D_USED_CHAR    - MSG_CHAR and MSG_XCHAR return this if they used
+                    the key
+
+Dialog procedures may be called with any of the messages: + +

+MSG_START:
+ Tells the object to initialise itself. The dialog manager sends this to + all the objects in a dialog just before it displays the dialog. + +

+MSG_END:
+ Sent to all objects when closing a dialog, allowing them to perform + whatever cleanup operations they require. + +

+MSG_DRAW:
+ Tells the object to draw itself onto the screen. The mouse pointer will + be turned off when this message is sent, so the drawing code does not + need to worry about it. + +

+MSG_CLICK:
+ Informs the object that a mouse button has been clicked while the mouse + was on top of the object. Typically an object will perform its own mouse + tracking as long as the button is held down, and only return from this + message handler when it is released. + +

+ If you process this message, use the functions gui_mouse_*() to read the + state of the mouse. + +

+MSG_DCLICK:
+ Sent when the user double-clicks on an object. A MSG_CLICK will be sent + when the button is first pressed, then MSG_DCLICK if it is released and + pressed again within a short space of time. + +

+ If you process this message, use the functions gui_mouse_*() to read the + state of the mouse. + +

+MSG_KEY:
+ Sent when the keyboard shortcut for the object is pressed, or if enter, + space, or a joystick button is pressed while it has the input focus. + +

+MSG_CHAR:
+ When a key is pressed, this message is sent to the object that has the + input focus, with a readkey() format character code (ASCII value in the + low byte, scancode in the high byte) as the c parameter. If the object + deals with the keypress it should return D_USED_CHAR, otherwise it should + return D_O_K to allow the default keyboard interface to operate. If you + need to access Unicode character input, you should use MSG_UCHAR instead + of MSG_CHAR. + +

+MSG_UCHAR:
+ If an object ignores the MSG_CHAR input, this message will be sent + immediately after it, passed the full Unicode key value as the c + parameter. This enables you to read character codes greater than 255, but + cannot tell you anything about the scancode: if you need to know that, + use MSG_CHAR instead. This handler should return D_USED_CHAR if it + processed the input, or D_O_K otherwise. + +

+MSG_XCHAR:
+ When a key is pressed, Allegro will send a MSG_CHAR and MSG_UCHAR to the + object with the input focus. If this object doesn't process the key (ie. + it returns D_O_K rather than D_USED_CHAR), the dialog manager will look + for an object with a matching keyboard shortcut in the key field, and + send it a MSG_KEY. If this fails, it broadcasts a MSG_XCHAR to all + objects in the dialog, allowing them to respond to special keypresses + even when they don't have the input focus. Normally you should ignore + this message (return D_O_K rather than D_USED_CHAR), in which case + Allegro will perform default actions such as moving the focus in response + to the arrow keys and closing the dialog if ESC is pressed. + +

+MSG_WANTFOCUS:
+ Queries whether an object is willing to accept the input focus. It should + return D_WANTFOCUS if it does, or D_O_K if it isn't interested in getting + user input. + +

+MSG_GOTFOCUS:
+MSG_LOSTFOCUS:
+ Sent whenever an object gains or loses the input focus. These messages + will always be followed by a MSG_DRAW, to let objects display themselves + differently when they have the input focus. If you return D_WANTFOCUS in + response to a MSG_LOSTFOCUS event, this will prevent your object from + losing the focus when the mouse moves off it onto the screen background + or some inert object, so it will only lose the input focus when some + other object is ready to take over the focus (this trick is used by the + d_edit_proc() object). + +

+MSG_GOTMOUSE:
+MSG_LOSTMOUSE:
+ Sent when the mouse moves on top of or away from an object. Unlike the + focus messages, these are not followed by a MSG_DRAW, so if the object is + displayed differently when the mouse is on top of it, it is responsible + for redrawing itself in response to these messages. + +

+MSG_IDLE:
+ Sent whenever the dialog manager has nothing better to do. + +

+MSG_RADIO:
+ Sent by radio button objects to deselect other buttons in the same group + when they are clicked. The group number is passed in the c message + parameter. + +

+MSG_WHEEL:
+ Sent to the focused object whenever the mouse wheel moves. The c message + parameter contains the number of clicks. + +

+MSG_LPRESS, MSG_MPRESS, MSG_RPRESS:
+ Sent when the corresponding mouse button is pressed. + +

+MSG_LRELEASE, MSG_MRELEASE, MSG_RRELEASE:
+ Sent when the corresponding mouse button is released. + +

+MSG_USER:
+ The first free message value. Any numbers from here on (MSG_USER, + MSG_USER+1, MSG_USER+2, ... MSG_USER+n) are free to use for whatever you + like. + +

+Allegro provides several standard dialog procedures. You can use these as +they are to provide simple user interface objects, or you can call them from +within your own dialog procedures, resulting in a kind of OOP inheritance. +For instance, you could make an object which calls d_button_proc to draw +itself, but handles the click message in a different way, or an object which +calls d_button_proc for everything except drawing itself, so it would behave +like a normal button but could look completely different. + +

+Since the release of Allegro version 3.9.33 (CVS), some GUI objects and +menus are being drawn differently unlike in previous Allegro versions. The +changes are the following: +


+ +

+Menus had been forgotten during the changes for 3.9.33 (CVS), so they were +still drawn too large until version 4.1.0. + +


+

int d_clear_proc(int msg, DIALOG *d, int c);

+ This just clears the screen when it is drawn. Useful as the first object + in a dialog. + + +
Examples using this: +excustom, +exgui.
+
int d_box_proc(int msg, DIALOG *d, int c);

+
int d_shadow_box_proc(int msg, DIALOG *d, int c);

+ These draw boxes onto the screen, with or without a shadow. + + +
Examples using this: +exgui, +exrgbhsv.
+
int d_bitmap_proc(int msg, DIALOG *d, int c);

+ This draws a bitmap onto the screen, which should be pointed to by the + dp field. + + +
Examples using this: +exgui, +exrgbhsv.
+
int d_text_proc(int msg, DIALOG *d, int c);

+
int d_ctext_proc(int msg, DIALOG *d, int c);

+
int d_rtext_proc(int msg, DIALOG *d, int c);

+ These draw text onto the screen. The dp field should point to the string + to display. d_ctext_proc() centers the string horizontally, and + d_rtext_proc() right aligns it. Any '&' characters in the string will + be replaced with lines underneath the following character, for displaying + keyboard shortcuts (as in MS Windows). To display a single ampersand, put + "&&". To draw the text in something other than the default font, set the + dp2 field to point to your custom font data. + + +
Examples using this: +exgui, +exrgbhsv.
+
int d_button_proc(int msg, DIALOG *d, int c);

+ A button object (the dp field points to the text string). This object can + be selected by clicking on it with the mouse or by pressing its keyboard + shortcut. If the D_EXIT flag is set, selecting it will close the dialog, + otherwise it will toggle on and off. Like d_text_proc(), ampersands can + be used to display the keyboard shortcut of the button. + + +
Examples using this: +excustom, +exgui.
+
int d_check_proc(int msg, DIALOG *d, int c);

+ This is an example of how you can derive objects from other objects. Most + of the functionality comes from d_button_proc(), but it displays itself + as a check box. If the d1 field is non-zero, the text will be printed to + the right of the check, otherwise it will be on the left. + +

+ Note: the object width should allow space for the text as well as the + check box (which is square, with sides equal to the object height). + + +

Examples using this: +excustom, +exgui.
+
int d_radio_proc(int msg, DIALOG *d, int c);

+ A radio button object. A dialog can contain any number of radio button + groups: selecting a radio button causes other buttons within the same + group to be deselected. The dp field points to the text string, d1 + specifies the group number, and d2 is the button style (0=circle, + 1=square). + + +
Examples using this: +exgui.
+
int d_icon_proc(int msg, DIALOG *d, int c);

+ A bitmap button. The fg color is used for the dotted line showing focus, + and the bg color for the shadow used to fill in the top and left sides of + the button when "pressed". d1 is the "push depth", ie. the number of + pixels the icon will be shifted to the right and down when selected + (default 2) if there is no "selected" image. d2 is the distance by which + the dotted line showing focus is indented (default 2). dp points to a + bitmap for the icon, while dp2 and dp3 are the selected and disabled + images respectively (optional, may be NULL). + + +
Examples using this: +exgui.
+
int d_keyboard_proc(int msg, DIALOG *d, int c);

+ This is an invisible object for implementing keyboard shortcuts. You can + put an ASCII code in the key field of the dialog object (a character such + as 'a' to respond to a simple keypress, or a number 1-26 to respond to a + control key a-z), or you can put a keyboard scancode in the d1 and/or d2 + fields. When one of these keys is pressed, the object will call the + function pointed to by dp. This should return an int, which will be + passed back to the dialog manager, so it can return D_O_K, D_REDRAW, + D_CLOSE, etc. + + +
Examples using this: +exgui.
+
int d_edit_proc(int msg, DIALOG *d, int c);

+ An editable text object (the dp field points to the string). When it has + the input focus (obtained by clicking on it with the mouse), text can be + typed into this object. The d1 field specifies the maximum number of + characters that it will accept, and d2 is the text cursor position within + the string. + +

+ Note: dp must point to a buffer at least (d1 + 1) * 4 bytes long because, + depending on the encoding format in use, a single character can occupy + up to 4 bytes and room must be reserved for the terminating null character. + + +

Examples using this: +excustom, +exgui.
+
int d_list_proc(int msg, DIALOG *d, int c);

+ A list box object. This will allow the user to scroll through a list of + items and to select one by clicking or with the arrow keys. If the D_EXIT + flag is set, double clicking on a list item will close the dialog. The + index of the selected item is held in the d1 field, and d2 is used to + store how far it has scrolled through the list. The dp field points to a + function which will be called to obtain information about the contents of + the list. This should follow the form: +
+      char *foobar(int index, int *list_size);
+
+ If index is zero or positive, the function should return a pointer to the + string which is to be displayed at position index in the list. If index + is negative, it should return NULL and list_size should be set to the + number of items in the list. + +

+ To create a multiple selection listbox, set the dp2 field to an array of + byte flags indicating the selection state of each list item (non-zero for + selected entries). This table must be at least as big as the number of + objects in the list! + + +

Examples using this: +exgui.
+
int d_text_list_proc(int msg, DIALOG *d, int c);

+ Like d_list_proc, but allows the user to type in the first few characters + of a listbox entry in order to select it. Uses dp3 internally, so you + mustn't store anything important there yourself. + + +
Examples using this: +exgui.
+
int d_textbox_proc(int msg, DIALOG *d, int c);

+ A text box object. The dp field points to the text which is to be + displayed in the box. If the text is long, there will be a vertical + scrollbar on the right hand side of the object which can be used to + scroll through the text. The default is to print the text with word + wrapping, but if the D_SELECTED flag is set, the text will be printed + with character wrapping. The d1 field is used internally to store the + number of lines of text, and d2 is used to store how far it has scrolled + through the text. + + +
Examples using this: +exgui.
+
int d_slider_proc(int msg, DIALOG *d, int c);

+ A slider control object. This object holds a value in d2, in the range + from 0 to d1. It will display as a vertical slider if h is greater than + or equal to w, otherwise it will display as a horizontal slider. The dp + field can contain an optional bitmap to use for the slider handle, and + dp2 can contain an optional callback function, which is called each time + d2 changes. The callback function should have the following prototype: +
+      int function(void *dp3, int d2);
+
+ The d_slider_proc object will return the value of the callback function. + + +
Examples using this: +exgui, +exrgbhsv.
+
int d_menu_proc(int msg, DIALOG *d, int c);

+ This object is a menu bar which will drop down child menus when it is + clicked or if an alt+key corresponding to one of the shortcuts in the + menu is pressed. It ignores a lot of the fields in the dialog structure, + in particular the color is taken from the gui_*_color variables, and the + width and height are calculated automatically (the w and h fields from + the DIALOG are only used as a minimum size.) The dp field points to an + array of menu structures: see do_menu() for more information. The top + level menu will be displayed as a horizontal bar, but when child menus + drop down from it they will be in the normal vertical format used by + do_menu(). When a menu item is selected, the return value from the menu + callback function is passed back to the dialog manager, so your callbacks + should return D_O_K, D_REDRAW, or D_CLOSE. + + +
See also: +GUI menus, +active_menu, +gui_menu_draw_menu.
+ +
Examples using this: +exgui.
+
int d_yield_proc(int msg, DIALOG *d, int c);

+ An invisible helper object that yields timeslices for the scheduler (if + the system supports it) when the GUI has nothing to do but waiting for + user actions. You should put one instance of this object in each dialog + array because it may be needed on systems with an unusual scheduling + algorithm (for instance QNX) in order to make the GUI fully responsive. + + +
See also: +rest.
+ +
Examples using this: +exgui.
+

GUI variables

+The behaviour of the dialog manager can be controlled by the following +global variables. + +


+

extern int gui_mouse_focus;

+ If set, the input focus follows the mouse pointer around the dialog, + otherwise a click is required to move it. + +


+

extern int gui_fg_color;

+
extern int gui_bg_color;

+ The foreground and background colors for the standard dialogs (alerts, + menus, and the file selector). They default to 255 and 0. + + +
See also: +gui_mg_color, +set_dialog_color.
+ +
Examples using this: +exgui.
+
extern int gui_mg_color;

+ The color used for displaying greyed-out dialog objects (with the + D_DISABLED flag set). Defaults to 8. + + +
See also: +gui_fg_color, +set_dialog_color.
+ +
Examples using this: +exgui.
+
extern int gui_font_baseline;

+ If set to a non-zero value, adjusts the keyboard shortcut underscores to + account for the height of the descenders in your font. + +


+

extern int (*gui_mouse_x)();

+
extern int (*gui_mouse_y)();

+
extern int (*gui_mouse_z)();

+
extern int (*gui_mouse_b)();

+ Hook functions, used by the GUI routines whenever they need to access the + mouse state. By default these just return copies of the mouse_x, mouse_y, + mouse_z, and mouse_b variables, but they could be used to offset or scale + the mouse position, or read input from a different source entirely. + +

+

GUI font

+You can change the global 'font' pointer to make the GUI objects use +something other than the standard 8x8 font. The standard dialog procedures, +menus, and alert boxes, will work with fonts of any size, but the +gfx_mode_select() dialog will look wrong with anything other than 8x8 fonts. + +


+

int gui_textout_ex(BITMAP *bmp, const char *s, int x, y, color, bg, centre);

+ Helper function for use by the GUI routines. Draws a text string onto the + screen, interpreting the '&' character as an underbar for displaying + keyboard shortcuts. Returns the width of the output string in pixels. + + +
See also: +gui_strlen.
+
int gui_strlen(const char *s);

+ Helper function for use by the GUI routines. Returns the length of a + string in pixels, ignoring '&' characters. + + +
See also: +gui_textout_ex.
+
void gui_set_screen(BITMAP *bmp);

+ This function can be used to change the bitmap surface the GUI routines + draw to. This can be useful if you are using a double buffering or page + flipping system. Passing NULL will cause the default surface (screen) to + be used again. Example: +
+      BITMAP *page[2];
+      
+      /* Allocate two pages of video memory */
+      page[0] = create_video_bitmap(SCREEN_W, SCREEN_H);
+      page[1] = create_video_bitmap(SCREEN_W, SCREEN_H);
+      
+      /* Page flip */
+      show_video_bitmap(page[0]);
+      gui_set_screen(page[0]);
+
+ + +
See also: +gui_get_screen.
+
BITMAP *gui_get_screen(void);

+ This function returns the current bitmap surface the GUI routines will + use for drawing. Note that this function will return screen if you have + called gui_set_screen(NULL) previously, and will never return NULL. + + +
See also: +gui_set_screen.
+
void position_dialog(DIALOG *dialog, int x, int y);

+ Moves an array of dialog objects to the specified screen position + (specified as the top left corner of the dialog). + + +
See also: +centre_dialog.
+ +
Examples using this: +exgui.
+
void centre_dialog(DIALOG *dialog);

+ Moves an array of dialog objects so that it is centered in the screen. + + +
See also: +position_dialog, +set_dialog_color.
+
void set_dialog_color(DIALOG *dialog, int fg, int bg);

+ Sets the foreground and background colors of an array of dialog objects. + + +
See also: +gui_fg_color, +gui_mg_color, +centre_dialog.
+ +
Examples using this: +exgui.
+
int find_dialog_focus(DIALOG *dialog);

+ Searches the dialog for the object which has the input focus, returning + an index or -1 if the focus is not set. This is useful if you are calling + do_dialog() several times in a row and want to leave the focus in the + same place it was when the dialog was last displayed, as you can call + do_dialog(dlg, find_dialog_focus(dlg)); + + +
See also: +do_dialog, +init_dialog, +offer_focus.
+
int offer_focus(DIALOG *dialog, int obj, int *focus_obj, int force);

+ Offers the input focus to a particular object. Normally the function sends + the MSG_WANTFOCUS message to query whether the object is willing to accept + the focus. However, passing any non-zero value as force argument instructs + the function to authoritatively set the focus to the object. + + +
See also: +find_dialog_focus.
+
int object_message(DIALOG *dialog, int msg, int c);

+ Sends a message to an object and returns the answer it has generated. + Remember that the first parameter is the dialog object (not a whole + array) that you wish to send the message to. For example, to make the + second object in a dialog draw itself, you might write: +
+      object_message(&dialog[1], MSG_DRAW, 0);
+
+ The function will take care of scaring and unscaring the mouse if the + message is MSG_DRAW. + + +
See also: +dialog_message, +scare_mouse, +scare_mouse_area, +unscare_mouse.
+ +
Examples using this: +excustom, +exrgbhsv.
+
int dialog_message(DIALOG *dialog, int msg, int c, int *obj);

+ Sends a message to all the objects in an array. If any of the dialog + procedures return values other than D_O_K, it returns the value and sets + obj to the index of the object which produced it. + + +
See also: +object_message, +broadcast_dialog_message.
+
int broadcast_dialog_message(int msg, int c);

+ Broadcasts a message to all the objects in the active dialog. If any of + the dialog procedures return values other than D_O_K, it returns that + value. + + +
See also: +dialog_message, +active_dialog.
+
int do_dialog(DIALOG *dialog, int focus_obj);

+ The basic dialog manager function. This displays a dialog (an array of + dialog objects, terminated by one with a NULL dialog procedure), and sets + the input focus to the focus_obj (-1 if you don't want anything to have + the focus). It interprets user input and dispatches messages as they are + required, until one of the dialog procedures tells it to close the + dialog, at which point it returns the index of the object that caused it + to exit, or until ESC is pressed, at which point it returns -1. + + +
See also: +popup_dialog, +init_dialog, +centre_dialog, +set_dialog_color, +find_dialog_focus.
+ +
Examples using this: +excustom, +exgui, +exrgbhsv.
+
int popup_dialog(DIALOG *dialog, int focus_obj);

+ Like do_dialog(), but it stores the data on the screen before drawing the + dialog and restores it when the dialog is closed. The screen area to be + stored is calculated from the dimensions of the first object in the + dialog, so all the other objects should lie within this one. + + +
See also: +do_dialog.
+
DIALOG_PLAYER *init_dialog(DIALOG *dialog, int focus_obj);

+ This function provides lower level access to the same functionality as + do_dialog(), but allows you to combine a dialog box with your own program + control structures. It initialises a dialog, returning a pointer to a + player object that can be used with update_dialog() and + shutdown_dialog(). With these functions, you could implement your own + version of do_dialog() with the lines: +
+      DIALOG_PLAYER *player = init_dialog(dialog, focus_obj);
+
+      while (update_dialog(player))
+         ;
+
+      return shutdown_dialog(player);
+ +

+ Note that you are responsible for showing and hiding the mouse cursor, which + do_dialog would otherwise do for you, or saving and restoring the screen + contents, as popup_dialog would do for you. + + +

See also: +update_dialog, +shutdown_dialog, +do_dialog.
+
int update_dialog(DIALOG_PLAYER *player);

+ Updates the status of a dialog object returned by init_dialog(). Returns + TRUE if the dialog is still active, or FALSE if it has terminated. Upon a + return value of FALSE, it is up to you whether to call shutdown_dialog() + or to continue execution. The object that requested the exit can be + determined from the player->obj field. + + +
See also: +init_dialog.
+
int shutdown_dialog(DIALOG_PLAYER *player);

+ Destroys a dialog player object returned by init_dialog(), returning the + object that caused it to exit (this is the same as the return value from + do_dialog()). + + +
See also: +init_dialog.
+
extern DIALOG *active_dialog;

+ Global pointer to the most recent activated dialog. This may be useful if + an object needs to iterate through a list of all its siblings. + + +
See also: +do_dialog, +init_dialog, +broadcast_dialog_message.
+

GUI menus

+Popup or pulldown menus are created as an array of MENU structures. Read +chapter "Structures and types defined by Allegro" for an internal description +of the MENU structure. + +

+Each menu item contains a text string. This can use the '&' character to +indicate keyboard shortcuts, or can be an zero-length string to display the +item as a non-selectable splitter bar. If the string contains a "\t" tab +character, any text after this will be right-justified, eg. for displaying +keyboard shortcut information. The proc pointer is a function which will be +called when the menu item is selected, and child points to another menu, +allowing you to create nested menus. Both proc and child may be NULL. The +proc function returns an integer which is ignored if the menu was brought up +by calling do_menu(), but which is passed back to the dialog manager if it +was created by a d_menu_proc() object. The array of menu items is terminated +by an entry with a NULL text pointer. + +

+Menu items can be disabled (greyed-out) by setting the D_DISABLED bit in the +flags field, and a check mark can be displayed next to them by setting the +D_SELECTED bit. With the default alignment and font this will usually +overlap the menu text, so if you are going to use checked menu items it +would be a good idea to prefix all your options with a space or two, to +ensure there is room for the check. + + +

See also: +do_menu, +d_menu_proc, +gui_menu_draw_menu.
+
int do_menu(MENU *menu, int x, int y);

+ Displays and animates a popup menu at the specified screen coordinates + (these will be adjusted if the menu does not entirely fit on the screen). + Returns the index of the menu item that was selected, or -1 if the menu + was cancelled. Note that the return value cannot indicate selection from + child menus, so you will have to use the callback functions if you want + multi-level menus. + + +
See also: +GUI menus, +d_menu_proc, +active_menu, +gui_menu_draw_menu, +update_menu.
+
MENU_PLAYER *init_menu(MENU *menu, int x, int y);

+ This function provides lower level access to the same functionality as + do_menu(), but allows you to combine a popup menu with your own program + control structures. It initialises a menu, returning a pointer to a menu + player object that can be used with update_menu() and shutdown_menu(). + With these functions, you could implement your own version of do_menu() + with the lines: +
+      MENU_PLAYER *player = init_menu(menu, x, y);
+
+      while (update_menu(player))
+         ;
+
+      return shutdown_menu(player);
+ + +
See also: +update_menu, +shutdown_menu, +do_menu.
+
int update_menu(MENU_PLAYER *player);

+ Updates the status of a menu object returned by init_menu(). Returns TRUE + if the menu is still active, or FALSE if it has terminated. Upon a return + value of FALSE, it is up to you to call shutdown_menu() or to continue + execution. + + +
See also: +init_menu, +shutdown_menu, +do_menu.
+
int shutdown_menu(MENU_PLAYER *player);

+ Destroys a menu player object returned by init_menu(), returning the index + of the menu item that was selected, or -1 if the menu was cancelled (this + is the same as the return value from do_menu()). + + +
See also: +init_menu, +update_menu.
+
extern MENU *active_menu;

+ When a menu callback procedure is triggered, this will be set to the menu + item that was selected, so your routine can determine where it was called + from. + + +
See also: +GUI menus.
+ +
Examples using this: +exgui.
+
extern void (*gui_menu_draw_menu)(int x, int y, int w, int h);

+
extern void (*gui_menu_draw_menu_item)(MENU *m, int x, int y, int w, + int h, int bar, int sel);

+ If set, these functions will be called whenever a menu needs to be + drawn, so you can change how menus look. + +

+ gui_menu_draw_menu() is passed the position and size of the + menu. It should draw the background of the menu onto screen. + +

+ gui_menu_draw_menu_item() is called once for each menu item that is + to be drawn. bar will be set if the item is part of a top-level + horizontal menu bar, and sel will be set if the menu item is + selected. It should also draw onto screen. + + +

See also: +GUI menus.
+
int alert(const char *s1, *s2, *s3, const char *b1, *b2, int c1, c2);

+ Displays a popup alert box, containing three lines of text (s1-s3), and + with either one or two buttons. The text for these buttons is passed in + `b1' and `b2' (`b2' may be NULL), and the keyboard shortcuts in `c1' and + `c2' as ASCII value. Example: +
+      if (!exists(CONFIG_FILE))
+         alert(CONFIG_FILE, "not found.", "Using defaults.",
+               "&Continue", NULL, 'c', 0);
+

Return value: + Returns 1 or 2 depending on which button was clicked. If the alert is + dismissed by pressing ESC when ESC is not one of the keyboard shortcuts, + it treats it as a click on the second button (this is consistent with the + common "Ok", "Cancel" alert). + + +

See also: +alert3, +gui_fg_color.
+ +
Examples using this: +exgui, +expackf, +exspline.
+
int alert3(const char *s1, *s2, *s3, const char *b1, *b2, *b3, int c1, c2, c3);

+ Like alert(), but with three buttons. Returns 1, 2, or 3. + + +
See also: +alert, +gui_fg_color.
+
int file_select_ex(const char *message, char *path, const char *ext, + int size, int w, int h);

+ Displays the Allegro file selector, with the message as caption. The path + parameter contains the initial filename to display (this can be used to + set the starting directory, or to provide a default filename for a + save-as operation). The user selection is returned by altering the path + buffer, whose maximum capacity in bytes is specified by the size parameter. + Note that it should have room for at least 80 characters (not bytes), + so you should reserve 6x that amount, just to be sure. The list of files + is filtered according to the file extensions in the ext parameter. + Passing NULL includes all files; "PCX;BMP" includes only files with + .PCX or .BMP extensions. If you wish to control files by their attributes, + one of the fields in the extension list can begin with a slash, followed + by a set of attribute characters. Any attribute written on its own, or + with a '+' before it, indicates to include only files which have that + attribute set. Any attribute with a '-' before it indicates to leave out + any files with that attribute. The flag characters are 'r' (read-only), + 'h' (hidden), 's' (system), 'd' (directory) and 'a' (archive). For + example, an extension string of "PCX;BMP;/+r-h" will display only PCX or + BMP files that are read-only and not hidden. The directories are not + affected in the same way as the other files by the extension string: the + extensions are never taken into account for them and the other attributes + are taken into account only when 'd' is mentioned in the string; in other + words, all directories are included when 'd' is not mentioned in the + string. The file selector is stretched to the width and height specified + in the w and h parameters, and to the size of the standard Allegro font. + If either the width or height argument is set to zero, it is stretched + to the corresponding screen dimension. This function returns zero if it + was closed with the Cancel button or non-zero if it was OK'd. + + +
See also: +gui_fg_color.
+
int gfx_mode_select(int *card, int *w, int *h);

+ Displays the Allegro graphics mode selection dialog, which allows the + user to select a screen mode and graphics card. Stores the selection in + the three variables, and returns zero if it was closed with the Cancel + button or non-zero if it was OK'd. + +

+ The initial values of card, w, h are not used. + + +

See also: +gfx_mode_select_ex, +gfx_mode_select_filter, +set_gfx_mode, +gui_fg_color.
+
int gfx_mode_select_ex(int *card, int *w, int *h, int *color_depth);

+ Extended version of the graphics mode selection dialog, which allows the + user to select the color depth as well as the resolution and hardware + driver. + +

+ This version of the function reads the initial values from the + parameters when it activates so you can specify the default values. + In fact, you should be sure not to pass in uninitialised values. + + +

See also: +gfx_mode_select, +gfx_mode_select_filter, +set_color_depth, +set_gfx_mode, +gui_fg_color.
+ +
Examples using this: +ex3d, +exscn3d, +exswitch, +exupdate, +exzbuf.
+
int gfx_mode_select_filter(int *card, int *w, int *h, int *color_depth, + int (*filter)(int, int, int, int));

+ Even more extended version of the graphics mode selection dialog, which + allows the programmer to customize the contents of the dialog and the user + to select the color depth as well as the resolution and hardware driver. + `filter' will be passed (card, w, h, color_depth) quadruplets and must + return 0 to let the specified quadruplet be added to the list of displayed + modes. + +

+ This version of the function reads the initial values from the + parameters when it activates so you can specify the default values. + In fact, you should be sure not to pass in uninitialised values. + + +

See also: +gfx_mode_select, +gfx_mode_select_ex, +set_color_depth, +set_gfx_mode, +gui_fg_color.
+
extern int (*gui_shadow_box_proc)(int msg, struct DIALOG *d, int c);

+
extern int (*gui_ctext_proc)(int msg, struct DIALOG *d, int c);

+
extern int (*gui_button_proc)(int msg, struct DIALOG *d, int c);

+
extern int (*gui_edit_proc)(int msg, struct DIALOG *d, int c);

+
extern int (*gui_list_proc)(int msg, struct DIALOG *d, int c);

+
extern int (*gui_text_list_proc)(int msg, struct DIALOG *d, int c);

+ If set, these functions will be used by the standard Allegro dialogs. + This allows you to customise the look and feel, much like gui_fg_color + and gui_bg_color, but much more flexibly. + + + + +
See also: +alert, +alert3, +file_select_ex, +gfx_mode_select, +gui_fg_color.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg036.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg036.html new file mode 100644 index 0000000..2bb0843 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg036.html @@ -0,0 +1,416 @@ + + +Allegro Manual: DOS specifics + + + + +

DOS specifics

+ + + +

+There are four Allegro files which you should redistribute along your program. +These are the files `keyboard.dat', `language.dat', `allegro.cfg' and +`setup.exe'. + +

+The first two contain internationalisation information for keyboard mappings +and system messages to show up localised on the user's computer. The +`setup.exe' program, which comes in Allegro's `setup' directory, is a +standalone tool which you can graphically customise and even embed into your +main binary. The user can generate a configuration file with this tool, to +store special settings or avoid Allegro's autodetection failing on specific +hardware. Even if you distribute `setup.exe', you are recommended to copy too +the empty `allegro.cfg' file, in case the setup program itself is unable to +run and the user has to edit manually the configuration with a text editor. + +

+If you are using get_config_text() in your program to localise text strings, +merge your xxtext.cfg files with the ones provided by Allegro in the +`resource' directory before creating `language.dat', and redistribute this +with your program. This file will contain then both Allegro's system +messages and the strings of your program. + +


+

Drivers JOY_TYPE_*/DOS

+ The DOS library supports the following type parameters for the + install_joystick() function: + + +
See also: +install_joystick.
+
Drivers GFX_*/DOS

+ The DOS library supports the following card parameters for the + set_gfx_mode() function: + + There are a few things you need to be aware of for scrolling: + most VESA implementations can only handle horizontal scrolling in four + pixel increments, so smooth horizontal panning is impossible in SVGA modes. + A significant number of VESA implementations seem to be very buggy when it + comes to scrolling in truecolor video modes, so you shouldn't depend on + this routine working correctly in the truecolor resolutions unless you can + be sure that SciTech Display Doctor is installed. Hardware scrolling may + also not work at all under Windows. + +

+ Triple buffering is only possible with certain drivers: it will work in any + DOS mode-X resolution if the timer retrace simulator is active (but this + doesn't work correctly under Windows 95), plus it is supported by the + VBE 3.0 and VBE/AF drivers for a limited number graphics cards. + +

See also: +set_gfx_mode.
+
Drivers DIGI_*/DOS

+ The DOS sound functions support the following digital soundcards: +
+      DIGI_AUTODETECT      - let Allegro pick a digital sound driver
+      DIGI_NONE            - no digital sound
+      DIGI_SB              - Sound Blaster (autodetect type)
+      DIGI_SB10            - SB 1.0 (8-bit mono single shot dma)
+      DIGI_SB15            - SB 1.5 (8-bit mono single shot dma)
+      DIGI_SB20            - SB 2.0 (8-bit mono auto-initialised
+                             dma)
+      DIGI_SBPRO           - SB Pro (8-bit stereo)
+      DIGI_SB16            - SB16 (16-bit stereo)
+      DIGI_AUDIODRIVE      - ESS AudioDrive
+      DIGI_SOUNDSCAPE      - Ensoniq Soundscape
+      DIGI_WINSOUNDSYS     - Windows Sound System
+ + +
See also: +detect_digi_driver, +install_sound, +install_sound_input.
+
Drivers MIDI_*/DOS

+ The DOS sound functions support the following MIDI soundcards: +
+      MIDI_AUTODETECT      - let Allegro pick a MIDI sound driver
+      MIDI_NONE            - no MIDI sound
+      MIDI_ADLIB           - Adlib or SB FM synth (autodetect type)
+      MIDI_OPL2            - OPL2 synth (mono, used in Adlib and SB)
+      MIDI_2XOPL2          - dual OPL2 synths (stereo, used in
+                             SB Pro-I)
+      MIDI_OPL3            - OPL3 synth (stereo, SB Pro-II
+                             and above)
+      MIDI_SB_OUT          - SB MIDI interface
+      MIDI_MPU             - MPU-401 MIDI interface
+      MIDI_DIGMID          - sample-based software wavetable player
+      MIDI_AWE32           - AWE32 (EMU8000 chip)
+ + +
See also: +detect_midi_driver, +install_sound, +install_sound_input.
+

DOS integration routines

+ +


+

extern int i_love_bill;

+ When running in clean DOS mode, the timer handler dynamically reprograms + the clock chip to generate interrupts at exactly the right times, which + gives an extremely high accuracy. Unfortunately, this constant speed + adjustment doesn't work under most multitasking systems (notably + Windows), so there is an alternative mode that just locks the hardware + timer interrupt to a speed of 200 ticks per second. This reduces the + accuracy of the timer (for instance, rest() will round the delay time to + the nearest 5 milliseconds), and prevents the vertical retrace simulator + from working, but on the plus side, it makes Allegro programs work under + Windows. This flag is set by allegro_init() if it detects the presence of + a multitasking OS, and enables the fixed rate timer mode. + + + + +
See also: +install_timer, +allegro_init, +os_type.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg037.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg037.html new file mode 100644 index 0000000..cfa6701 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg037.html @@ -0,0 +1,443 @@ + + +Allegro Manual: Windows specifics + + + + +

Windows specifics

+ + + +

+In terms of file redistribution, the Windows platform behaves practically the +same as the DOS platform. Read section chapter "Dos specifics" in the manual +to learn more about this. + +

+A Windows program that uses the Allegro library is only required to include +one or more header files from the include/allegro tree, or allegro.h; however, +if it also needs to directly call non portable Win32 API functions, it must +include the Windows-specific header file winalleg.h after the Allegro headers, +and before any Win32 API header file. By default winalleg.h includes the main +Win32 C API header file windows.h. If instead you want to use the C++ +interface to the Win32 API (a.k.a. the Microsoft Foundation Classes), define +the preprocessor symbol ALLEGRO_AND_MFC before including any Allegro header +so that afxwin.h will be included. Note that, in this latter case, the Allegro +debugging macros ASSERT() and TRACE() are renamed AL_ASSERT() and AL_TRACE() +respectively. + +

+Windows GUI applications start with a WinMain() entry point, rather than the +standard main() entry point. Allegro is configured to build GUI applications +by default and to do some magic in order to make a regular main() work with +them, but you have to help it out a bit by writing END_OF_MAIN() right after +your main() function. If you don't want to do that, you can just include +winalleg.h and write a WinMain() function. Note that this magic may bring +about conflicts with a few programs using direct calls to Win32 API +functions; for these programs, the regular WinMain() is required and the +magic must be disabled by defining the preprocessor symbol +ALLEGRO_NO_MAGIC_MAIN before including Allegro headers. + +

+If you want to build a console application using Allegro, you have to define +the preprocessor symbol ALLEGRO_USE_CONSOLE before including Allegro headers; +it will instruct the library to use console features and also to disable the +special processing of the main() function described above. + +

+When creating the main window, Allegro searches the executable for an ICON +resource named "allegro_icon". If it is present, Allegro automatically +loads it and uses it as its application icon; otherwise, Allegro uses the +default IDI_APPLICATION icon. See the manual of your compiler for a method +to create an ICON resource, or use the wfixicon utility from the tools/win +directory. + +

+DirectX requires that system and video bitmaps (including the screen) be +locked before you can draw onto them. This will be done automatically, but +you can usually get much better performance by doing it yourself: see the +acquire_bitmap() function for details. + +

+Due to a major oversight in the design of DirectX, there is no way to +preserve the contents of video memory when the user switches away from your +program. You need to be prepared for the fact that your screen contents, and +the contents of any video memory bitmaps, may be destroyed at any point. You +can use the set_display_switch_callback() function to find out when this +happens. + +

+On the Windows platform, the only return values for the desktop_color_depth() +function are 8, 16, 24 and 32. This means that 15-bit and 16-bit desktops +cannot be differentiated and are both reported as 16-bit desktops. See +below for the consequences for windowed and overlay DirectX drivers. + +


+

Drivers JOY_TYPE_*/Windows

+ The Windows library supports the following type parameters for the + install_joystick() function: + + + +
See also: +install_joystick.
+
Drivers GFX_*/Windows

+ The Windows library supports the following card parameters for the + set_gfx_mode() function: + + +
See also: +set_gfx_mode.
+
Drivers DIGI_*/Windows

+ The Windows sound functions support the following digital soundcards: +
+      DIGI_AUTODETECT      - let Allegro pick a digital sound driver
+      DIGI_NONE            - no digital sound
+      DIGI_DIRECTX(n)      - use DirectSound device #n (zero-based)
+                             with direct mixing
+      DIGI_DIRECTAMX(n)    - use DirectSound device #n (zero-based)
+                             with Allegro mixing
+      DIGI_WAVOUTID(n)     - high (n=0) or low (n=1) quality WaveOut
+                             device
+ + +
See also: +detect_digi_driver, +install_sound, +install_sound_input.
+
Drivers MIDI_*/Windows

+ The Windows sound functions support the following MIDI soundcards: +
+      MIDI_AUTODETECT      - let Allegro pick a MIDI sound driver
+      MIDI_NONE            - no MIDI sound
+      MIDI_WIN32MAPPER     - use win32 MIDI mapper
+      MIDI_WIN32(n)        - use win32 device #n (zero-based)
+      MIDI_DIGMID          - sample-based software wavetable player
+ + +
See also: +detect_midi_driver, +install_sound, +install_sound_input.
+

Windows integration routines

+ +

+The following functions provide a platform specific interface to seamlessly +integrate Allegro into general purpose Win32 programs. To use these routines, +you must include winalleg.h after other Allegro headers. + +


+

HWND win_get_window(void);

+ Retrieves a handle to the window used by Allegro. Note that Allegro + uses an underlying window even though you don't set any graphics mode, + unless you have installed the neutral system driver (SYSTEM_NONE). + +


+

void win_set_window(HWND wnd);

+ Registers an user-created window to be used by Allegro. This function is + meant to be called before initialising the library with allegro_init() + or installing the autodetected system driver (SYSTEM_AUTODETECT). It + lets you attach Allegro to any already existing window and prevents the + library from creating its own, thus leaving you total control over the + window; in particular, you are responsible for processing the events as + usual (Allegro will automatically monitor a few of them, but will not + filter out any of them). You can then use every component of the library + (graphics, mouse, keyboard, sound, timers and so on), bearing in mind + that some Allegro functions are blocking (e.g. readkey() if the key buffer + is empty) and thus must be carefully manipulated by the window thread. + +

+ However you can also call it after the library has been initialised, + provided that no graphics mode is set. In this case the keyboard, mouse, + joystick, sound and sound recording modules will be restarted. + +

+ Passing NULL instructs Allegro to switch back to its built-in window if + an user-created window was registered, or to request a new handle from + Windows for its built-in window if this was already in use. + +


+

void win_set_wnd_create_proc(HWND (*proc)(WNDPROC));

+ Registers an user-defined procedure to be used by Allegro for creating + its window. This function must be called *before* initializing the + library with allegro_init() or installing the autodetected system + driver (SYSTEM_AUTODETECT). It lets you customize Allegro's window but + only by its creation: unlike with win_set_window(), you have no control + over the window once it has been created (in particular, you are not + responsible for processing the events). The registered function will be + passed a window procedure (WNDPROC object) that it must make the + procedure of the new window of and it must return a handle to the new + window. You can then use the full-featured library in the regular way. + +


+

HDC win_get_dc(BITMAP *bmp);

+ Retrieves a handle to the device context of a DirectX video or system + bitmap. + +


+

void win_release_dc(BITMAP *bmp, HDC dc);

+ Releases a handle to the device context of the bitmap that was + previously retrieved with win_get_dc(). + +

+

GDI routines

+ +

+The following GDI routines are a very platform specific thing, to allow +drawing Allegro memory bitmaps onto a Windows device context. When you want +to use this, you'll have to install the neutral system driver (SYSTEM_NONE) +or attach Allegro to an external window with win_set_window(). + +

+There are two ways to draw your Allegro bitmaps to the Windows GDI. When you +are using static bitmaps (for example just some pictures loaded from a +datafile), you can convert them to DDB (device-dependent bitmaps) with +convert_bitmap_to_hbitmap() and then just use Win32's BitBlt() to draw it. + +

+When you are using dynamic bitmaps (for example some things which react to +user input), it's better to use set_palette_to_hdc() and blit_to_hdc() +functions, which work with DIB (device-independent bitmaps). + +

+There are also functions to blit from a device context into an Allegro +BITMAP, so you can do things like screen capture. + +

+All the drawing and conversion functions use the current palette as a color +conversion table. You can alter the current palette with the +set_palette_to_hdc() or select_palette() functions. Warning: when the GDI +system color palette is explicitly changed, (by another application, for +example) the current Allegro palette is not updated along with it! + +

+To use these routines, you must include winalleg.h after Allegro headers. + +


+

void set_gdi_color_format(void);

+ Tells Allegro to use the GDI color layout for truecolor images. This is + optional, but it will make the conversions work faster. If you are going + to call this, you should do it right after initialising Allegro and + before creating any graphics. + +


+

void set_palette_to_hdc(HDC dc, PALETTE pal);

+ Selects and realizes an Allegro palette on the specified device context. + +


+

HPALETTE convert_palette_to_hpalette(PALETTE pal);

+ Converts an Allegro palette to a Windows palette and returns a handle to + it. You should call DeleteObject() when you no longer need it. + + +
See also: +convert_hpalette_to_palette.
+
void convert_hpalette_to_palette(HPALETTE hpal, PALETTE pal);

+ Converts a Windows palette to an Allegro palette. + + +
See also: +convert_palette_to_hpalette.
+
HBITMAP convert_bitmap_to_hbitmap(BITMAP *bitmap);

+ Converts an Allegro memory bitmap to a Windows DDB and returns a handle + to it. This bitmap uses its own memory, so you can destroy the original + bitmap without affecting the converted one. You should call + DeleteObject() when you no longer need this bitmap. + + +
See also: +convert_hbitmap_to_bitmap.
+
BITMAP *convert_hbitmap_to_bitmap(HBITMAP bitmap);

+ Creates an Allegro memory bitmap from a Windows DDB. + + +
See also: +convert_bitmap_to_hbitmap.
+
void draw_to_hdc(HDC dc, BITMAP *bitmap, int x, int y);

+ Draws an entire Allegro bitmap to a Windows device context, using the + same parameters as the draw_sprite() function. + + +
See also: +blit_to_hdc, +stretch_blit_to_hdc, +draw_sprite.
+
void blit_to_hdc(BITMAP *bitmap, HDC dc, int sx, sy, dx, dy, w, h);

+ Blits an Allegro memory bitmap to a Windows device context, using the + same parameters as the blit() function. + + +
See also: +draw_to_hdc, +stretch_blit_to_hdc, +blit_from_hdc, +blit.
+
void stretch_blit_to_hdc(BITMAP *bitmap, HDC dc, int sx, sy, sw, sh, + int dx, dy, dw, dh);

+ Blits an Allegro memory bitmap to a Windows device context, using the + same parameters as the stretch_blit() function. + + +
See also: +draw_to_hdc, +blit_to_hdc, +stretch_blit_from_hdc, +stretch_blit.
+
void blit_from_hdc(HDC hdc, BITMAP *bitmap, int sx, sy, dx, dy, w, h);

+ Blits from a Windows device context to an Allegro memory bitmap, using + the same parameters as the blit() function. See stretch_blit_from_hdc() + for details. + + +
See also: +stretch_blit_from_hdc, +blit_to_hdc, +blit.
+
void stretch_blit_from_hdc(HDC hcd, BITMAP *bitmap, int sx, sy, sw, sh, + int dx, dy, dw, dh);

+ Blits from a Windows device context to an Allegro memory bitmap, using + the same parameters as the stretch_blit() function. It uses the current + Allegro palette and does conversion to this palette, regardless of the + current DC palette. So if you are blitting from 8-bit mode, you should + first set the DC palette with the set_palette_to_hdc() function. + + + +
See also: +blit_from_hdc, +stretch_blit_to_hdc, +stretch_blit.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg038.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg038.html new file mode 100644 index 0000000..93f168c --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg038.html @@ -0,0 +1,291 @@ + + +Allegro Manual: Unix specifics + + + + +

Unix specifics

+ + + +

+Under Unix you usually have two ways of redistributing your binaries. You +either pack everything in a single directory, even providing Allegro in +binary or source form for the user to compile. Or your program is being +packaged separately from Allegro and stored in different paths. For the +first case of redistribution, read section "Files shared by Allegro" from +the "Dos specifics" chapter to learn more about this. + +

+For the second type, you can ignore redistributing the setup, keyboard +mappings and language datafiles, because they will be already installed in +the system. This, however, is problematic if you are using get_config_text() +to localise your program's text strings. + +

+The problem is that on other platforms you usually mix your program's text +strings with those of Allegro (found in the `resources' directory) to create +a special language.dat. And it is likely that the Allegro library installed +on the user's system already contains a datafile.dat. You can go ahead and +still provide your own language.dat file, but this will mean that if Allegro +is updated, your language.dat file may not contain all the text strings used +by the new version. + +

+Given the slow paced release cycle of Allegro, this might not be a concern. +However, if you want to make it easy on system administrators, instead of +providing your own `language.dat', you should provide the separate +`xxtext.cfg' files it in a separate directory. Then, before showing the +strings to the user you can detect the language setting and use +override_config_file() with the appropriate localisation file and call +reload_config_texts(). + +

+In order to locate things like the config and translation files, Allegro +needs to know the path to your executable. Since there is no standard way to +find that, it needs to capture a copy of your argv[] parameter, and it does +this with some preprocessor macro trickery. Unfortunately it can't quite +pull this off without a little bit of your help, so you will have to write +END_OF_MAIN() right after your main() function. Pretty easy, really, and if +you forget, you'll get a nice linker error about a missing _mangled_main +function to remind you :-) + +

+Under Unix resources are searched for in many different paths (see above). +When a configuration resource is looked for, it is usually tried with the +variations `name.cfg' or `.namerc' in multiple paths: the current directory, +the directory pointed to by the ALLEGRO environment variable, the user's home +directory, one or more global system directories which usually only the +root user has access to and any custom paths set up with +set_allegro_resource_path(). Text files, like the main allegro config file or +a language text translation files are looked for in the following places: +

+   ./allegro.cfg
+   $ALLEGRO/allegro.cfg
+   ~/allegro.cfg
+   ~/.allegrorc
+   /etc/allegro.cfg
+   /etc/allegrorc
+
+Binary resources like the language translation files packfile (language.dat) +are looked for in: +
+   ./language.dat
+   $ALLEGRO/language.dat
+   ~/language.dat
+   /etc/language.dat
+   /usr/share/allegro/language.dat
+   /usr/local/share/allegro/language.dat
+
+Note that if you have installed Allegro from the source distribution with +the typical `make install', global files like `language.dat' and +`allegro.cfg' will not have been installed. As a system administrator you are +required to install them manually wherever you prefer to have them. If you +suspect that an Allegro program is somehow not finding the correct +configuration file, you could try using the following command: +
+   strace program 2>&1|egrep "(open|stat)"
+
+The strace program traces system calls and signals. By default it outputs +the information to stderr, so that's why we redirect it to stdin with `2>&1'. +Since we are interested only in files being (un)successfully opened, we +restrict the output of the log to stat or open calls with the extended grep +command. You could add another grep to filter only lines with text like +`language' or `allegro'. + +


+

Drivers JOY_TYPE_*/Linux

+ The Linux library supports the following type parameters for the + install_joystick() function: + + + +
See also: +install_joystick.
+
Drivers GFX_*/Linux

+ When running in Linux console mode, Allegro supports the following card + parameters for the set_gfx_mode() function: + + +
See also: +set_gfx_mode, +GFX_*/X.
+
Drivers GFX_*/X

+ When running in X mode, Allegro supports the following card parameters + for the set_gfx_mode() function: + + +
See also: +set_gfx_mode, +GFX_*/Linux.
+
Drivers DIGI_*/Unix

+ The Unix sound functions support the following digital soundcards: +
+      DIGI_AUTODETECT      - let Allegro pick a digital sound driver
+      DIGI_NONE            - no digital sound
+      DIGI_OSS             - Open Sound System
+      DIGI_ESD             - Enlightened Sound Daemon
+      DIGI_ARTS            - aRts (Analog Real-Time Synthesizer)
+      DIGI_ALSA            - ALSA sound driver
+      DIGI_JACK            - JACK sound driver
+ + +
See also: +detect_digi_driver, +install_sound, +install_sound_input.
+
Drivers MIDI_*/Unix

+ The Unix sound functions support the following MIDI soundcards: +
+      MIDI_AUTODETECT      - let Allegro pick a MIDI sound driver
+      MIDI_NONE            - no MIDI sound
+      MIDI_OSS             - Open Sound System
+      MIDI_DIGMID          - sample-based software wavetable player
+      MIDI_ALSA            - ALSA RawMIDI driver
+ + +
See also: +detect_midi_driver, +install_sound, +install_sound_input.
+

Unix integration routines

+ +


+

void xwin_set_window_name(const char *name, const char *group);

+ This function is only available under X. It lets you to specify the + window name and group (or class). They are important because they allow + the window manager to remember the window attributes (position, layer, + etc). Note that the name and the title of the window are two different + things: the title is what appears in the title bar of the window, but + usually has no other effects on the behaviour of the application. + + +
See also: +set_window_title.
+
extern void *allegro_icon;

+ This is a pointer to the Allegro X11 icon, which is in the format of + standard .xpm bitmap data. + You do not normally have to bother with this at all: you can use the + xfixicon.sh utility from the tools/x11 directory to convert a true + colour bitmap to a C file that you only need to link with your own code + to set the icon. + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg039.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg039.html new file mode 100644 index 0000000..4467a7f --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg039.html @@ -0,0 +1,97 @@ + + +Allegro Manual: BeOS specifics + + + + +

BeOS specifics

+ + + +

+In terms of file redistribution, the BeOS platform behaves practically the +same as the DOS platform. Read section chapter "Dos specifics" in the manual +to learn more about this. + +


+

Drivers GFX_*/BeOS

+ BeOS Allegro supports the following card parameters for the + set_gfx_mode() function: + + +
See also: +set_gfx_mode.
+
Drivers DIGI_*/BeOS

+ The BeOS sound functions support the following digital soundcards: +
+      DIGI_AUTODETECT      - let Allegro pick a digital sound driver
+      DIGI_NONE            - no digital sound
+      DIGI_BEOS            - BeOS digital output
+ + +
See also: +detect_digi_driver, +install_sound, +install_sound_input.
+
Drivers MIDI_*/BeOS

+ The BeOS sound functions support the following MIDI soundcards: +
+      MIDI_AUTODETECT      - let Allegro pick a MIDI sound driver
+      MIDI_NONE            - no MIDI sound
+      MIDI_BEOS            - BeOS MIDI output
+      MIDI_DIGMID          - sample-based software wavetable player
+
+ + + +
See also: +detect_midi_driver, +install_sound, +install_sound_input.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg040.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg040.html new file mode 100644 index 0000000..372a550 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg040.html @@ -0,0 +1,115 @@ + + +Allegro Manual: QNX specifics + + + + +

QNX specifics

+ + + +

+In terms of file redistribution, the QNX platform behaves practically the +same as the DOS platform. Read section chapter "Dos specifics" in the manual +to learn more about this. + +


+

Drivers GFX_*/QNX

+ QNX Allegro supports the following card parameters for the + set_gfx_mode() function: + + +
See also: +set_gfx_mode.
+
Drivers DIGI_*/QNX

+ The QNX sound functions support the following digital soundcards: +
+      DIGI_AUTODETECT      - let Allegro pick a digital sound driver
+      DIGI_NONE            - no digital sound
+      DIGI_ALSA            - ALSA sound driver
+ + +
See also: +detect_digi_driver, +install_sound, +install_sound_input.
+
Drivers MIDI_*/QNX

+ The QNX sound functions support the following MIDI soundcards: +
+      MIDI_AUTODETECT      - let Allegro pick a MIDI sound driver
+      MIDI_NONE            - no MIDI sound
+      MIDI_ALSA            - ALSA RawMIDI driver
+      MIDI_DIGMID          - sample-based software wavetable player
+
+ + +
See also: +detect_midi_driver, +install_sound, +install_sound_input.
+

QNX integration routines

+ +

+The following functions provide a platform specific interface to seamlessly +integrate Allegro into general purpose QNX programs. To use these routines, +you must include qnxalleg.h after other Allegro headers. + +


+

PtWidget_t qnx_get_window(void);

+ Retrieves a handle to the window used by Allegro. Note that Allegro + uses an underlying window even though you don't set any graphics mode, + unless you have installed the neutral system driver (SYSTEM_NONE). + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg041.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg041.html new file mode 100644 index 0000000..b3161a9 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg041.html @@ -0,0 +1,125 @@ + + +Allegro Manual: MacOS X specifics + + + + +

MacOS X specifics

+ + + +

+In terms of file redistribution, the MacOS X platform behaves practically the +same as the DOS platform. Read section chapter "Dos specifics" in the manual +to learn more about this. + +

+Allegro programs under MacOS X are Cocoa applications; in order to hide all +the Cocoa interfacing to the enduser, you need to add the END_OF_MAIN() +macro right after your main() function. This is a necessary step: if you omit +it, your program will not compile. + +

+The END_OF_MAIN() macro simply does some magic to make sure your program +executes another function before your main(); this function is defined into +the liballeg-main.a static library, which is automatically linked if you use +the allegro-config script when linking. Otherwise be sure you link against it +unless you want to get undefined symbol errors. + +

+To behave nicely with the MacOS X user interface, Allegro apps will provide a +standard application menu with the "Quit" menu item in it. The default +behaviour when the user hits Command-Q or selects "Quit" is to do nothing. +To override this behaviour you must call the set_close_button_callback() function; under MacOS +X the supplied callback will be used either if the user clicks the window +close button either on Command-Q or "Quit" selection. In this last case the +application will not shutdown, but you are supposed to set some quit flag +in your callback and check for it on a regular basis in your main program +loop. + +

+If you would like to use InterfaceBuilder to design a more +fully-featured menu, Allegro will automatically load it if you create +a bundle for your application. The use of InterfaceBuilder is beyond +the scope of this document. Briefly, you need to create a Nib, called +MainMenu.nib, containing a main menu and a controller. Then, when you +create the bundle, install MainMenu.nib into the Contents/Resources +subdirectory. Note that the actions attached to the menu items will be +called from a different thread than the one in which your Allegro code +is running. Therefore you should not do any work there (especially, +don't call Allegro functions.) Instead, set a variable, and test it in +your main loop. + +


+

Drivers GFX_*/MacOSX

+ MacOS X Allegro supports the following card parameters for the + set_gfx_mode() function: + + +
See also: +set_gfx_mode.
+
Drivers DIGI_*/MacOSX

+ The MacOS X sound functions support the following digital soundcards: +
+      DIGI_AUTODETECT      - let Allegro pick a digital sound driver
+      DIGI_NONE            - no digital sound
+      DIGI_CORE_AUDIO      - CoreAudio digital output (OS >= X.2 required)
+      DIGI_SOUND_MANAGER   - Carbon Sound Manager digital output
+
+ + +
See also: +detect_digi_driver, +install_sound, +install_sound_input.
+
Drivers MIDI_*/MacOSX

+ The MacOS X sound functions support the following MIDI soundcards: +
+      MIDI_AUTODETECT      - let Allegro pick a MIDI sound driver
+      MIDI_NONE            - no MIDI sound
+      MIDI_CORE_AUDIO      - CoreAudio MIDI synthesizer (OS >= X.2 required)
+      MIDI_QUICKTIME       - QuickTime Music Note Allocator MIDI output
+      MIDI_DIGMID          - sample-based software wavetable player
+
+ + + +
See also: +detect_midi_driver, +install_sound, +install_sound_input.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg042.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg042.html new file mode 100644 index 0000000..0de4653 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg042.html @@ -0,0 +1,236 @@ + + +Allegro Manual: Differences between platforms + + + + +

Differences between platforms

+ +

+Here's a quick summary of things that may cause problems when moving your +code from one platform to another (you can find a more detailed version of +this in the docs section of the Allegro website). + +

+The Windows, Unix and MacOS X versions require you to write END_OF_MAIN() +after your main() function. This is used to magically turn an ISO C style +main() into a Windows style WinMain(), or by the Unix code to grab a copy +of your argv[] parameter, or by the MacOS X code to shell the user main() +inside a Cocoa application. + +

+On many platforms Allegro runs very slowly if you rely on it in order to +automatically lock bitmaps when drawing onto them. For good performance, +you need to call acquire_bitmap() and release_bitmap() yourself, and try +to keep the amount of locking to a minimum. + +

+The Windows version may lose the contents of video memory if the user +switches away from your program, so you need to deal with that. + +

+None of the currently supported platforms require input polling, but it is +possible that some future ones might, so if you want to ensure 100% +portability of your program, you should call poll_mouse() and +poll_keyboard() in all the relevant places. + +

+On Unix the shared files by Allegro (like `language.dat') may require a +special use due to the nature of distributing the resources in separate paths +instead of putting everything in the same directory. Check the beginning of +your platform's specific chapter to learn more about this. + +

+Allegro defines a number of standard macros that can be used to check +various attributes of the current platform: + +

+ALLEGRO_PLATFORM_STR
+ Text string containing the name of the current platform. + +

+ALLEGRO_DOS
+ALLEGRO_DJGPP
+ALLEGRO_WATCOM
+ALLEGRO_WINDOWS
+ALLEGRO_MSVC
+ALLEGRO_MINGW32
+ALLEGRO_BCC32
+ALLEGRO_UNIX
+ALLEGRO_LINUX
+ALLEGRO_BEOS
+ALLEGRO_QNX
+ALLEGRO_DARWIN
+ALLEGRO_MACOSX
+ALLEGRO_GCC
+ Defined if you are building for a relevant system. Often several of these + will apply, eg. DOS+Watcom, or Windows+GCC+MinGW. + +

+ALLEGRO_AMD64
+ALLEGRO_I386
+ALLEGRO_BIG_ENDIAN
+ALLEGRO_LITTLE_ENDIAN
+ Defined if you are building for a processor of the relevant type. + +

+ALLEGRO_MULTITHREADED
+ Defined if the library is internally multi-threaded on this system. + +

+ALLEGRO_USE_CONSTRUCTOR
+ Defined if the compiler supports constructor/destructor functions. + +

+ALLEGRO_VRAM_SINGLE_SURFACE
+ Defined if the screen is a single large surface that is then partitioned + into multiple video sub-bitmaps (eg. DOS), rather than each video bitmap + being a totally unique entity (eg. Windows). + +

+ALLEGRO_CONSOLE_OK
+ Defined if when you are not in a graphics mode, there is a text mode + console that you can printf() to, and from which the user could + potentially redirect stdout to capture it even while you are in a + graphics mode. If this define is absent, you are running in an + environment like Windows that has no stdout at all. + +

+ALLEGRO_MAGIC_MAIN
+ Defined if Allegro uses a magic main, i.e takes over the main() entry + point and turns it into a secondary entry point suited to its needs. + +

+ALLEGRO_LFN
+ Non-zero if long filenames are supported, or zero if you are limited to + 8.3 format (in the DJGPP version, this is a variable depending on the + runtime environment). + +

+LONG_LONG
+ Defined to whatever represents a 64-bit "long long" integer for the + current compiler, or not defined if that isn't supported. + +

+OTHER_PATH_SEPARATOR
+ Defined to a path separator character other than a forward slash for + platforms that use one (eg. a backslash under DOS and Windows), or + defined to a forward slash if there is no other separator character. + +

+DEVICE_SEPARATOR
+ Defined to the filename device separator character (a colon for DOS and + Windows), or to zero if there are no explicit devices in paths (Unix). + +

+Allegro can be customized at compile time to a certain extent with the +following macros: + +

+ALLEGRO_NO_MAGIC_MAIN
+ If you define this prior to including Allegro headers, Allegro won't + touch the main() entry point. This effectively removes the requirement + on a program to be linked against the Allegro library when it includes + the allegro.h header file. Note that the configuration and file routines + are not guaranteed to work on Unix systems when this symbol is defined. + Moreover, on Darwin/MacOS X systems, this symbol simply prevents the + program from being linked against the Allegro library! This highly non + portable feature is primarily intended to be used under Windows. + +

+ALLEGRO_USE_CONSOLE
+ If you define this prior to including Allegro headers, Allegro will be + set up for building a console application rather than the default GUI + program on some platforms (especially Windows). + +

+ALLEGRO_NO_STD_HEADER
+ If you define this prior to including Allegro headers, Allegro will not + automatically include some standard headers (eg <stddef.h>) its own + headers depend upon. + +

+ALLEGRO_NO_KEY_DEFINES
+ If you define this prior to including Allegro headers, Allegro will omit + the definition of the KEY_* constants, which may clash with other headers. + +

+ALLEGRO_NO_FIX_ALIASES
+ The fixed point functions used to be named with an "f" prefix instead of + "fix", eg. fixsqrt() used to be fsqrt(), but were renamed due to conflicts + with some libc implementations. So backwards compatibility aliases are + provided as static inline functions which map the old names to the new + names, eg. fsqrt() calls fixsqrt(). If you define this symbol prior to + including Allegro headers, the aliases will be turned off. + +

+ALLEGRO_NO_FIX_CLASS
+ If you define this symbol prior to including Allegro headers in a C++ + source file, the 'fix' class will not be made available. This mitigates + problems with the 'fix' class's overloading getting in the way. + +

+ALLEGRO_NO_VHLINE_ALIAS
+ The `curses' API also defines functions called vline() and hline(). + To avoid a linker conflict when both libraries are used, we have + internally renamed our functions and added inline function aliases which + remap vline() and hline(). This should not be noticable to most users. + +

+ If you define ALLEGRO_NO_VHLINE_ALIAS prior to including Allegro headers, + Allegro will not define the vline() and hline() aliases, e.g. so you can + include curses.h and allegro.h in the same module. + +

+ALLEGRO_NO_CLEAR_BITMAP_ALIAS
+ If you define this prior to including Allegro headers, Allegro will not + define the clear() backwards compatibility alias to clear_bitmap(). + +

+ALLEGRO_NO_COMPATIBILITY
+ If you define this prior to including Allegro headers, Allegro will not + include the backward compatibility layer. It is undefined by default so + old programs can still be compiled with the minimum amount of issues, + but you should define this symbol if you intend to maintain your code + up to date with the latest versions of Allegro. It automatically turns + off all backwards compatibility aliases. + +

+Allegro also defines a number of standard macros that can be used to +insulate you from some of the differences between systems: + +

+INLINE
+ Use this in place of the regular "inline" function modifier keyword, and + your code will work correctly on any of the supported compilers. + +

+RET_VOLATILE
+ Use this to declare a function with a volatile return value. + +

+ZERO_SIZE_ARRAY(type, name)
+ Use this to declare zero-sized arrays in terminal position inside + structures, like in the BITMAP structure. These arrays are effectively + equivalent to the flexible array members of ISO C99. + +

+AL_CONST
+ Use this in place of the regular "const" object modifier keyword, and + your code will work correctly on any of the supported compilers. + +

+AL_RAND()
+ On platforms that require it, this macro does a simple shift + transformation of the libc rand() function, in order to improve the + perceived randomness of the output series in the lower 16 bits. + Where not required, it directly translates into a rand() call. + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg043.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg043.html new file mode 100644 index 0000000..95390a3 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg043.html @@ -0,0 +1,180 @@ + + +Allegro Manual: Reducing your executable size + + + + +

Reducing your executable size

+ +

+Some people complain that Allegro produces very large executables. This is +certainly true: with the DJGPP version, a simple "hello world" program will +be about 200k, although the per-executable overhead is much less for +platforms that support dynamic linking. But don't worry, Allegro takes up a +relatively fixed amount of space, and won't increase as your program gets +larger. As George Foot so succinctly put it, anyone who is concerned about +the ratio between library and program code should just get to work and write +more program code to catch up :-) + +

+Having said that, there are several things you can do to make your programs +smaller: +

+Note: the aforementioned methods for removing unused hardware drivers only +apply to statically linked versions of the library, eg. DOS. On Windows and +Unix platforms, you can build Allegro as a DLL or shared library, which +prevents these methods from working, but saves so much space that you +probably won't care about that. Removing unused color depths from alconfig.h +will work on any platform, though. + +

+If you are distributing a copy of the setup program along with your game, +you may be able to get a dramatic size reduction by merging the setup code +into your main program, so that only one copy of the Allegro routines will +need to be linked. See setup.txt for details. In the DJGPP version, after +compressing the executable, this will probably save you about 200k compared +to having two separate programs for the setup and the game itself. + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg044.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg044.html new file mode 100644 index 0000000..e9fd4cd --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg044.html @@ -0,0 +1,163 @@ + + +Allegro Manual: Debugging + + + + +

Debugging

+ + + +

+There are three versions of the Allegro library: the normal optimised code, +one with extra debugging support, and a profiling version. See the platform +specific readme files for information about how to install and link with +these alternative libs. Although you will obviously want to use the +optimised library for the final version of your program, it can be very +useful to link with the debug lib while you are working on it, because this +will make debugging much easier, and includes assert tests that will help to +locate errors in your code at an earlier stage. Allegro also contains some +debugging helper functions: + +


+

void ASSERT(condition);

+ Debugging helper macro. Normally compiles away to nothing, but if you + defined the preprocessor symbol DEBUGMODE before including Allegro headers, + it will check the supplied condition and call al_assert() if it fails, + whose default action is to stop the program and report the assert. You can + use this macro even when Allegro has not been initialised. Example: +
+      #define DEBUGMODE
+      #include 
+      ...
+      void my_blitter(BITMAP *source, int flags)
+      {
+         int some_variables;
+         ASSERT(source != NULL);
+         ASSERT(flags & GAME_RUNNING);
+         ...
+      }
+ + +
See also: +al_assert, +TRACE, +register_assert_handler.
+ +
Examples using this: +expackf.
+
void TRACE(char *msg, ...);

+ Debugging helper macro. Normally compiles away to nothing, but if you + defined the preprocessor symbol DEBUGMODE before including Allegro headers, + it passes the supplied message given in ASCII format to al_trace(). + Example: +
+      #define DEBUGMODE
+      #include 
+      ...
+      void my_blitter(BITMAP *source, int flags)
+      {
+         static int count_call = 0;
+         TRACE("my_blitter() called %d times.\n", count_call++);
+         ...
+      }
+ + +
See also: +al_trace, +ASSERT, +register_trace_handler.
+
void register_assert_handler(int (*handler)(const char *msg));

+ Supplies a custom handler function for dealing with assert failures. Your + callback will be passed a formatted error message in ASCII, and should + return non-zero if it has processed the error, or zero to continue with + the default actions. You could use this to ignore assert failures, or to + display the error messages on a graphics mode screen without aborting the + program. Example: +
+   int show_but_continue(const char *text)
+   {
+       alert("Uh oh...", "Fasten your seat belts.", text,
+             "&Go on!", NULL, 'g', 0);
+       return 1;
+   }
+   ...
+      register_assert(show_but_continue);
+      ASSERT(0); /* This won't crash the program now. */
+ + +
See also: +al_assert, +ASSERT, +register_trace_handler.
+
void register_trace_handler(int (*handler)(const char *msg));

+ Supplies a custom handler function for dealing with trace output. Your + callback will be passed a formatted error message in ASCII, and should + return non-zero if it has processed the message, or zero to continue with + the default actions. You could use this to ignore trace output, or to + display the messages on a second monochrome monitor, etc. Example: +
+   int network_broadcaster(const char *text)
+   {
+      int f;
+
+      for (int f = 0; f < connected_clients; f++)
+         send_msg_to_client(client[f], text);
+         
+      return 0; /* Let normal tracing occur. */
+   }
+   ...
+      register_trace_handler(network_broadcaster);
+      TRACE("Networked tracing activated\n");
+ + +
See also: +al_trace, +TRACE, +register_assert_handler.
+
void al_assert(const char *file, int line);

+ Raises an assert for an error at the specified file and line number. The + file parameter is always given in ASCII format. By default, this will call + the system driver's assert handler. If there is none, the error will be + sent to stderr and the program will abort. However, if the environment + variable ALLEGRO_ASSERT is set, this function writes a message into the + file specified by the environment variable and program execution will + continue. If none of this behaviours is wanted, you can override them with + a custom assert handler. + +

+ You will usually want to use the ASSERT() macro instead of calling this + function directly. + + +

See also: +ASSERT, +al_trace, +register_assert_handler.
+
void al_trace(const char *msg, ...);

+ Outputs a debugging trace message, using a printf() format string given + in ASCII. If you have installed a custom trace handler it uses that, or + if the environment variable ALLEGRO_TRACE is set it writes into the file + specified by the environment, otherwise it writes the message to + "allegro.log" in the current directory. You will usually want to use the + TRACE() macro instead of calling this function directly. + + + + +
See also: +TRACE, +al_assert, +register_trace_handler.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg045.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg045.html new file mode 100644 index 0000000..0a686e9 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg045.html @@ -0,0 +1,223 @@ + + +Allegro Manual: Makefile targets + + + + +

Makefile targets

+ +

+There are a number of options that you can use to control exactly how +Allegro will be compiled. On Unix platforms, you do this by passing arguments +to the configure script (run "configure --help" for a list), but on other +platforms you can set the following environment variables: +

+If you only want to recompile a specific test program or utility, you can +specify it as an argument to make, eg. "make demo" or "make grabber". The +makefiles also provide some special pseudo-targets: + + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg046.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg046.html new file mode 100644 index 0000000..6022cc2 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg046.html @@ -0,0 +1,2364 @@ + + +Allegro Manual: Available Allegro examples + + + + +

Available Allegro examples

+ + + +

+With Allegro comes quite a bunch of examples, which go from the simple +introductory `Hello world' to more complicated programs featuring truecolor +blending effects. This chapter describes these examples which you can find +in the allegro/examples folder. You don't have to go through them in the same +order as this documentation, but doing so you will learn the basic functions +and avoid missing any important bit of information. + +


+

Example exhello

+ This is a very simple program showing how to get into graphics + mode and draw text onto the screen. + + +
See also: +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_error, +allegro_init, +allegro_message, +clear_to_color, +desktop_palette, +font, +install_keyboard, +makecol, +readkey, +release_screen, +screen, +set_gfx_mode, +set_palette, +textout_centre_ex.
+
Example exmem

+ This program demonstrates the use of memory bitmaps. It creates + a small temporary bitmap in memory, draws some circles onto it, + and then blits lots of copies of it onto the screen. + + +
See also: +BITMAP, +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_error, +allegro_init, +allegro_message, +blit, +circle, +clear_bitmap, +create_bitmap, +desktop_palette, +destroy_bitmap, +install_keyboard, +palette_color, +readkey, +release_screen, +screen, +set_gfx_mode, +set_palette.
+
Example expal

+ This program demonstrates how to manipulate the palette. It draws + a set of concentric circles onto the screen and animates them by + cycling the palette. + + +
See also: +END_OF_MAIN, +PALETTE, +RGB, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_error, +allegro_init, +allegro_message, +black_palette, +circlefill, +install_keyboard, +install_mouse, +keypressed, +release_screen, +screen, +set_gfx_mode, +set_palette, +show_mouse.
+
Example expat

+ This program demonstrates the use of patterned drawing and sub-bitmaps. + + +
See also: +BITMAP, +END_OF_MAIN, +acquire_bitmap, +allegro_error, +allegro_init, +allegro_message, +bitmap_mask_color, +blit, +clear_to_color, +create_bitmap, +create_sub_bitmap, +desktop_palette, +destroy_bitmap, +drawing_mode, +font, +install_keyboard, +makecol, +masked_blit, +palette_color, +readkey, +rectfill, +release_bitmap, +screen, +set_gfx_mode, +set_palette, +solid_mode, +text_height, +text_length, +textout_ex.
+
Example exflame

+ This program demonstrates how to write directly to video memory. + It implements a simple fire effect, first by calling getpixel() and + putpixel(), then by accessing video memory directly a byte at a + time, and finally using block memory copy operations. + + +
See also: +END_OF_MAIN, +PALETTE, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_error, +allegro_init, +allegro_message, +bmp_read_line, +bmp_unwrite_line, +bmp_write_line, +clear_keybuf, +font, +getpixel, +install_keyboard, +keypressed, +line, +makecol, +putpixel, +release_screen, +screen, +set_gfx_mode, +set_palette, +textout_ex.
+
Example exdbuf

+ This program demonstrates the use of double buffering. + It moves a circle across the screen, first just erasing and + redrawing directly to the screen, then with a double buffer. + + +
See also: +BITMAP, +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_error, +allegro_init, +allegro_message, +blit, +circlefill, +clear_keybuf, +clear_to_color, +create_bitmap, +desktop_palette, +destroy_bitmap, +font, +install_keyboard, +install_timer, +keypressed, +makecol, +release_screen, +retrace_count, +screen, +set_gfx_mode, +set_palette, +textprintf_ex.
+
Example exflip

+ This program moves a circle across the screen, first with a + double buffer and then using page flips. + + +
See also: +BITMAP, +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +circlefill, +clear_keybuf, +clear_to_color, +create_bitmap, +create_video_bitmap, +desktop_palette, +destroy_bitmap, +font, +install_keyboard, +install_timer, +keypressed, +makecol, +retrace_count, +screen, +set_gfx_mode, +set_palette, +show_video_bitmap, +textprintf_ex.
+
Example exfixed

+ This program demonstrates how to use fixed point numbers, which + are signed 32-bit integers storing the integer part in the + upper 16 bits and the decimal part in the 16 lower bits. This + example also uses the unusual approach of communicating with + the user exclusively via the allegro_message() function. + + +
See also: +END_OF_MAIN, +allegro_init, +allegro_message, +fixdiv, +fixed, +fixmul, +fixsqrt, +fixtof, +ftofix, +itofix.
+
Example exfont

+ This is a very simple program showing how to load and manipulate fonts. + + +
See also: +END_OF_MAIN, +FONT, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_error, +allegro_init, +allegro_message, +clear_to_color, +desktop_palette, +destroy_font, +extract_font_range, +font, +install_keyboard, +load_font, +makecol, +merge_fonts, +readkey, +release_screen, +screen, +set_gfx_mode, +set_palette, +textout_centre_ex.
+
Example exmouse

+ This program demonstrates how to get mouse input. The + first part of the test retrieves the raw mouse input data + and displays it on the screen without using any mouse + cursor. When you press a key the standard arrow-like mouse + cursor appears. You are not restricted to this shape, + and a second keypress modifies the cursor to be several + concentric colored circles. They are not joined together, + so you can still see bits of what's behind when you move the + cursor over the printed text message. + + +
See also: +BITMAP, +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_error, +allegro_init, +allegro_message, +bitmap_mask_color, +circle, +clear_keybuf, +clear_to_color, +create_bitmap, +desktop_palette, +destroy_bitmap, +font, +get_mouse_mickeys, +install_keyboard, +install_mouse, +install_timer, +key, +keypressed, +makecol, +mouse_b, +mouse_x, +mouse_y, +mouse_z, +palette_color, +poll_mouse, +readkey, +release_screen, +screen, +set_gfx_mode, +set_mouse_sprite, +set_mouse_sprite_focus, +set_palette, +show_mouse, +textout_centre_ex, +textout_ex, +textprintf_centre_ex, +textprintf_ex, +vsync.
+
Example extimer

+ This program demonstrates how to use the timer routines. + These can be a bit of a pain, because you have to be sure + you lock all the memory that is used inside your interrupt + handlers. The first part of the example shows a basic use of + timing using the blocking function rest(). The second part + shows how to use three timers with different frequencies in + a non blocking way. + + +
See also: +END_OF_FUNCTION, +END_OF_MAIN, +LOCK_FUNCTION, +LOCK_VARIABLE, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +clear_to_color, +desktop_palette, +font, +install_int, +install_int_ex, +install_keyboard, +install_timer, +key, +keypressed, +makecol, +readkey, +rest, +screen, +set_gfx_mode, +set_palette, +textprintf_centre_ex.
+
Example exkeys

+ This program demonstrates how to access the keyboard. The + first part shows the basic use of readkey(). The second part + shows how to extract the ASCII value. Next come the scancodes. + The fourth test detects modifier keys like alt or shift. The + fifth test requires some focus to be passed. The final step + shows how to use the global key array to read simultaneous + keypresses. + The last method to detect key presses are keyboard callbacks. + This is demonstrated by by installing a keyboard callback, + which marks all pressed keys by drawing to a grid. + + +
See also: +END_OF_FUNCTION, +END_OF_MAIN, +LOCK_FUNCTION, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_error, +allegro_init, +allegro_message, +blit, +clear_keybuf, +clear_to_color, +desktop_palette, +font, +install_keyboard, +install_timer, +key, +key_shifts, +keyboard_lowlevel_callback, +keypressed, +makecol, +readkey, +rectfill, +release_screen, +rest, +scancode_to_name, +screen, +set_gfx_mode, +set_palette, +textprintf_centre_ex, +textprintf_ex, +ureadkey, +usprintf, +ustrzncpy.
+
Example exjoy

+ This program uses the Allegro library to detect and read the value + of a joystick. The output of the program is a small target sight + on the screen which you can move. At the same time the program will + tell you what you are doing with the joystick (moving or firing). + + +
See also: +BITMAP, +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +calibrate_joystick, +calibrate_joystick_name, +circle, +clear_bitmap, +clear_keybuf, +create_bitmap, +default_palette, +destroy_bitmap, +drawing_mode, +font, +install_joystick, +install_keyboard, +joy, +key, +keypressed, +num_joysticks, +palette_color, +poll_joystick, +putpixel, +readkey, +screen, +set_gfx_mode, +set_palette, +textout_centre_ex, +textprintf_centre_ex, +textprintf_ex.
+
Example exsample

+ This program demonstrates how to play samples. You have to + use this example from the commandline to specify as first + parameter a WAV or VOC sound file to play. If the file is + loaded successfully, the sound will be played in an infinite + loop. While it is being played, you can use the left and right + arrow keys to modify the panning of the sound. You can also + use the up and down arrow keys to modify the pitch. + + +
See also: +END_OF_MAIN, +SAMPLE, +SCREEN_H, +SCREEN_W, +adjust_sample, +allegro_error, +allegro_init, +allegro_message, +clear_to_color, +desktop_palette, +destroy_sample, +font, +install_keyboard, +install_sound, +install_timer, +key, +load_sample, +makecol, +play_sample, +poll_keyboard, +rest, +screen, +set_gfx_mode, +set_palette, +textprintf_centre_ex.
+
Example exmidi

+ This program demonstrates how to play MIDI files. + + +
See also: +END_OF_MAIN, +MIDI, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +clear_to_color, +desktop_palette, +destroy_midi, +font, +get_filename, +get_midi_length, +install_keyboard, +install_sound, +install_timer, +key, +keypressed, +load_midi, +makecol, +midi_pause, +midi_pos, +midi_resume, +midi_time, +play_midi, +readkey, +rectfill, +rest, +screen, +set_display_switch_mode, +set_gfx_mode, +set_palette, +text_height, +text_length, +textprintf_centre_ex.
+
Example exgui

+ This program demonstrates how to use the GUI routines. From + the simple dialog controls that display a text or a bitmap to + more complex multiple choice selection lists, Allegro provides + a framework which can be customised to suit your needs. + + +
See also: +DATAFILE, +DIALOG, +END_OF_MAIN, +MENU, +active_menu, +alert, +allegro_error, +allegro_init, +allegro_message, +d_bitmap_proc, +d_box_proc, +d_button_proc, +d_check_proc, +d_clear_proc, +d_ctext_proc, +d_edit_proc, +d_icon_proc, +d_keyboard_proc, +d_list_proc, +d_menu_proc, +d_radio_proc, +d_rtext_proc, +d_shadow_box_proc, +d_slider_proc, +d_text_list_proc, +d_text_proc, +d_textbox_proc, +d_yield_proc, +do_dialog, +gui_bg_color, +gui_fg_color, +gui_mg_color, +install_keyboard, +install_mouse, +install_timer, +key, +load_datafile, +makecol, +position_dialog, +replace_filename, +screen, +set_dialog_color, +set_gfx_mode, +set_palette, +unload_datafile, +ustrtok, +ustrzcat, +ustrzcpy, +uszprintf.
+
Example excustom

+ A follow up of the exgui.c example showing how to customise the + default Allegro framework. In this case a dialog procedure + animates a graphical clock without disrupting other GUI + dialogs. A more simple option shows how to dynamically change + the font used by all GUI elements. + + +
See also: +BITMAP, +DATAFILE, +DIALOG, +END_OF_MAIN, +FONT, +allegro_error, +allegro_init, +allegro_message, +blit, +circle, +circlefill, +clear_to_color, +create_bitmap, +d_button_proc, +d_check_proc, +d_clear_proc, +d_edit_proc, +desktop_palette, +destroy_bitmap, +do_dialog, +fixcos, +fixed, +fixmul, +fixsin, +fixtoi, +font, +install_keyboard, +install_mouse, +install_timer, +itofix, +key, +line, +load_datafile, +makecol, +object_message, +replace_filename, +screen, +set_gfx_mode, +set_palette, +unload_datafile.
+
Example exunicod

+ This program demonstrates the use of the 16-bit Unicode text + encoding format with Allegro. The example displays a message + translated to different languages scrolling on the screen + using an external font containing the required characters to + display those messages. + +

+ Note how the Allegro unicode string functions resemble the + functions you can find in the standard C library, only these + handle Unicode on all platforms. + + +

See also: +BITMAP, +DATAFILE, +END_OF_MAIN, +FONT, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +clear_to_color, +create_bitmap, +font, +install_int_ex, +install_keyboard, +install_timer, +keypressed, +load_datafile, +replace_filename, +rest, +screen, +set_gfx_mode, +set_uformat, +set_window_title, +text_height, +text_length, +textout_ex, +uconvert_ascii, +unload_datafile, +ustrcat, +ustrcpy, +ustrsize, +ustrsizez.
+
Example exbitmap

+ This program demonstrates how to load and display a bitmap + file. You have to use this example from the commandline to + specify as first parameter a graphic file in one of Allegro's + supported formats. If the file is loaded successfully, + it will be displayed until you press a key. + + +
See also: +BITMAP, +END_OF_MAIN, +PALETTE, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +destroy_bitmap, +install_keyboard, +load_bitmap, +readkey, +screen, +set_gfx_mode, +set_palette.
+
Example exscale

+ This example demonstrates how to use pcx files, palettes and stretch + blits. It loads a pcx file, sets its palette and does some random + stretch_blits. Don't worry - it's VERY slowed down using vsync(). + + +
See also: +BITMAP, +END_OF_MAIN, +PALETTE, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +destroy_bitmap, +install_keyboard, +keypressed, +load_pcx, +replace_filename, +screen, +set_gfx_mode, +set_palette, +stretch_blit, +vsync.
+
Example exconfig

+ This is a very simple program showing how to use the allegro + config (ini file) routines. A first look at the example + shows nothing more than a static graphic and the wait for + a keypress. However, the way this graphic is displayed is + configured through a custom exconfig.ini file which is loaded + manually. From this file the example obtains parameters like + fullscreen/windowed mode, a specific graphic resolution to set + up, which graphic to show, how to blit it on the screen, etc. + + +
See also: +BITMAP, +END_OF_MAIN, +RGB, +SCREEN_H, +SCREEN_W, +allegro_init, +allegro_message, +blit, +clear_bitmap, +font, +get_config_argv, +get_config_int, +get_config_string, +install_keyboard, +line, +load_bitmap, +makecol, +pop_config_state, +push_config_state, +readkey, +screen, +set_color_depth, +set_config_file, +set_gfx_mode, +set_palette, +stretch_blit, +textout_centre_ex, +textprintf_centre_ex, +ustrdup, +ustricmp.
+
Example exdata

+ This program demonstrates how to access the contents of an + Allegro datafile (created by the grabber utility). The example + loads the file `example.dat', then blits a bitmap and shows + a font, both from this datafile. + + +
See also: +DATAFILE, +END_OF_MAIN, +allegro_error, +allegro_init, +allegro_message, +blit, +font, +install_keyboard, +load_datafile, +makecol, +readkey, +replace_filename, +screen, +set_color_conversion, +set_gfx_mode, +set_palette, +textout_ex, +unload_datafile.
+
Example exsprite

+ This example demonstrates how to use datafiles, various sprite + drawing routines and flicker-free animation. + +

+ Why is the animate() routine coded in that way? As you + probably know, VIDEO RAM is much slower than "normal" + RAM, so it's advisable to reduce VRAM blits to a minimum. + Drawing sprite on the screen (meaning in VRAM) and then + clearing a background for it is not very fast. This example + uses a different method which is much faster, but require a + bit more memory. + +

+ First the buffer is cleared (it's a normal BITMAP), then the + sprite is drawn on it, and when the drawing is finished this + buffer is copied directly to the screen. So the end result is + that there is a single VRAM blit instead of blitting/clearing + the background and drawing a sprite on it. It's a good method + even when you have to restore the background. And of course, + it completely removes any flickering effect. + +

+ When one uses a big (ie. 800x600 background) and draws + something on it, it's wise to use a copy of background + somewhere in memory and restore background using this + "virtual background". When blitting from VRAM in SVGA modes, + it's probably, that drawing routines have to switch banks on + video card. I think, I don't have to remind how slow is it. + +

+ Note that on modern systems, the above isn't true anymore, and + you usually get the best performance by caching all your + animations in video ram and doing only VRAM->VRAM blits, so + there is no more RAM->VRAM transfer at all anymore. And usually, + such transfers can run in parallel on the graphics card's + processor as well, costing virtually no main cpu time at all. + See the exaccel example for an example of this. + + +

See also: +BITMAP, +DATAFILE, +END_OF_FUNCTION, +END_OF_MAIN, +LOCK_FUNCTION, +LOCK_VARIABLE, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +circle, +clear_bitmap, +clear_keybuf, +create_bitmap, +destroy_bitmap, +draw_sprite, +draw_sprite_h_flip, +draw_sprite_v_flip, +draw_sprite_vh_flip, +fixed, +font, +hline, +install_int_ex, +install_keyboard, +install_sound, +install_timer, +itofix, +key, +keypressed, +load_datafile, +makecol, +palette_color, +pivot_sprite, +pivot_sprite_v_flip, +play_sample, +rectfill, +replace_filename, +rest, +screen, +set_gfx_mode, +set_palette, +text_height, +textout_centre_ex, +unload_datafile, +vsync.
+
Example exexedat

+ This program demonstrates how to access the contents of an Allegro + datafile (created by the grabber utility) linked to the exe by the + exedat tool. It is basically the exdata example with minor + modifications. + +

+ You may ask: how do you compile, append and exec your program? + +

+ Answer: like this... + +

+ 1) Compile your program like normal. Use the magic filenames with '#' + to load your data where needed. + +

+ 2) Once you compressed your program, run "exedat foo.exe data.dat" + +

+ 3) Finally run your program. + +

+ Note that appending data to the end of binaries may not be portable + accross all platforms supported by Allegro. + + +

See also: +DATAFILE, +END_OF_MAIN, +allegro_error, +allegro_init, +allegro_message, +blit, +font, +install_keyboard, +line, +load_datafile, +makecol, +readkey, +screen, +set_color_conversion, +set_gfx_mode, +set_palette, +textout_ex, +unload_datafile.
+
Example extrans

+ This program demonstrates how to use the lighting and + translucency functions. The first part of the example will + show a dark screen iluminated by a spotlight you can move + with your mouse. After a keypress the example shows the full + bitmap and the spotlight changes to be a reduced version of + the background with 50% of translucency. + +

+ The translucency effect is easy to do in all color depths. + However, the lighting effect has to be performed in a different + way depending on whether the screen is in 8bit mode or another + color depth. This is because additive drawing mode uses a + different set of routines for truecolor modes. + + +

See also: +BITMAP, +COLOR_MAP, +END_OF_MAIN, +PALETTE, +RGB, +RGB_MAP, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +bitmap_color_depth, +blit, +circlefill, +clear_bitmap, +clear_keybuf, +color_map, +create_bitmap, +create_bitmap_ex, +create_light_table, +create_rgb_table, +create_trans_table, +destroy_bitmap, +draw_trans_sprite, +drawing_mode, +install_keyboard, +install_mouse, +install_timer, +keypressed, +load_bitmap, +mouse_x, +mouse_y, +poll_mouse, +rectfill, +replace_filename, +rest, +rgb_map, +screen, +set_alpha_blender, +set_gfx_mode, +set_palette, +set_trans_blender, +set_write_alpha_blender, +stretch_blit.
+
Example extruec

+ This program shows how to specify colors in the various different + truecolor pixel formats. The example shows the same screen (a few + text lines and three coloured gradients) in all the color depth + modes supported by your video card. The more color depth you have, + the less banding you will see in the gradients. + + +
See also: +END_OF_MAIN, +PALETTE, +RGB, +SCREEN_H, +SCREEN_W, +acquire_screen, +allegro_init, +clear_to_color, +font, +generate_332_palette, +install_keyboard, +key, +makecol, +readkey, +release_screen, +screen, +set_color_depth, +set_gfx_mode, +set_palette, +textout_centre_ex, +textout_ex, +textprintf_ex, +vline.
+
Example excolmap

+ This program demonstrates how to create custom graphic effects + with the create_color_table function. Allegro drawing routines + are affected by any color table you might have set up. In + the first part of this example, a greyscale color table is + set. The result is that a simple rectfill call, instead of + drawing a rectangle with color zero, uses the already drawn + pixels to determine the pixel to be drawn (read the comment + of return_grey_color() for a precise description of the + algorithm). In the second part of the test, the color table + is changed to be an inverse table, meaning that any pixel + drawn will be shown as its color values had been inverted. + + +
See also: +BITMAP, +COLOR_MAP, +END_OF_MAIN, +PALETTE, +RGB, +RGB_MAP, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +circlefill, +clear_keybuf, +color_map, +create_bitmap, +create_color_table, +create_rgb_table, +destroy_bitmap, +drawing_mode, +font, +generate_332_palette, +install_keyboard, +keypressed, +makecol, +rectfill, +rgb_map, +screen, +set_gfx_mode, +set_palette, +textout_centre_ex, +vsync.
+
Example exrgbhsv

+ This program shows how to convert colors between the different + color-space representations. The central area of the screen + will display the current color. On the top left corner of the + screen, three sliders allow you to modify the red, green and + blue value of the color. On the bottom right corner of the + screen, three sliders allow you to modify the hue, saturation + and value of the color. The color bars beneath the sliders + show what the resulting color will look like when the slider + is dragged to that position. + +

+ Additionally this example also shows how to "inherit" the + behaviour of a GUI object and extend it, here used to create + the sliders. + + +

See also: +BITMAP, +DIALOG, +END_OF_MAIN, +PALETTE, +RGB, +RGB_MAP, +allegro_error, +allegro_init, +allegro_message, +clear_to_color, +create_bitmap_ex, +create_rgb_table, +d_bitmap_proc, +d_box_proc, +d_slider_proc, +d_text_proc, +destroy_bitmap, +do_dialog, +font, +generate_332_palette, +get_color_depth, +hsv_to_rgb, +install_keyboard, +install_mouse, +install_timer, +key, +makecol, +makecol32, +makecol8, +object_message, +rgb_map, +rgb_to_hsv, +screen, +set_color, +set_color_depth, +set_gfx_mode, +set_palette, +textout_ex, +vline, +vsync.
+
Example exshade

+ This program demonstrates how to draw gouraud shaded (lit) + sprites. In an apparently black screen, a planet like sprite + is drawn close to the middle of the screen. In a similar + way to how the first test of extrans works, you move the + cursor on the screen with the mouse. Attached to this mouse + you can imagine a virtual spotlight illuminating the scene + around. Depending on where the mouse is, the goraud shaded + sprite will show the direction of the light. + + +
See also: +BITMAP, +COLOR_MAP, +END_OF_MAIN, +PALETTE, +RGB, +RGB_MAP, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +clear_bitmap, +color_map, +create_bitmap, +create_light_table, +create_rgb_table, +destroy_bitmap, +draw_gouraud_sprite, +font, +install_keyboard, +install_mouse, +keypressed, +line, +load_bitmap, +mouse_x, +mouse_y, +palette_color, +poll_mouse, +replace_filename, +rgb_map, +screen, +set_gfx_mode, +set_palette, +set_trans_blender, +show_mouse, +textout_ex.
+
Example exblend

+ This program demonstrates how to use the translucency functions + in truecolor video modes. Two image files are loaded from + disk and displayed moving slowly around the screen. One of + the images will be tinted to different colors. The other + image will be faded out with a varying alpha strength, and + drawn on top of the other image. + + +
See also: +BITMAP, +END_OF_MAIN, +PALETTE, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +circle, +clear_bitmap, +clear_keybuf, +create_bitmap, +destroy_bitmap, +draw_lit_sprite, +draw_trans_sprite, +fixcos, +fixsin, +fixtoi, +font, +install_keyboard, +install_timer, +itofix, +keypressed, +load_bitmap, +makecol, +replace_filename, +retrace_count, +screen, +set_color_conversion, +set_color_depth, +set_gfx_mode, +set_trans_blender, +textprintf_ex, +vsync.
+
Example exxfade

+ This program demonstrates how to load and display bitmap files + in truecolor video modes, and how to crossfade between them. + You have to use this example from the commandline to specify + as parameters a number of graphic files. Use at least two + files to see the graphical effect. The example will crossfade + from one image to another with each keypress until you press + the ESC key. + + +
See also: +BITMAP, +END_OF_MAIN, +PALETTE, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_exit, +allegro_init, +allegro_message, +blit, +create_bitmap, +destroy_bitmap, +draw_trans_sprite, +install_keyboard, +keypressed, +line, +load_bitmap, +readkey, +screen, +set_color_conversion, +set_color_depth, +set_gfx_mode, +set_palette, +set_trans_blender, +vsync.
+
Example exalpha

+ This program demonstrates how to use the 32 bit RGBA + translucency functions to store an alpha channel along with + a bitmap graphic. Two images are loaded from disk. One will + be used for the background and the other as a sprite. The + example generates an alpha channel for the sprite image, + composing the 32 bit RGBA bitmap during runtime, and draws + it at the position of the mouse cursor. + + +
See also: +BITMAP, +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +blit, +clear_keybuf, +create_bitmap, +destroy_bitmap, +draw_trans_sprite, +drawing_mode, +font, +getb, +getg, +getpixel, +getr, +install_keyboard, +install_mouse, +install_timer, +keypressed, +load_bitmap, +makecol, +mouse_x, +mouse_y, +putpixel, +rectfill, +replace_filename, +screen, +set_alpha_blender, +set_color_conversion, +set_color_depth, +set_gfx_mode, +set_multiply_blender, +set_write_alpha_blender, +solid_mode, +stretch_blit, +textprintf_ex.
+
Example exlights

+ This program shows one way to implement colored lighting effects + in a hicolor video mode. Warning: it is not for the faint of heart! + This is by no means the simplest or easiest to understand method, + I just thought it was a cool concept that would be worth + demonstrating. + +

+ The basic approach is to select a 15 or 16 bit screen mode, but + then draw onto 24 bit memory bitmaps. Since we only need the bottom + 5 bits of each 8 bit color in order to store 15 bit data within a + 24 bit location, we can fit a light level into the top 3 bits. + The tricky bit is that these aren't actually 24 bit images at all: + they are implemented as 8 bit memory bitmaps, and we just store the + red level in one pixel, green in the next, and blue in the next, + making the total image be three times wider than we really wanted. + This allows us to use all the normal 256 color graphics routines + for drawing onto our memory surfaces, most importantly the lookup + table translucency, which can be used to combine the low 5 bits + of color and the top 3 bits of light in a single drawing operation. + Some trickery is needed to load 24 bit data into this fake 8 bit + format, and of course it needs a custom routine to convert the + resulting image while copying it across to the hardware screen. + +

+ This program chugs slightly on my p133, but not significantly + worse than any double buffering in what amounts to a 1920x640, + 256 color resolution. The light blending doesn't seem to slow + it down too badly, so I think this technique would be quite usable + on faster machines and in lower resolution hicolor modes. The + biggest problem is that although you keep the full 15 bit color + resolution, you only get 3 bits of light, ie. 8 light levels. + You can do some nice colored light patches, but smooth gradients + aren't going to work too well :-) + + +

See also: +BITMAP, +COLOR_MAP, +END_OF_MAIN, +PALETTE, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +bitmap_color_depth, +blit, +bmp_unwrite_line, +bmp_write_line, +circlefill, +clear_bitmap, +clear_keybuf, +color_map, +create_bitmap_ex, +destroy_bitmap, +draw_trans_sprite, +fixatan2, +fixsqrt, +fixtoi, +getb_depth, +getg_depth, +getpixel, +getr_depth, +hsv_to_rgb, +install_keyboard, +install_mouse, +install_timer, +itofix, +key, +keypressed, +line, +load_bitmap, +makecol, +mouse_x, +mouse_y, +poll_mouse, +replace_filename, +retrace_count, +screen, +select_palette, +set_color_conversion, +set_color_depth, +set_gfx_mode.
+
Example ex3d

+ This program demonstrates how to use the 3d matrix functions. + It isn't a very elegant or efficient piece of code, but it + does show the stuff in action. It is left to the reader as + an exercise to design a proper model structure and rendering + pipeline: after all, the best way to do that sort of stuff + varies hugely from one game to another. + +

+ The example first shows a screen resolution selection dialog. + Then, a number of bouncing 3d cubes are animated. Pressing + a key modifies the rendering of the cubes, which can be + wireframe, the more complex transparent perspective correct + texture mapped version, and many other. + + +

See also: +BITMAP, +COLOR_MAP, +END_OF_MAIN, +MATRIX, +PALETTE, +POLYTYPE_ATEX, +POLYTYPE_ATEX_LIT, +POLYTYPE_ATEX_MASK, +POLYTYPE_ATEX_MASK_LIT, +POLYTYPE_ATEX_MASK_TRANS, +POLYTYPE_ATEX_TRANS, +POLYTYPE_FLAT, +POLYTYPE_GCOL, +POLYTYPE_GRGB, +POLYTYPE_PTEX, +POLYTYPE_PTEX_LIT, +POLYTYPE_PTEX_MASK, +POLYTYPE_PTEX_MASK_LIT, +POLYTYPE_PTEX_MASK_TRANS, +POLYTYPE_PTEX_TRANS, +RGB, +RGB_MAP, +SCREEN_H, +SCREEN_W, +V3D, +allegro_error, +allegro_exit, +allegro_init, +allegro_message, +apply_matrix, +bitmap_color_depth, +bitmap_mask_color, +blit, +clear_bitmap, +clear_to_color, +color_map, +create_bitmap, +create_light_table, +create_rgb_table, +create_trans_table, +desktop_palette, +destroy_bitmap, +fixed, +fixtoi, +font, +get_transformation_matrix, +gfx_mode_select_ex, +install_keyboard, +install_mouse, +install_timer, +itofix, +key, +keypressed, +line, +palette_color, +persp_project, +polygon_z_normal, +quad3d, +readkey, +rect, +retrace_count, +rgb_map, +screen, +set_color_depth, +set_gfx_mode, +set_palette, +set_projection_viewport, +set_trans_blender, +textout_ex, +textprintf_ex, +vsync.
+
Example excamera

+ This program demonstrates how to use the get_camera_matrix() + function to view a 3d world from any position and angle. The + example draws a checkered floor through a viewport region + on the screen. You can use the keyboard to move around the + camera or modify the size of the viewport. The keys that can + be used with this example are displayed between brackets at + the top of the screen. + + +
See also: +BITMAP, +END_OF_MAIN, +MATRIX_f, +POLYTYPE_FLAT, +SCREEN_H, +SCREEN_W, +V3D_f, +allegro_error, +allegro_init, +allegro_message, +apply_matrix_f, +blit, +clear_to_color, +clip3d_f, +create_bitmap, +desktop_palette, +destroy_bitmap, +font, +get_camera_matrix_f, +get_vector_rotation_matrix_f, +install_int_ex, +install_keyboard, +install_timer, +key, +key_shifts, +makecol, +persp_project_f, +poll_keyboard, +polygon, +polygon3d_f, +rect, +screen, +set_clip_rect, +set_gfx_mode, +set_palette, +set_projection_viewport, +textprintf_ex, +vsync.
+
Example exquat

+ Euler angles are convenient for storing and creating 3D orientations. + However, this program demonstrates that they are not good when + interpolating between two different orientations. The problem is + solved by using Allegro's quaternion operations. + +

+ In this program, two cubes are rotated between random orientations. + Notice that although they have the same beginning and ending + orientations, they do not follow the same path between orientations. + +

+ One cube is being rotated by directly incrementing or decrementing + the Euler angles from the starting point to the ending point. + This is an intuitive notion, but it is incorrect because it does not + cause the object to turn around a single unchanging axis of rotation. + The axis of rotation wobbles resulting in the object spinning in + strange ways. The object will eventually end up in the orientation + that the user intended, but it gets there in a way that is unattractive. + Imagine if this method was used to update the position of a camera in a + game! Sometimes it would swing wildly and disorient the player. + +

+ The other cube is animated using quaternions. This results in a much + more pleasing animation because the cube turns around a single axis + of rotation. + + +

See also: +BITMAP, +END_OF_MAIN, +MATRIX_f, +QUAT, +acquire_bitmap, +allegro_error, +allegro_init, +allegro_message, +apply_matrix_f, +blit, +circle, +clear_keybuf, +clear_to_color, +create_bitmap, +desktop_palette, +destroy_bitmap, +font, +get_camera_matrix_f, +get_rotation_matrix, +get_rotation_matrix_f, +get_rotation_quat, +install_keyboard, +keypressed, +line, +matrix_mul_f, +palette_color, +persp_project_f, +quat_interpolate, +quat_to_matrix, +readkey, +release_bitmap, +rest, +screen, +set_gfx_mode, +set_palette, +set_projection_viewport, +textout_ex.
+
Example exstars

+ This program draws a 3D starfield (depth-cued) and a polygon + starship (controllable with the keyboard cursor keys), using + the Allegro math functions. + + +
See also: +BITMAP, +END_OF_MAIN, +MATRIX, +PALETTE, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +apply_matrix, +blit, +clear_bitmap, +create_bitmap, +cross_product, +destroy_bitmap, +dot_product, +fixed, +fixmul, +fixtof, +fixtoi, +font, +get_rotation_matrix, +get_transformation_matrix, +get_translation_matrix, +install_keyboard, +install_timer, +itofix, +key, +normalize_vector, +palette_color, +persp_project, +poll_keyboard, +putpixel, +rectfill, +screen, +set_gfx_mode, +set_palette, +set_projection_viewport, +textout_centre_ex, +textprintf_centre_ex, +triangle, +vsync.
+
Example exscn3d

+ This program demonstrates how to use scanline sorting algo + in Allegro (create_scene, clear_scene, ... functions). It + also provides an example of how to use the 3D clipping + function. The example consists of a flyby through a lot of + rotating 3d cubes. + + + +
See also: +BITMAP, +END_OF_FUNCTION, +END_OF_MAIN, +LOCK_FUNCTION, +LOCK_VARIABLE, +MATRIX_f, +PALETTE, +POLYTYPE_GCOL, +SCREEN_H, +SCREEN_W, +V3D_f, +allegro_error, +allegro_exit, +allegro_init, +allegro_message, +apply_matrix_f, +bitmap_color_depth, +blit, +clear_bitmap, +clear_scene, +clip3d_f, +create_bitmap, +create_scene, +desktop_palette, +destroy_bitmap, +destroy_scene, +font, +get_rotation_matrix_f, +get_translation_matrix_f, +gfx_mode_select_ex, +install_int, +install_keyboard, +install_mouse, +install_timer, +key, +matrix_mul_f, +palette_color, +persp_project_f, +polygon_z_normal_f, +render_scene, +scene_polygon3d_f, +screen, +set_color_depth, +set_gfx_mode, +set_palette, +set_projection_viewport, +textprintf_ex.
+
Example exzbuf

+ This program demonstrates how to use Z-buffered polygons and + floating point 3D math routines. It also provides a simple + way to compute fps (frames per second) using a timer. After + selecting a screen resolution through the standard GUI dialog, + the example shows two 3D cubes rotating and intersecting each + other. Rather than having full polygons incorrectly overlap + other polgons due to per-polygon sorting, each pixel is drawn + at the correct depth. + + +
See also: +BITMAP, +END_OF_FUNCTION, +END_OF_MAIN, +LOCK_FUNCTION, +LOCK_VARIABLE, +MATRIX_f, +PALETTE, +POLYTYPE_GCOL, +SCREEN_H, +SCREEN_W, +V3D_f, +ZBUFFER, +allegro_error, +allegro_exit, +allegro_init, +allegro_message, +apply_matrix_f, +bitmap_color_depth, +blit, +clear_bitmap, +clear_zbuffer, +create_bitmap, +create_zbuffer, +desktop_palette, +destroy_bitmap, +destroy_zbuffer, +font, +get_transformation_matrix_f, +gfx_mode_select_ex, +install_int, +install_keyboard, +install_mouse, +install_timer, +keypressed, +palette_color, +persp_project_f, +polygon_z_normal_f, +quad3d_f, +readkey, +screen, +set_color_depth, +set_gfx_mode, +set_palette, +set_projection_viewport, +set_zbuffer, +textprintf_ex, +vsync.
+
Example exscroll

+ This program demonstrates how to use hardware scrolling. + The scrolling should work on anything that supports virtual + screens larger than the physical screen. + + +
See also: +BITMAP, +END_OF_MAIN, +RGB, +SCREEN_H, +SCREEN_W, +acquire_bitmap, +allegro_init, +allegro_message, +clear_keybuf, +create_sub_bitmap, +desktop_palette, +destroy_bitmap, +install_keyboard, +keypressed, +rectfill, +release_bitmap, +screen, +scroll_screen, +set_color, +set_gfx_mode, +set_palette, +vline.
+
Example ex3buf

+ This program demonstrates the use of triple buffering. Several + triangles are displayed rotating and bouncing on the screen + until you press a key. Note that on some platforms you + can't get real hardware triple buffering. The Allegro code + remains the same, but most likely the graphic driver will + emulate it. Unfortunately, in these cases you can't expect + the animation to be completely smooth and flicker free. + + +
See also: +BITMAP, +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +acquire_bitmap, +allegro_error, +allegro_init, +allegro_message, +clear_bitmap, +clear_keybuf, +create_video_bitmap, +desktop_palette, +destroy_bitmap, +enable_triple_buffer, +fixcos, +fixed, +fixmul, +fixsin, +fixtoi, +font, +gfx_capabilities, +install_keyboard, +install_mouse, +install_timer, +itofix, +keypressed, +poll_scroll, +release_bitmap, +request_video_bitmap, +screen, +set_gfx_mode, +set_palette, +textout_ex, +triangle, +ustrzcpy.
+
Example ex12bit

+ This program sets up a 12-bit mode on any 8-bit card, by + setting up a 256-colour palette that will fool the eye into + grouping two 8-bit pixels into one 12-bit pixel. In order + to do this, you make your 256-colour palette with all the + combinations of blue and green, assuming green ranges from 0-15 + and blue from 0-14. This takes up 16x15=240 colours. This + leaves 16 colours to use as red (red ranges from 0-15). + Then you put your green/blue in one pixel, and your red in + the pixel next to it. The eye gets fooled into thinking it's + all one pixel. + +

+ The example starts setting a normal 256 color mode, and + construct a special palette for it. But then comes the trick: + you need to write to a set of two adjacent pixels to form a + single 12 bit dot. Two eight bit pixels is the same as one 16 + bit pixel, so after setting the video mode you need to hack + the screen bitmap about, halving the width and changing it + to use the 16 bit drawing code. Then, once you have packed a + color into the correct format (using the makecol12() function + below), any of the normal Allegro drawing functions can be + used with this 12 bit display! + +

+ Things to note: + +

+

+ + +
See also: +BITMAP, +END_OF_MAIN, +MATRIX, +PALETTE, +RGB, +allegro_error, +allegro_init, +allegro_message, +apply_matrix, +blit, +circle, +clear_bitmap, +clear_keybuf, +clear_to_color, +create_bitmap, +create_bitmap_ex, +destroy_bitmap, +ellipsefill, +fade_out, +fixcos, +fixed, +fixsin, +fixtoi, +font, +get_rotation_matrix, +getpixel, +install_keyboard, +itofix, +keypressed, +line, +makecol, +masked_blit, +putpixel, +screen, +set_clip_rect, +set_color, +set_gfx_mode, +set_palette, +text_height, +text_length, +textout_ex, +textprintf_ex.
+
Example exaccel

+ This program demonstrates how to use an offscreen part of + the video memory to store source graphics for a hardware + accelerated graphics driver. The example loads the `mysha.pcx' + file and then blits it several times on the screen. Depending + on whether you have enough video memory and Allegro supports + the hardware acceleration features of your card, your success + running this example may be none at all, sluggish performance + due to software emulation, or flicker free smooth hardware + accelerated animation. + + +
See also: +BITMAP, +END_OF_MAIN, +PALETTE, +SCREEN_H, +SCREEN_W, +acquire_bitmap, +allegro_error, +allegro_init, +allegro_message, +blit, +clear_bitmap, +create_video_bitmap, +destroy_bitmap, +font, +gfx_capabilities, +install_keyboard, +install_timer, +keypressed, +load_bitmap, +readkey, +release_bitmap, +replace_filename, +screen, +set_gfx_mode, +set_palette, +show_video_bitmap, +textout_ex, +textprintf_ex.
+
Example exspline

+ This program demonstrates the use of spline curves to create smooth + paths connecting a number of node points. This can be useful for + constructing realistic motion and animations. + +

+ The technique is to connect the series of guide points p1..p(n) with + spline curves from p1-p2, p2-p3, etc. Each spline must pass though + both of its guide points, so they must be used as the first and fourth + of the spline control points. The fun bit is coming up with sensible + values for the second and third spline control points, such that the + spline segments will have equal gradients where they meet. I came + up with the following solution: + +

+ For each guide point p(n), calculate the desired tangent to the curve + at that point. I took this to be the vector p(n-1) -> p(n+1), which + can easily be calculated with the inverse tangent function, and gives + decent looking results. One implication of this is that two dummy + guide points are needed at each end of the curve, which are used in + the tangent calculations but not connected to the set of splines. + +

+ Having got these tangents, it becomes fairly easy to calculate the + spline control points. For a spline between guide points p(a) and + p(b), the second control point should lie along the positive tangent + from p(a), and the third control point should lie along the negative + tangent from p(b). How far they are placed along these tangents + controls the shape of the curve: I found that applying a 'curviness' + scaling factor to the distance between p(a) and p(b) works well. + +

+ One thing to note about splines is that the generated points are + not all equidistant. Instead they tend to bunch up nearer to the + ends of the spline, which means you will need to apply some fudges + to get an object to move at a constant speed. On the other hand, + in situations where the curve has a noticable change of direction + at each guide point, the effect can be quite nice because it makes + the object slow down for the curve. + + +

See also: +END_OF_MAIN, +SCREEN_W, +acquire_screen, +alert, +allegro_error, +allegro_init, +allegro_message, +calc_spline, +circlefill, +clear_keybuf, +clear_to_color, +desktop_palette, +fixatan2, +fixcos, +fixed, +fixmul, +fixsin, +fixsqrt, +fixtof, +fixtoi, +font, +ftofix, +install_keyboard, +install_mouse, +install_timer, +itofix, +key, +keypressed, +line, +makecol, +mouse_b, +mouse_x, +mouse_y, +palette_color, +poll_mouse, +readkey, +release_screen, +screen, +set_gfx_mode, +set_palette, +show_mouse, +spline, +textout_centre_ex, +textprintf_centre_ex, +textprintf_ex, +vsync, +xor_mode.
+
Example exsyscur

+ This program demonstrates the use of hardware accelerated mouse cursors. + + +
See also: +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +clear_to_color, +enable_hardware_cursor, +font, +gfx_capabilities, +install_keyboard, +install_mouse, +install_timer, +makecol, +readkey, +screen, +select_mouse_cursor, +set_gfx_mode, +show_mouse, +text_height, +textprintf_centre_ex.
+
Example exupdate

+ This program demonstrates how to support double buffering, + page flipping, and triple buffering as options within a single + program, and how to make things run at a constant rate no + matter what the speed of your computer. You have to use this + example from the commandline to specify as first parameter a + number which represents the type of video update you want: 1 + for double buffering with memory bitmaps, 2 for page flipping, + 3 for triple buffering and 4 for double buffering with system + bitmaps. After this, a dialog allows you to select a screen + resolution and finally you will see a kaleidoscopic animation, + along with a frames per second counter on the top left of + the screen. + + +
See also: +BITMAP, +END_OF_FUNCTION, +END_OF_MAIN, +LOCK_FUNCTION, +LOCK_VARIABLE, +PALETTE, +SCREEN_H, +SCREEN_W, +acquire_bitmap, +allegro_error, +allegro_init, +allegro_message, +bitmap_color_depth, +blit, +clear_bitmap, +create_bitmap, +create_system_bitmap, +create_video_bitmap, +desktop_palette, +destroy_bitmap, +enable_triple_buffer, +fixcos, +fixed, +fixmul, +fixsin, +fixtoi, +font, +ftofix, +generate_332_palette, +gfx_capabilities, +gfx_mode_select_ex, +install_int_ex, +install_keyboard, +install_mouse, +install_timer, +keypressed, +line, +makecol, +poll_scroll, +release_bitmap, +request_video_bitmap, +screen, +set_color_depth, +set_gfx_mode, +set_palette, +show_video_bitmap, +textout_ex, +textprintf_ex, +triangle, +vsync, +xor_mode.
+
Example exswitch

+ This program shows how to control the console switching mode, and + let your program run in the background. These functions don't apply + to every platform and driver, for example you can't control the + switching mode from a DOS program. + +

+ Yes, I know the fractal drawing is very slow: that's the point! + This is so you can easily check whether it goes on working in the + background after you switch away from the app. + +

+ Depending on the type of selected switching mode, you will see + whether the contents of the screen are preserved or not. + + +

See also: +BITMAP, +END_OF_FUNCTION, +END_OF_MAIN, +LOCK_FUNCTION, +LOCK_VARIABLE, +PALETTE, +SCREEN_H, +SCREEN_W, +acquire_bitmap, +acquire_screen, +allegro_error, +allegro_exit, +allegro_init, +allegro_message, +bitmap_color_depth, +blit, +clear_to_color, +create_sub_bitmap, +desktop_palette, +destroy_bitmap, +font, +get_display_switch_mode, +gfx_mode_select_ex, +install_int, +install_keyboard, +install_mouse, +install_timer, +keypressed, +makecol, +palette_color, +putpixel, +readkey, +rectfill, +release_bitmap, +release_screen, +screen, +set_color_depth, +set_display_switch_callback, +set_display_switch_mode, +set_gfx_mode, +set_palette, +textout_centre_ex, +textprintf_centre_ex.
+
Example exstream

+ This program shows how to use the audio stream functions to + transfer large blocks of sample data to the soundcard. In + this case, the sample data is generated during runtime, + and the resulting sound reminds of a car engine when you + are accelerating. + + +
See also: +AUDIOSTREAM, +END_OF_MAIN, +SCREEN_H, +SCREEN_W, +allegro_error, +allegro_init, +allegro_message, +clear_to_color, +desktop_palette, +font, +free_audio_stream_buffer, +get_audio_stream_buffer, +install_keyboard, +install_sound, +install_timer, +keypressed, +makecol, +play_audio_stream, +readkey, +screen, +set_gfx_mode, +set_palette, +stop_audio_stream, +textprintf_centre_ex, +voice_start, +voice_stop.
+
Example expackf

+ This program demonstrates the use of the packfile functions, with some + simple tests. + +

+ The first test uses the standard packfile functions to transfer a + bitmap file into a block of memory, then reads the bitmap out of the + block of memory, using a custom packfile vtable. + +

+ The second test reads in a bitmap with another custom packfile + vtable, which uses libc's filestream functions. + +

+ The third test demonstrates seeking with a custom vtable. + +

+ The fourth test reads two bitmaps, and dumps them back into a + single file, using a custom vtable again. + + + + +

See also: +ASSERT, +BITMAP, +END_OF_MAIN, +PACKFILE, +PACKFILE_VTABLE, +SCREEN_H, +SCREEN_W, +alert, +allegro_error, +allegro_init, +allegro_message, +blit, +clear_bitmap, +destroy_bitmap, +file_size_ex, +font, +install_keyboard, +key, +load_bmp_pf, +load_pcx, +load_pcx_pf, +load_tga_pf, +pack_fclose, +pack_fopen, +pack_fopen_vtable, +pack_fread, +pack_fseek, +readkey, +save_bmp_pf, +save_tga_pf, +screen, +set_color_depth, +set_gfx_mode, +text_height, +textprintf_centre_ex, +textprintf_ex.
+
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg047.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg047.html new file mode 100644 index 0000000..abc82bd --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg047.html @@ -0,0 +1,70 @@ + + +Allegro Manual: Community + + + + +

Community

+ +

+Allegro was originally created by Shawn Hargreaves. Published sometime between +1994 and 1995, it was just a simple lib for himself. At that time, many people +were switching from Borland C to DJGPP and looking for a decent graphics +library. Allegro was the first reasonably complete one to show up, so it +attracted enough interest to keep growing, and a little contribution here, and +some more encouragement there made it all light up like fire. + +

+Some time after the latest 3.x stable release, though, Shawn was flooded with +Allegro tasks and Real Life (TM) work, and chose the latter to focus his +energies on. While this somehow stalled Allegro's development, it also +attracted a lot of people who wanted Allegro to live longer. Also, by that +time other people had started to work on Windows and Unix ports of Allegro, +which suggested that Allegro had the potential to survive its only decaying +main platform (DOS). + +

+The current situation is that Shawn still keeps watching Allegro's progress +from time to time, but is not involved with development any more. The +community that grew over the years when Shawn was in charge of everything has +stepped forward to continue improving Allegro. Transformed into a meritocratic +community, users keep sending bug reports to the mailing lists, developers +around the world keep sending patches to fix them, and a few carefully chosen +have write access to the CVS repository, from which releases are built every +now and then. + +

+But, who decides when a build is stable enough? Who decides when somebody is +granted write access to the CVS? Who chooses the lesser of two evils patching +some obscure bug? And more importantly, who decides what's Allegro's mascot? +For all these reasons, the community decided to replace Shawn's position with +the Allegro Dictator. + +

+In republican Rome, political power was with the Senate and the Consuls. +However, if it was nescessary that decisions were made very quickly then the +senate could appoint a Dictator. The Dictator was appointed for a specified +duration or charged with a specific task, after which he was expected to +surrender his authority back to the Senate. Nowadays, the Allegro Dictator is +a benevolent figure and rarely has to use his overwhelming fist of iron to put +order into chaos. + +

+The truth is that the Allegro Dictator is usually the person in charge of +doing releases and all that unsexy work inside the community, like pestering +users to test some obscure bugfix or rejecting incomplete patches. + +

+Past Allegro dictators have been: Shawn Hargreaves, George Foot, Peter Wang +and Eric Botcazou. At the moment of writing this, Evert Glebbeek is the +active Allegro Dictator. Should you want to change Allegro in some illogical +way, he's the guy you have to send your bribes too :-) + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg048.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg048.html new file mode 100644 index 0000000..170ed67 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg048.html @@ -0,0 +1,33 @@ + + +Allegro Manual: Conclusion + + + + +

Conclusion

+ +

+All good things must come to an end. Writing documentation is not a good +thing, though, and that means it goes on for ever. There is always something +we've forgotten to explain, or some essential detail we've left out, but for +now you will have to make do with this. Feel free to ask if you can't figure +something out. + +

+Enjoy. We hope you find some of this stuff useful. + + +


+By Shawn Hargreaves and the Allegro development team. + +

+http://alleg.sourceforge.net/ + + + +


+


Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/alleg049.html b/lib/allegro/allegro-htmldocs-4.2.1/alleg049.html new file mode 100644 index 0000000..2d402eb --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/alleg049.html @@ -0,0 +1,1160 @@ + + +Allegro Manual: Index + + + + +

Index

+ +

+

+ A + B + C + D + E + F + G + J + L + M + P + Q + R + S + T + V + 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 + +
+ +

A

+ +

B

+ +

C

+ +

D

+ +

E

+ +

F

+ +

G

+ +

J

+ +

L

+ +

M

+ +

P

+ +

Q

+ +

R

+ +

S

+ +

T

+ +

V

+ +

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

+ + + +
Back to contents
+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/allegro.css b/lib/allegro/allegro-htmldocs-4.2.1/allegro.css new file mode 100644 index 0000000..fdd2b98 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/allegro.css @@ -0,0 +1,113 @@ +A.xref:link { + color: blue; + text-decoration: none; + background: transparent; +} +A.xref:visited { + color: blue; + text-decoration: none; + background: transparent; +} +A.xref:hover { + color: blue; + text-decoration: underline; + background: rgb(220, 220, 220); +} +A.xref:active { + color: red; + text-decoration: none; + background: rgb(255, 204, 50); +} +A.eref:link { + color: blue; + text-decoration: none; + background: transparent; +} +A.eref:visited { + color: blue; + text-decoration: none; + background: transparent; +} +A.eref:hover { + color: blue; + text-decoration: underline; + background: rgb(255, 165, 214); +} +A.eref:active { + color: red; + text-decoration: none; + background: rgb(255, 204, 50); +} +A.autotype:link { + color: rgb(64, 64, 255); + text-decoration: none; + background: transparent; +} +A.autotype:visited { + color: rgb(64, 64, 255); + text-decoration: none; + background: transparent; +} +A.autotype:hover { + color: rgb(64, 64, 255); + text-decoration: underline; + background: transparent; +} +A.autotype:active { + color: red; + text-decoration: none; + background: transparent; +} +blockquote.xref { + font-family: helvetica, verdana, serif; + font-size: smaller; + border: thin solid rgb(220, 220, 220); + color: black; + background: rgb(240, 240, 240); +} +blockquote.eref { + font-family: helvetica, verdana, serif; + font-size: smaller; + border: thin solid rgb(255, 165, 214); + color: black; + background: rgb(255, 201, 230); +} +blockquote.code { + border: thin solid rgb(255, 234, 190); + color: black; + background: rgb(255, 255, 205); +} +blockquote.text { + border: thin solid rgb(190, 234, 255); + color: black; + background: rgb(225, 255, 255); +} +div.al-api { + padding-left: 0.5em; + color: black; + background: rgb(255, 234, 100); + font-weight: bold; + border-bottom: medium solid rgb(255, 204, 51); + border-left: medium solid rgb(255, 204, 51); + margin-top: 2em; +} +div.al-api-cont { + padding-left: 0.5em; + color: black; + background: rgb(255, 234, 100); + font-weight: bold; + border-bottom: medium solid rgb(255, 204, 51); + border-left: medium solid rgb(255, 204, 51); + margin-top: -1em; +} +div.faq-shift-to-right { + margin-left: 2em; +} +div.al-back-to-contents { + text-align: center; + font-family: sans-serif; + margin-top: 1em; + font-weight: bold; + /* Removing the comments of the next line create longer pages */ + /* margin-bottom: 100em; */ +} diff --git a/lib/allegro/allegro-htmldocs-4.2.1/allegro.html b/lib/allegro/allegro-htmldocs-4.2.1/allegro.html new file mode 100644 index 0000000..19769c5 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/allegro.html @@ -0,0 +1,124 @@ + + +Allegro Manual + + + + +
+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/     Version 4.2.1
+
+
+                A game programming library.
+
+             By Shawn Hargreaves, Nov 26, 2006.
+
+                See the AUTHORS file for a
+               complete list of contributors.
+
+ + + +


+#include <std_disclaimer.h> +

+ "I do not accept responsibility for any effects, adverse or otherwise, + that this code may have on you, your computer, your sanity, your dog, + and anything else that you can think of. Use it at your own risk." +
+ + +


+

Contents

+ +

+

API

Platform specifics

Miscellaneous

Tools

+ + + +


+ + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/api.html b/lib/allegro/allegro-htmldocs-4.2.1/api.html new file mode 100644 index 0000000..34af2ba --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/api.html @@ -0,0 +1,350 @@ + + +API compatibility information + + + + +

+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                API compatibility information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

Introduction

+ +

+ Once Allegro 4.0 is released, we plan to maintain backward compatibility + at the Application Programming Interface level for the subsequent stable + releases of the 4.x series, that is for the releases with an even minor + version number. For example, that means you will be able to compile your + program written for version 4.0.0 with version 4.0.23 or version 4.2.1 of + the library. However, in order to fix some minor inconsistencies of the + original 4.0 API, we may make exceptions to the rule and break strict + backward compatibility in a few cases. But this is guaranteed to never + happen in a stable series for which major and minor version numbers are + fixed; in other words, two stable versions that differ from each other + only by the revision (3rd) number will be strictly backward compatible. + +

+

Changes between 4.0.x and 4.2.x series

+ + +

+

Deprecated materials

+ +

+ The following items have been deprecated and the main documentation was + purged of any references to them. If you are still using any of those, now + might be a good time to get rid of them (within parentheses is the symbol + most likely to be a replacement for the obsolete one, if any). However + they are still supported for the sake of backwards compatibility, unless + you define the symbol ALLEGRO_NO_COMPATIBILITY prior to including Allegro + headers. + +

+

+ + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/bcc32.html b/lib/allegro/allegro-htmldocs-4.2.1/build/bcc32.html new file mode 100644 index 0000000..e9ac38e --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/bcc32.html @@ -0,0 +1,123 @@ + + +Allegro Borland C++Builder-specific information + + + + +
+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+          Borland C++Builder-specific information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

BCC32 notes

+ +

+ Status: it works. It currently doesn't build the Allegro library + from the sources, but it does let you compile your own Allegro-based + programs and run them with the Allegro DLLs. Thanks to Inprise for + creating the very useful IMPLIB program. + +

+ The screensaver example is built, but you must copy scrsave.scr to + your windows/system directory (or winnt/system32 directory + under Windows NT/2k/XP) if you want to test it. + + + +


+

Required software

+ +

+

+ In order to run your programs, you need to obtain the Allegro DLLs and + install them in the Windows system directory. + +

+ This is known to work with the Borland C++ 5.5 command line compiler. + Earlier versions may cause problems (for example v5.02). + +

+ You need to use GNU make, since Borland make is really ugly about its + makefiles. You can grab it from either the MinGW or DJGPP + distributions; more info on this in available in the following files: + docs/build/mingw32.txt and docs/build/djgpp.txt. + + + +


+

Installing Allegro

+ +

+ Set up your environment so that Borland C++ can be used from the + commandline. Then set the variable BCC32DIR to the directory where + Borland C++ is located, for example 'set BCC32DIR=c:\bcc32'. + +

+ Type "cd allegro" and then "fix.bat bcc32". Then, run "make". Find + something fun to do while it's compiling. It will eventually + finish; then just type "make install" to set the library up for use. + +

+ If you also want to install a debugging version of the library (highly + recommended), type "make install DEBUGMODE=1". Case is important, so + it must be DEBUGMODE, not debugmode! + +

+ If you also want to install a profiling version of the library, now type + "make install PROFILEMODE=1". + +

+ If your copy of Allegro doesn't include the makefile.dep dependency files + (unlikely, unless you have run "make veryclean" at some point), you can + regenerate them by running "make depend". + +

+ If your copy of Allegro doesn't include the linker .def file (unlikely, + unless you have run "make veryclean" at some point), you can regenerate + it by running "misc\fixdll.bat". + + + +


+

Using Allegro

+ +

+ All the Allegro functions, variables, and data structures are defined in + allegro.h. You should include this in your programs, and link with one of + the libraries: +

+      alleg.lib      - optimised DLL import library
+      alld.lib       - debugging DLL import library
+      allp.lib       - profiling DLL import library
+
+ Don't forget that you need to use the END_OF_MAIN() macro right after + your main() function! + +

+ You will need to distribute the appropriate DLL along with your program. + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/beos.html b/lib/allegro/allegro-htmldocs-4.2.1/build/beos.html new file mode 100644 index 0000000..8dcbbf9 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/beos.html @@ -0,0 +1,146 @@ + + +Allegro BeOS-specific information + + + + +

+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                 BeOS-specific information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

BeOS notes

+ +

+ Status: It compiles for Intel R4 & R5. Port is complete. + + + +


+

Required software

+ +

+ BeOS Intel R4 and R5 Pro Edition come with everything you need. If you + have BeOS Intel R5 Personal Edition, you require the development tools; + these can be found on the Be homepage at http://www.be.com. You also need + updated binutils, which can be found at http://bebits.com. It might not + be a bad idea to update gcc as well, but is not required. + + + +


+

Installing Allegro

+ +

+ Allegro comes as a source distribuition: you'll have to compile it to get + it to work. Unzip the library archive wherever you want, and cd into that + directory with a Terminal. Due to the multi-platform nature of Allegro, + you need to run: +

+      fix.sh beos
+
+ This will set the library ready to be compiled on the Be platform. + Now you must build it: +
+      make
+
+ And then install it: +
+      make install
+
+ With this last command the Allegro library will be installed into + /boot/home/config/lib (the default location for BeOS shared libraries), + while the headers will go into /boot/develop/headers (the default + locations where Be looks for them). + +

+ You have now installed Allegro! See the rest of the documentation and + examples to learn more about it. A simple example of a command line to + compile an allegro program: +

+      gcc foo.c -O2 -Wall -o foo `allegro-config --shared`
+
+ The `allegro-config --shared` is explained in the next section. + +

+ The dynamically linked version of Allegro gets built by default but if + you want to build the statically linked version of Allegro write the + following on the command line: +

+      export STATICLINK=1
+
+ In the same manner we can also enter one of the following lines to + build either the debug or the profiling version of the library: +
+      export DEBUGMODE=1
+      export PROFILEMODE=1
+
+ Then we can start to actually make and install the Allegro library. +
+      make
+      make install
+
+ If you have compiled a static version of the library, it will be copied to + /boot/develop/lib/x86. + + + +


+

Using Allegro

+ +

+ Linking Allegro to a program also requires you to link several other BeOS + libraries and set the correct library search pathes. To simplify the + linking process, the installation sets up a script, allegro-config, that + will print out a suitable commandline. You can use this inside backtick + command substitution, for example: +

+      gcc myfile.c -o myprogram `allegro-config --static`
+
+ This will enable you to link against the static library. + +

+ The `allegro-config --shared` option mentioned above will output all the + options and libraries needed to link dynamically against the shared + version of the Allegro library. If you use --libs instead of --shared or + --static, the script will generate the linking arguments according to the + latest installed library version. You can also run these allegro-config + commands on the commandline to see what exactly they do. + +

+ If you want to build a debug version of your program, assuming that + you have installed the debug version of Allegro, use: +

+      gcc myfile.c -o myprogram `allegro-config --libs debug`
+
+ Terminal newbies, take note that these are ` backticks, not normal ' + quotes! + +

+ There are also other switches for printing out the Allegro version number, + or to override the install paths. Run allegro-config without any + arguments for a full list of options. + +

+ Don't forget that you need to use the END_OF_MAIN() macro right after + your main() function! + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/darwin.html b/lib/allegro/allegro-htmldocs-4.2.1/build/darwin.html new file mode 100644 index 0000000..7224846 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/darwin.html @@ -0,0 +1,143 @@ + + +Notes on building the Darwin/X11 version of Allegro + + + + +

+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+   Notes on building the Darwin/X11 version of Allegro.
+
+   Written by Jeremiah Blanchard.
+
+   See docs/build/unix.txt for general Unix information.
+
+   See readme.txt for a more general overview.
+
+ + + +


+

Darwin Notes

+ +

+ This file explains how to build the X Window port of Allegro on a Darwin + system. + +

+ If you are running MacOS X, you are strongly encouraged to use the MacOS + X native port; read docs/build/macosx.txt for more info. + +

+ It is important to note that there is no sound because the sound drivers + have not yet been ported. + +

+ This library cannot yet be compiled as a shared library, only static. + + +


+

Required software

+ +

+ If you are running MacOS X, you must download the developer tools. This + requires free registration with Apple. You can register and download the + tools at: +

+

+ http://connect.apple.com +

+

+ Recently, GCC 3.1 has been released which supports the Mach-O binary + format, and you may be able to use it directly (if you compile it + yourself or find a binary distribution.) + +

+ You will also need X Window. You can use either the Darwin/MacOS X port + of XFree86 from the XonX project or Xtools, a proprietary version. The + XonX project is located at: +

+

+ http://sourceforge.net/projects/xonx +

+ + +


+

Installing Allegro

+ +

+ First, decompress the .tar or .zip file into some directory. Next, open + up a terminal (in MacOS X, this can be found in Applications/Utilities). + From here, enter the directory into which Allegro has been decompressed. + +

+ If you are using the .zip file, type the following: +

+      chmod +x fix.sh
+      ./fix.sh unix
+
+ From here on everything is a pretty standard Unix-style install process. + First you configure it with at least the following options: +
+      ./configure --enable-static --disable-shared --disable-pthreads
+
+ It should automatically build dependencies. + +

+ Then you build it: +

+      make
+
+ If you are using an older version of Apple's tools, you will probably see + lots of preprocessing errors. Just ignore them (they are due to Apple's + modifications to GCC and do not affect the resulting object code). + +

+ To install Allegro, you will need root permissions. If you don't have + root permissions set up on your system (in MacOS X, for example), you + will first need to activate the root account. This can be done by running + the program "NetInfo Manager" in Applications/Utilites. From within the + program, go to the "Domain" menu, select "Security" and "Authenticate". + Type in your password and go to "Domain", "Security", "Root User Enable". + I strongly urge you to set your root password in the same menu. + +

+ Now, type the following in the terminal: +

+      su -c "make install"
+
+ To install the man pages, type: +
+      su -c "make install-man"
+
+ If prompted for a password, type in your root password. + + + +


+

Using Allegro

+ +

+ When compiling a program using Allegro, you will have to link to the + following libraries: +

+      -lalleg -lX11 -lXext
+
+ If you are using the XFree86 port, you will also have to add: +
+      -lXxf86vm
+
+ + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/djgpp.html b/lib/allegro/allegro-htmldocs-4.2.1/build/djgpp.html new file mode 100644 index 0000000..d93618f --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/djgpp.html @@ -0,0 +1,325 @@ + + +Allegro DJGPP-specific information + + + + +
+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                DJGPP-specific information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

djgpp notes

+ +

+ Status: complete. This is the original Allegro version, and has had + plenty of time to become nice and stable. However, under Windows NT, + 2000, or XP you will very likely experience problems and should consider + using the native Windows version of Allegro instead, less likely to give + you problems under such environments. + + + +


+

Required software

+ +

+

+ All of the above can be downloaded from your nearest SimTel mirror site, + in the /pub/simtelnet/gnu/djgpp/ directory, or you can use the zip picker + on http://www.delorie.com/djgpp/. Please make sure that you have + installed djgpp according to the instructions in readme.1st, and that you + aren't mixing it with any files from different compilers (eg. the Borland + version of make). + + + +


+

Allegro CVS Notes

+ +

+ If you are using a CVS version of Allegro, then you will need to do some + extra things to ensure that your copy of Allegro will compile correctly. + These are covered in detail below, but briefly: +

+

+ 1. You must run the `fix' script (either the batch file, under + command.com, or the .sh file under bash). You must supply the + argument `djgpp'. + +

+ 2. You must regenerate the dependency files: a simple `make depend' + will do this. However, please note that you must have sed installed + to do this. +

+ + +


+

Installing Allegro

+ +

+ This is a source-only distribution, so you will have to compile Allegro + before you can use it. To do this you should: + +

+ Go to wherever you want to put your copy of Allegro (your main djgpp + directory would be fine, but you can put it somewhere else if you + prefer), and unzip everything. Allegro contains several subdirectories, + so you must specify the -d flag if you are using pkunzip. + +

+ If you are running under Linux, and want to cross-compile the djgpp + version of Allegro, set the environment variable "CROSSCOMPILE=1", set + DJDIR to the directory where your djgpp cross-compiler is installed, + set PATH to access to the cross-compiler, and set NATIVEPATH to a path + that will use your native version of gcc instead (_not_ the djgpp + cross-compiler!) so that this can be invoked when converting the + documentation. You might like to edit and use `xmake.sh'; there are + further instructions in comments in the file. You must also run + 'fix.sh djgpp' as detailed above - it is required to properly configure + Allegro for building with djgpp. + +

+ Type "cd allegro", followed by "make". Then go do something interesting + while everything compiles. When it finishes compiling, type "make + install" to set the library up ready for use. If you have any trouble + with the build, look at docs/txt/faq.txt for the solutions to some of the + more common problems. + +

+ If you also want to install a debugging version of the library (highly + recommended), now type "make install DEBUGMODE=1". Case is important, so + it must be DEBUGMODE, not debugmode! + +

+ If you also want to install a profiling version of the library, now type + "make install PROFILEMODE=1". + +

+ If you want to read the Allegro documentation with the Rhide online help + system, go to the "Help / Syntax help / Files to search" menu, and add + "allegro" after the existing "libc" entry (separated by a space). + +

+ If you want to create the HTML documentation as one large allegro.html + file rather than splitting it into sections, edit docs/allegro._tx, + remove the @multiplefiles statement from line 8, and run make again. + +

+ Once the build is finished you can recover some disk space by running + "make compress" (which uses the DJP or UPX programs to compress the + executable files), and/or "make clean" (to get rid of all the temporary + files and HTML format documentation). + +

+ If your copy of Allegro is set up for use with some different compiler + (if you downloaded a tar.gz archive or a CVS version), you will have to + run 'fix.bat djgpp' before compiling it. If you are using bash you can run + 'fix.sh djgpp' instead. + +

+ If your copy of Allegro doesn't include the makefile.dep dependency files + (if you have run "make veryclean" or you have the CVS version), you can + regenerate them by running "make depend". + +

+ If `make' tells you that you need to download a new package, or if you + need the `sed' package to generate dependencies, you can find these at + ftp://ftp.demon.co.uk/pub/mirrors/simtelnet/gnu/djgpp/. + +

+ A list of all the available options: +

+

+

CROSSCOMPILE
+ Set this if you are crosscompiling; it implies UNIX_TOOLS.
+ +

+

WARNMODE
+ Set this if you want Allegro to display and stop on nearly all + warnings issued by the compiler. Allegro should compile fine with + this set.
+ +

+

TARGET_ARCH_COMPAT + or + TARGET_ARCH_EXCL
+ These affect the level of processor dependant optimisation that + Allegro uses. You can set either of these to the processor type you + want to optimize for. The difference between these two is that + TARGET_ARCH_COMPAT optimise for the given processor so that the code + will still run on older processors, while TARGET_ARCH_EXCL will + generate code that will run exclusively on the given processor and of + course newer ones. Example: set TARGET_ARCH_COMPAT=i686
+ +

+

TARGET_OPTS
+ Affects the general optimisations that Allegro uses.
+ +

+

UNIX_TOOLS
+ If your system does not have the usual DOS tools available (`md', + `rd', `copy', etc., and commands which understand the \ character), + then set this to 1 to use the Unix equivalents. This is set + implicitly when you set CROSSCOMPILE, and is also set automatically + when you are running under bash.
+
+

+ To activate any of these, type (for example) "make WARNMODE=1". + + + +


+

Using Allegro

+ +

+ All the Allegro functions, variables, and data structures are defined in + allegro.h. You should include this in your programs, and link with either + the optimised library liballeg.a, the debugging library liballd.a, or the + profiling library liballp.a. To do this you should: + +

+ Put the following line at the beginning of all C or C++ files that use + Allegro: +

+      #include <allegro.h>
+
+ If you compile from the command line or with a makefile, add either + '-lalleg' (for the optimised version), '-lalld' (debugging version), or + '-lallp' (profiling version) to the end of the gcc command, eg: +
+      gcc foo.c -o foo.exe -lalleg
+
+ If you are using Rhide, go to the Options/Libraries menu, type either + 'alleg' (for the optimised version), 'alld' (debugging version), or + 'allp' (profiling version) into the first empty space, and make sure the + box next to it is checked. + + + +


+

Supported hardware

+ +

+ The bare minimum you need to use Allegro is a 386 with a VGA graphics + card, but a 486 is strongly recommended. To get into SVGA modes you will + need a compatible SVGA card, which means something that has a working + VESA or VBE/AF driver. + +

+ Ideally you should use VBE/AF, because it allows Allegro to use hardware + acceleration functions to speed up the drawing. The FreeBE/AF project + (http://www.talula.demon.co.uk/freebe/) provides a number of free VBE/AF + drivers (volunteers to write more are always welcome!), and accelerated + drivers for a large number of cards are available commercially as part of + the SciTech Display Doctor package (http://www.scitechsoft.com/). + +

+ If you have a VBE 2.0 or VBE 3.0 driver you are probably fine just using + that, although unlike VBE/AF it won't provide any hardware acceleration. + If you have an older VESA BIOS implementation (eg. VESA 1.2), beware. For + one thing, everything will be much slower if Allegro can't use the sexy + VBE 2.0 features. For another, I could go on all day telling horror + stories about the buggy and generally just pathetic VESA implementations + that I've come across. If you are having trouble with the SVGA modes, try + getting a copy of the SciTech Display Doctor and see if that clears + things up (it probably will: SciTech usually get these things right). + +

+ Note that the native SVGA chipset drivers from Allegro 3.0 and earlier + have been removed. These are still available as an optional add-on + package from the same sites as Allegro, but are not needed any more + because you can get the same code in a more flexible format as part of + the FreeBE/AF project. + +

+ On the sound front, Allegro supports sample playback on the SB (mono), + the SB Pro (stereo), the SB16, the ESS AudioDrive, the Ensoniq + Soundscape, and the Windows Sound System. It has MIDI drivers for the + OPL2 FM synth (Adlib and SB cards), the OPL3 (Adlib Gold, SB Pro-II and + above), the pair of OPL2 chips found in the SB Pro-I, the AWE32 EMU8000 + chip, the raw SB MIDI output, and the MPU-401 interface, plus it can + emulate a wavetable MIDI synth in software, running on top of any of the + supported digital soundcards. The Creative Labs SB PCI-64 and PCI-128 + cards are actually based on the Ensoniq chipset, so they can be used with + the Soundscape and MPU-401 drivers. You'll have to manually select the + MPU, though, because it won't be autodetected. Actually, quite a lot of + wavetable boards emulate the MPU, so give this a try and see if it works + on your card. If you feel like coming up with drivers for any other + hardware, they would be much appreciated. + +

+ Audio recording is supported for all SB cards, but only in unidirectional + mode, ie. you cannot simultaneously record and playback samples. MIDI + input is provided by the MPU-401 and SB MIDI drivers, but there are some + restrictions on this. The SB MIDI interface cannot be used at the same + time as the digital sound system, and the MPU will only work when there + is an IRQ free for it to use (this will be true if you have an SB16 or + greater, or if no SB-type digital driver is installed, or if your MIDI + interface uses a different IRQ to the SB). + + + +


+

Notes for the musician

+ +

+ The OPL2 synth chip can provide either nine voice polyphony or six voices + plus five drum channels. How to make music sound good on the OPL2 is left + as an exercise for the reader :-) On an SB Pro or above you will have + eighteen voices, or fifteen plus drums. Allegro decides whether to use + drum mode individually for each MIDI file you play, based on whether it + contains any drum sounds or not. If you have an orchestral piece with + just the odd cymbal crash, you might be better removing the drums + altogether as that will let Allegro use the non-drum mode and give you an + extra three notes polyphony. + +

+ When Allegro is playing a MIDI file in looped mode, it jumps back to the + start of the file when it reaches the end of the piece. To control the + exact loop point, you may need to insert a dummy marker event such as a + controller message on an unused channel. + +

+ All the OPL chips have very limited stereo capabilities. On an OPL2, + everything is of course played in mono. On the SB Pro-I, sounds can only + be panned hard left or right. With the OPL3 chip in the SB Pro-II and + above, they can be panned left, right, or centre. I could use two voices + per note to provide more flexible panning, but that would reduce the + available polyphony and I don't want to do that. So don't try to move + sounds around the stereo image with streams of pan controller messages, + because they will jerk horribly. It is also worth thinking out the + panning of each channel so that the music will sound ok on both SB Pro-I + and OPL3 cards. If you want a sound panned left or right, use a pan value + less than 48 or greater than 80. If you want it centred, use a pan value + between 48 and 80, but put it slightly to one side of the exactly central + 64 to control which speaker will be used if the central panning isn't + possible. + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/linux.html b/lib/allegro/allegro-htmldocs-4.2.1/build/linux.html new file mode 100644 index 0000000..de3bf3e --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/linux.html @@ -0,0 +1,204 @@ + + +Allegro Linux-specific information + + + + +

+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                 Linux-specific information.
+
+         See readme.txt for a more general overview.
+
+   Also see docs/build/unix.txt for general Unix information.
+
+ + + +


+

General notes

+ +

+ On Linux you have two different system drivers -- one for running using + X, and one for running without X. For information on the X version, and + instructions telling how to install Allegro and compile your programs on + a Unix system, see docs/build/unix.txt. This file only describes the + Linux console routines. + +

+ Normally the X version is used in preference to the console version, if + an X server is contactable (this means that your programs will use X if + you launch them from inside X, and otherwise use the console). You can + change this using your config file if you like, or by configuring + --without-x. + + + +


+

Installing Allegro

+ +

+ See docs/build/unix.txt: this process is identical for the console and X + versions. + + + +


+

Using Allegro

+ +

+ Some parts of Linux console Allegro need root privileges. Others don't. + Specifically, the VGA, mode-X and VBE/AF graphics drivers do. The fbcon + driver doesn't. Also, if you intend to run a program from something which + isn't a VT (e.g. an xterm (but not using the X version), a remote login, + a screen session) then you need to either own a (free) console numbered + from 1 to 15 or to have root privileges. + +

+ If you want a program to run with privileges even though the user running + it is not root, make root own the binary and set the suid bit: +

+      # chown root.allegro exhello
+      # chmod 4770 exhello
+
+ That makes the executable be owned by root and group `allegro'. It's + readable, writable and executable by root and people in that group. Also, + when it runs, it has root privileges. For that reason, it's not + executable by the general public. Put trusted users into group `allegro'. + +

+ You might prefer to use `4750' instead of `4770' -- then people in the + group cannot write to the binary. + +

+ Allegro will drop the privileges almost immediately after initialisation, + using `seteuid'. This means that you can still get the permissions back + later on. Allegro needs to be able to regain the privileges if you intend + to call `allegro_init' again in the future. If this isn't the case, you + can completely give up the privileges using `setuid(getuid());' -- then + they are lost for good. + +

+ Security note: If you don't do this, any buffer overflows are a severe + security problem. In any case, you should take great care when allowing + random people to execute third-party programs suid root. + +

+ If, as root, you run `make suid', it will do this to all of the programs + generated -- the demo game, the examples, the tests, etc. + + + +


+

Notes on drivers

+ +

+ This section contains Linux-specific notes on the drivers available. +

+

+

System:
+ On initialisation, Allegro will try to get a certain amount of + control over the console. This doesn't generally require root + privileges, but if the program isn't being run from a plain VC (e.g. + it's running from within X or screen), Allegro must try to allocate + a spare VC and move the program to it. This requires a free console + we can read from and write to; unless the user has allocated some, + we need to be root here. + +

+ Display switching is possible; all of Allegro's modes are supported. + The default is SWITCH_PAUSE. SWITCH_BACKGROUND will only work if the + application takes special precautions.

+ +

+

Graphics:
+ Linux Allegro supports standard VGA and mode-X by direct writes to + the video card. You need root privileges for this to work. + +

+ It also supports fbcon, for which you do not need privileges, but + you do need a recent kernel, correctly configured. + +

+ The VBE/AF system does require root privileges. Note it is not built by + default and hasn't been tested in a long time. Basically, you should + not bother with it. But if you insist, you need to get a VBE/AF driver + that works in Linux -- the FreeBE/AF project has two at present, but + the project itself hasn't been ported to Linux. You can just copy out + the driver binaries, though. Put the appropriate driver into + `/usr/local/lib', `/usr/lib', `/lib' or + `/', filename `vbeaf.drv' -- or put it anywhere you + like, specifying the location in the config file as for the DOS + version. + +

+ For security reasons, the VBE/AF driver binary must be owned by root + and only writable by root. You really don't want to load and execute + user-specified binary code in a privileged program. + +

+ The SVGAlib driver should be fairly stable and fast now, and can use + most of the video modes that SVGAlib provides. It requires root + privileges if your version of SVGAlib requires them.

+ +

+

Sound:
+ The ALSA drivers support both the older 0.5.x version of the ALSA API + as well as the newer 0.9.x+ series. Support for the older API will be + dropped later.
+ +

+

Keyboard:
+ The keyboard driver uses the kernel mapping tables to map scancodes + to character codes and key functions, so your keyboard mapping + should be fine without special configuration in the setup program.
+ +

+

Joystick:
+ To compile Allegro with joystick support you must have a 2.2.* or newer + kernel, i.e. with kernel-based joystick support. Look for + /usr/src/linux/include/linux/joystick.h. You shouldn't have to + actually configure the kernel with joystick support though, you just + need that header file. + +

+ Similarly, to run Allegro programs with joystick support you must have + configured joystick support into the kernel. You also need to create + the device file /dev/input/js0, if it's not already there. + +

+ See /usr/src/linux/Documentation/joystick.txt for details.

+ +

+

Mouse:
+ Currently Linux Allegro supports PS/2 and Microsoft mice directly, + and other mouse types via GPM. To use GPM you must turn on its + `repeater' feature, where it copies all mouse activity to the FIFO + /dev/gpmdata. Edit your init scripts and add the `-R' option. The + GPM driver can also be used with native Mouse Systems mice by + changing the `mouse_device' variable in the config file. + +

+ When using the PS/2 Intellimouse protocol, it is necessary to + explicitly put the mouse into wheel mode, which requires Allegro + to have write permissions to the device. + +

+ There is now also a input events-based driver which reads events from + /dev/input/eventN.

+
+ + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/macosx.html b/lib/allegro/allegro-htmldocs-4.2.1/build/macosx.html new file mode 100644 index 0000000..218a7d4 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/macosx.html @@ -0,0 +1,390 @@ + + +Allegro MacOS X-specific information + + + + +
+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                MacOS X-specific information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

MacOS X notes

+ +

+ This is a full featured native MacOS X port. The whole codebase is young, + so it may hold some bugs; feedback is welcome! + + + +


+

Required software

+ +

+ To build Allegro under MacOS X, you need: + +

+

+ +

+ If you don't have the Developer Tools installed, you can get the + latest release at: +

+

+ http://developer.apple.com/tools/download +

+

+ On the same page you will also find instructions on how to install them. + Note that system version 10.2.x is required to compile Allegro, but + the library will still work on 10.1.x. + + + +


+

Installing Allegro

+ +

+ Allegro ships in source code form; this means you need to compile it + before you can use it. You do this easily from a terminal window. + Due to the multiplatform nature of the library, the first step is to + fix it so it can be built under MacOS X, by running: +

+      chmod +x fix.sh
+      ./fix.sh macosx
+
+ If you have checked out a development version from Allegro's CVS + repository, run the following command. Otherwise, skip this step: +
+      make depend
+
+ Now Allegro is ready to be compiled. Start building it: +
+      make
+
+ And finally you install it (you need the root password for this step): +
+      sudo make install
+
+ Allegro has now been installed in your system as a standalone shared + library, in /usr/local/lib. + You may also wish to install the man pages: +
+      sudo make install-man
+
+ Alternatively, you can view the documentation in the Mac Help Center: +
+      sudo make install-applehelp
+
+ You may also wish to install the library as a standard MacOS X framework: +
+      sudo make install-framework
+
+ The "Allegro" framework will be created into /Library/Frameworks. Note + that the framework is standalone: it contains its own copy of the + dynamic library, so it can be safely copied around. + If you plan to embed the Allegro framework inside your application + bundles, you must install a special embeddable version of it: +
+      sudo make install-framework EMBED=1
+
+ Embedding the framework into your application bundles ensures they will + work also on machines where Allegro is not installed. Note that if you + embed the non-embeddable version of the framework into your app bundle, + your program will not be able to load it and it will not work. + Finally, if you plan on using Project Builder to code your apps, you + may find useful installing an Allegro application PB project template: +
+      sudo make install-template
+
+ The dynamically linked version of the library gets built by default, but + if you want to build a statically linked one, write the following on the + command line: +
+      export STATICLINK=1
+
+ In the same manner we can also enter one of the following lines to + build either the debug or the profiling version of the library: +
+      export DEBUGMODE=1
+      export PROFILEMODE=1
+
+ Then restart the build process by issuing: +
+      make
+      sudo make install
+
+ The static library will be installed in /usr/local/lib as the shared one, + but you will not be able to install the framework nor the Project Builder + template, which require a dynamically linked Allegro version. + +

+ If you have OS X 10.4 and you want to build a Universal Binary version of the library + (i.e. one that will run on both PowerPC and Intel Macs) you can type +

+      ./fix.sh macosx-universal
+
+ instead of the fix.sh line given above. Note that you'll still need to specify + the appropriate flags when you link your program, otherwise gcc will 'thin' the binary + so it only includes the native code. + +

+ For more information see + http://developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/ + + +


+

Using Allegro from the command line

+ +

+ The options for linking with Allegro are quite long, expecially for + static versions of the library as you need to pull in several different + frameworks (Cocoa, QuickTime, etc.) other than Allegro itself. When + linking against the shared library version, things are also different. + To avoid you having to work out the right linker commands for yourself, + the installation creates a script, allegro-config, that will print out a + suitable commandline. You can use this inside a backtick command + substitution, for example: +

+      gcc myfile.c -o myprogram `allegro-config --libs`
+
+ Or if you want to build a debug version of your program, assuming that + you have installed the debug version of Allegro: +
+      gcc myfile.c -o myprogram `allegro-config --libs debug`
+
+ You can also link against the Allegro framework, providing you previously + installed it via make install-framework: +
+      gcc myfile.c -o myprogram `allegro-config --frameworks`
+
+ Unix newbies, take note that these are ` backticks, not normal ' quotes! + +

+ There are also switches for printing out the Allegro version number, + overriding the install paths, and selecting between shared and static + libraries, in case you installed both. Run allegro-config without any + arguments for a full list of options. + +

+ If you get an error like 'allegro-config: program not found', and + you're sure you have built and installed the library as described above, it + probably means that /usr/local/bin is not on your path. The method + to add it depends on the shell you're using. If you have tcsh, add the + following line to the end of the .cshrc in your home directory. +

+     set path=($path /usr/local/bin)
+
+ If you have bash, add the following line to the end of the .bash_profile + file in your home directory: +
+     PATH=${PATH}:/usr/local/bin
+
+ If you don't know which, just type echo $SHELL on the command + line, which will print either /bin/bash or /bin/tcsh. + Newer versions of OSX use bash, older ones use tcsh. + You will have to close the Terminal window and open a new one once + you have made the changes, so it will have an effect. + +

+

Using Allegro from Project Builder (or XCode)

+ +

+ To use Allegro from inside Apple's Project Builder, be sure you first + installed the library as a framework and that you also installed the PB + application template (see section "Installing Allegro" for details). + +

+ Once you're ready, start up Project Builder and choose "New Project" + from the "File" menu. On the very first dialog, you'll be prompted + with a list of project templates with which to create your program. + Select "Allegro Application" under the "Application" category and enter + the project name and location in the next dialog. Once the setup is + complete, you will find yourself with an opened Allegro application + project, holding an unique source file (main.c) and some linked + frameworks. The project can already be compiled to a working application; + try it! + +

+ Note that the same procedure applies to XCode, which is compatible + with Project Builder. + +

+ The main.c source file contains a very simple skeleton of an Allegro + program that will open up a white window with the text "Hello, world!" + in the center. This file is just a start: you can (and should) completely + replace its contents to suit your needs. + + + +


+

Allegro and application bundles

+ +

+ When you build applications from the command line, you're actually just + creating the executable, so you can run it from the command line only, + and not also from the finder like a common MacOS X application. In other + words, compiling from the command line does not create application + bundles. + +

+ Allegro ships with a little tool, named fixbundle, which allows to build + an application bundle out of an executable. + The utility works from the command line and it accepts a variety of + options to customize your bundle; the easiest way to use it is: +

+      fixbundle executable_name
+
+ This will create an application bundle named "executable_name.app" that + contains your program executable and will appear in the finder with the + default application icon. A more complex usage example follows: +
+      fixbundle executable_name -m -o bundle_name -v "1.2" icon.bmp
+
+ This creates a bundle named "bundle_name.app". The executable will be + moved instead of copied into the bundle; the application will be marked + as version "1.2" and icon.bmp will be converted to an icon for the + bundle. You can specify more options and up to 4 differently sized + icons (16x16, 32x32, 48x48 and 128x128) to be read from any Allegro + supported image files or from datafile objects. + Run fixbundle without arguments for the full list of known options. + +

+ A special note is required for the "-e" switch; this lets you embed + the Allegro framework inside the built application bundle, so your + app will not require Allegro to be installed into the target machine + in order to work. This flag assumes you previously installed the + embeddable version of the Allegro framework, and that your executable + has been linked to it, either via Project Builder or XCode, either + via the allegro-config script. + If one of these conditions is not met, the created app may not + work on target machines. + +

+ Bundles created by fixbundle have this default layout: +

+      bundle.app --- Contents --+--- MacOS --- executable
+                                |
+                                +--- Resources --+--- (bundle.icns)
+                                |                |
+                                |                +--- (executable/...)
+                                |
+                                |
+                                +--- (Frameworks) --- (Allegro.framework/...)
+                                |
+                                +--- Info.plist
+                                |
+                                +--- PkgInfo
+
+ If you are using Project Builder to compile your programs, there is no + need to use fixbundle, as the IDE will do the work of generating an + application bundle for you. + +

+ When an Allegro program starts, it automatically detects if the + executable lives inside a bundle or not. The working directory is + always set up to be the directory where the standalone executable + or application bundle is located, but there is an exception: if the + application is a bundle and Allegro finds a directory under the bundle + Contents/Resources path with the same name of the executable (note that + here we mean the real executable name, not the bundle name), that + directory is set to be the working one. This allows to easily package + all the application data inside the bundle, and still have a working + program without the need to tell your code about the changed location + of your files. + + + +


+

Notes on drivers

+ +

+ This section contains MacOS X-specific notes on the drivers available. +

+

+

System:
+ When the system driver is about to be initialized, we already + have a working NSApplication object connected to the Window Server. + At driver startup, the working directory is changed if inside a + bundle with a proper data directory under the Contents/Resources + path (see above). + +

+ Display switching is possible, but only the SWITCH_BACKGROUND + mode is supported, so your application will have to deal with it.

+ +

+

Graphics:
+ The MacOS X windowed graphics mode uses a Cocoa window with a + Quartz QuickDraw view as its content view. All combinations of + window/desktop color depths are supported; if needed, color + conversion will automatically be done transparently to the user. + +

+ Fullscreen mode uses the CoreGraphics DirectDisplay API; only + 8, 15 and 32 bit color depths are supported.

+ +

+

Sound:
+ The CoreAudio digital/MIDI drivers use V2 AudioUnits, and thus + they require MacOS X 10.2.x (Jaguar) or newer to work. If this is + not the case, you can fall back to the Carbon Sound Manager and + Quicktime MIDI drivers.
+ +

+

Keyboard:
+ MacOS X Allegro uses the current system keyboard mapping table + to map scancodes to characters: the keyboard user settings in + allegro.cfg have no effect.
+ +

+

Mouse:
+ On MacOS X 10.2.x (Jaguar) or newer, Allegro will automatically + detect the number of buttons of your mouse at driver initialization. + If the 1-button Apple mouse is found, the library will activate an + emulation mode that mimics the way MacOS X itself deals with + 1-button mice: depending on which key is pressed when the button is + clicked, Allegro will report a different mouse button click. + (Control + button) emulates a right click and (Option + button) + emulates a middle click. + +

+ On MacOS X 10.1.x, mouse autodetection is not possible, and Allegro + will assume an 1-button mouse to always be present, activating + buttons emulation accordingly.

+
+ + +


+

Final notes

+ +

+ There is a known compatibility problem when using gcc 4 on MacOS X 10.4 + that prevents binaries from working on older versions of MacOS X. While it + is anticipated that a future update from Apple will fix this problem, you + can use gcc 3 to work around it. + +

+ As a final note, when coding Allegro programs don't forget that you + need to use the END_OF_MAIN() macro right after your main() function! + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/mingw32.html b/lib/allegro/allegro-htmldocs-4.2.1/build/mingw32.html new file mode 100644 index 0000000..70bea15 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/mingw32.html @@ -0,0 +1,528 @@ + + +Notes on building the MinGW/Cygwin version of Allegro. + + + + +

+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+   Notes on building the MinGW/Cygwin version of Allegro.
+
+   Written by Henrik Stokseth.
+
+   Robert J Ohannessian added some updates to the installation instructions
+   and an example on how to use Dev-C++ with Allegro.
+
+   Elias Pschernig and Hein Zelle revamped the cross-compilation section.
+
+   Andrei Ellman updated the Cygwin section.
+
+   Michal Molhanec simplified the Dev-C++ instructions.
+
+   See readme.txt for a more general overview.
+
+ + + +


+

MinGW notes

+ +

+ This is a complete MinGW port of Allegro. This build doesn't rely + on the DLL files produced by MSVC any longer but can make them itself. + I'm proud to say Allegro can now make Win32 programs entirely using + free professional tools. On that note I'd like to thank Peter Puck for + making this a reality and for finishing off what I started. Enjoy! + +

+ The screensaver example is built, but you must copy scrsave.scr to + your windows/system directory (or winnt/system32 directory + under Windows NT/2k/XP) if you want to test it. + +

+ If you have both GNU bash and GNU fileutils installed on your system, then + set the environment variable UNIX_TOOLS (set UNIX_TOOLS=1). This is needed + because GNU make will automatically use sh.exe instead of command.com if + it finds it somewhere in the PATH. This step is not necessary when using + MSYS or Cygwin as the makefile automatically sets UNIX_TOOLS for you. + +

+ "make depend" and "fixdll.bat" require that you have GNU sed installed. + "fixdll.bat" requires that you have GNU sort (not DOS sort!) installed. + You can download some extra utilities for MinGW from: + 'http://sourceforge.net/projects/gnuwin32/' + + + +


+

Obtaining and installing the compiler & tools

+ +

+ You have four choices when it comes to installing MinGW and Allegro + on your computer: +

+ Note: You will need a program to decompress .zip, .tar.gz and optionally + .tar.bz2 files. I recommend PowerArchiver (shareware) which can be + downloaded from: 'http://www.powerarchiver.com'. + + + +


+

Setting up MinGW to build Allegro

+ +

+ The procedure is as follows: +

+

+ 1. Make sure you have a working MinGW installation. You can download the + complete distribution or individual packages from 'http://www.mingw.org' + or 'http://sourceforge.net/projects/mingw/'. You can also use + the Minimal SYStem (MSYS) environment with Allegro. + +

+ 2. Get the minimal DirectX 7 SDK for MinGW (dx70_mgw.zip). You + download it from 'http://alleg.sourceforge.net/wip.html'. Note + that this is *not* the same package as 'dx70_min.zip'. Unzip it + to the compiler directory, overwriting any existing files. + +

+ 3. Set the environment variable MINGDIR to the compiler directory. If you + use Windows 9x, you can add the line +

+         set MINGDIR=c:\MinGW
+
+ to your 'c:\autoexec.bat' file, assuming 'c:\MinGW' is the compiler + directory, and reboot. If you use Windows ME, you can run 'msconfig', + select the 'Environment' tab and then add MINGDIR. If you use + Windows NT/2k/XP, you can open the Control Panel, click the 'System' + applet, the 'Advanced' tab and finally the 'Environment' button, and + then add MINGDIR. If you use MSYS, add instead the line +
+         export MINGDIR=/mingw
+
+ to your 'c:\msys\etc\profile' file. +
+

+ Test the installation by typing the following on the command line: + 'gcc -v'. The answer should be similar to: +

+      Reading specs from ../lib/gcc-lib/mingw32/3.2/specs
+      Configured with: ../gcc/configure --with-gcc --with-gnu-ld
+      --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw
+      --enable-threads --disable-nls --enable-languages=f77,c++,objc,ada
+      --disable-win32-registry --disable-shared
+      Thread model: win32
+      gcc version 3.2 (mingw special 20020817-1)
+
+ If you don't know how to open a terminal, you can click on 'Start -> Run' + then type "command". Under Windows 2k/XP, you should type "cmd" instead. + + + +


+

Setting up Dev-C++ to build Allegro

+ +

+ Note: we assume that the complete version of the Dev-C++ environment (i.e + with the bundled MinGW compiler) is used. If you use instead Dev-C++ as + a mere IDE on top of an already installed MinGW compiler, follow the + instructions given in the previous section. + +

+ The procedure is as follows: +

+

+ 1. Make sure you have a working Dev-C++ installation. You can download the + complete version from 'http://bloodshed.net/dev/devcpp.html'. + +

+ 2. Get the DirectX SDK: go to Tools\Check for Updates/Packages... and + install the DirectX package. Close Dev-C++. + +

+ 3. Add 'c:\DevCpp\bin' to the beginning of your PATH environment variable + and set the environment variable MINGDIR to 'c:\DevCpp'. If you use + Windows 9x, you can add the lines +

+         PATH=c:\DevCpp\bin;%PATH%
+         set MINGDIR=c:\DevCpp
+
+ to your 'c:\autoexec.bat' file and reboot. If you use Windows ME, you + can run 'msconfig', select the 'Environment' tab, then modify PATH and + add MINGDIR. If you use Windows NT/2k/XP, you can open the Control + Panel, click the 'System' applet, the 'Advanced' tab and finally the + 'Environment' button, then modify PATH and add MINGDIR. + +
+


+ Test the installation by typing the following on the command line: + 'gcc -v'. The answer should be similar to: +

+      Reading specs from ../lib/gcc-lib/mingw32/3.2/specs
+      Configured with: ../gcc/configure --with-gcc --with-gnu-ld
+      --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw
+      --enable-threads --disable-nls --enable-languages=f77,c++,objc,ada
+      --disable-win32-registry --disable-shared
+      Thread model: win32
+      gcc version 3.2 (mingw special 20020817-1)
+
+ If you don't know how to open a terminal, you can click on 'Start -> Run' + then type "command". Under Windows 2k/XP, you should type "cmd" instead. + + + +


+

Setting up Cygwin to build Allegro

+ +

+ The procedure is as follows: +

+

+ 1. Make sure you have a working Cygwin installation. You can download the + setup.exe program from 'http://sources.redhat.com/cygwin/'. + You will need the followin packages: bash, binutils, cygwin, cygutils, + fileutils, gcc, gdb, login, make, man, mingw-runtime, sed, sh-utils, + texinfo, textutils and w32api. + +

+ 2. Get the minimal DirectX 7 SDK for MinGW. (dx70_mgw.zip) Download it + from 'http://alleg.sourceforge.net/wip.html' and unzip it to a + temporary directory, for instance 'C:\Temp'. Then move the contents of + 'C:\Temp\lib' to 'C:\cygwin\lib\w32api', and the contents of + 'C:\Temp\include' to 'c:\cygwin\usr\include\w32api'. If you are asked + if you want to overwrite any existing files, choose to overwrite them. + +

+ 3. Put the following text in '/etc/profile' (c:\cygwin\etc\profile) +

+         export ALLEGRO_USE_CYGWIN=1
+         export MINGDIR=/usr/local
+         export CPATH=/usr/local/include
+         export LIBRARY_PATH=/usr/local/lib
+
+ Note: if the CPATH or LIBRARY_PATH variables are already set, you will + have to append the new path to the existing one by using a colon (":") + as the separator. + +
+


+ Test the installation by typing the following in the Bash shell: + 'gcc -v'. The answer should be similar to: +

+      Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.2/specs
+      gcc version 3.2 20020927 (prerelease)
+
+ Note: if you have problems installing the profiling version of the Allegro + library, you will probably need to copy a file called libgmon.a from the + MinGW distribution to your /lib/mingw directory (c:\cygwin\lib\mingw) in + Cygwin. This is expected to be fixed in a later release of the + mingw-runtime package (I'm currently using mingw-runtime-1.2-1). + + + +


+

Cross compilation

+ +

+ The procedure is as follows: +

+

+ 1. Download and install the MinGW cross-compiler. You can get the + software: + +

+

+ 2. Get the minimal DirectX 7 SDK for MinGW (dx70_mgw.zip). + Download it from 'http://alleg.sourceforge.net/wip.html' and unzip it + in the cross-compiler base directory. Make sure you convert all text + files to unix style (unzip -a) or the preprocessor will croak. The + DirectX package downloaded and installed by the SDL script is not up + to date: replace it with the package from the Allegro site. + +

+ 3. Edit the file 'xmake.sh' in the root of your Allegro directory, + replacing XC_PATH, XPREFIX and INSTALL_BASE with the right names. + For example, if your compiler's base dir (the one with bin, lib and + include sub-folders) is /usr/i586-mingw32msvc, and you have prefix-less + binaries in /usr/i586-mingw32msvc/bin, you would use: +

+         XC_PATH=/usr/i586-mingw32msvc/bin
+         XPREFIX=
+         INSTALL_BASE=/usr/i586-mingw32msvc
+
+ Note that the build-cross.sh script from SDL installs binaries both + with and without prefix, but some binaries (windres specifically) + are installed only with prefix. If you installed the crosscompiler + in /opt/cross-tools using this script, you would use: +
+         XC_PATH=/opt/cross-tools/i386-mingw32msvc/bin:/opt/cross-tools/bin
+         XPREFIX=i386-mingw32msvc-
+         INSTALL_BASE=/opt/cross-tools/i386-mingw32msvc
+
+ 4. Run './fix.sh mingw --dtou' (--dtou is only needed if your Allegro + directory has text files in DOS format, otherwise you can use --quick). + If you are using a CVS version of Allegro, run 'make depend' to + generate the build dependencies, then run 'misc/fixdll.sh' to generate + the allegro.def file. You are now finished with all the preparations. + +

+ 5. You can now run './xmake.sh' to build the Allegro library and then run + './xmake.sh install' as root to install it. Afterwards, you can use + 'xmake.sh' as you would use 'make' to compile your Allegro programs, or + you can use the 'cross-make.sh' and 'cross-configure.sh' scripts from + the SDL site. You must use 'xmake.sh' to compile Allegro itself though. + +

+ 6. To build the documentation, use the native build process. This + limitation will eventually be removed. +

+ + +


+

Installing Allegro

+ +

+ This assumes you have unzipped allegro to c:\allegro or, if you are using + MSYS, you have unzipped it to c:\msys\allegro (which is equivalent to + /allegro from within the MSYS environment) or, if you are using Cygwin, + you have unzipped it to c:\cygwin\allegro (which is equivalent to + /allegro from within the Cygwin environment). + +

+ First configure Allegro for MinGW. Unless you are using MSYS or Cygwin, + enter the following on the commandline (click on 'Start -> Run' then type + "command" or "cmd" to get a command prompt): +

+      cd c:\allegro
+      fix.bat mingw
+
+ If you are using MSYS or Cygwin, start your environment, which you can + find either on your desktop and/or on your Windows start menu. The + following commands should then be used instead of the ones above: +
+      cd /allegro
+      ./fix.sh mingw --dtou   (--dtou can be replaced by --quick for MSYS).
+
+ Now you're ready to build the Allegro library with: +
+      make (or mingw32-make if you are using a recent version of MinGW)
+
+ The dynamically linked version of Allegro gets built by default. If you + want to build the statically linked version of Allegro, use: +
+      make STATICLINK=1
+
+ If you want to build either the debug or the profile version of the + library, enter one of the following commands: +
+      make DEBUGMODE=1 (dynamically linked)
+      make DEBUGMODE=1 STATICLINK=1 (statically linked)
+      make PROFILEMODE=1 (dynamically linked)
+      make PROFILEMODE=1 STATICLINK=1 (statically linked)
+
+ A list of all the available options: +
+

+

CROSSCOMPILE
+ Set this if you are crosscompiling; it implies UNIX_TOOLS.
+ +

+

WARNMODE
+ Set this if you want Allegro to display and stop on nearly all + warnings issued by the compiler. Allegro should compile fine with + this set.
+ +

+

TARGET_ARCH_COMPAT + or + TARGET_ARCH_EXCL
+ These affect the level of processor dependant optimisation that + Allegro uses. You can set either of these to the processor type you + want to optimize for. The difference between these two is that + TARGET_ARCH_COMPAT optimise for the given processor so that the code + will still run on older processors, while TARGET_ARCH_EXCL will + generate code that will run exclusively on the given processor and of + course newer ones. Example: set TARGET_ARCH_COMPAT=i686
+ +

+

TARGET_OPTS
+ Affects the general optimisations that Allegro uses.
+ +

+

UNIX_TOOLS
+ If your system does not have the usual DOS tools available (`md', + `rd', `copy', etc., and commands which understand the \ character), + then set this to 1 to use the Unix equivalents. This is set + implicitly when you set CROSSCOMPILE, and is also set automatically + when you are running under bash.
+
+

+ To activate any of these, type (for example) "make WARNMODE=1". + +

+ If your copy of Allegro does not include the linker .def file (unlikely, + unless you have run "make veryclean" at some point, or are using the CVS + version of Allegro), you can regenerate it by running "misc\fixdll.bat". + You will need to have GNU sed and sort installed for this operation to + work. The version of sed that is linked from the MinGW site does not + work properly; it has issues with end-of-line characters. You should get + sed and sort from the link at the top of this document. + +

+ Once the build is finished you can recover some disk space by running + "make compress", which uses the UPX program to compress the executable + files and the optimized dll. Before running "make compress", you must set + the environment variable UPX_BIN to point to upx.exe. You will have to + do run "make compress" before "make install" if you want the compressed + dll to be copied to the windows directory. To recover even more disk + space, you can run "make clean" to get rid of all the temporary files and + HTML format documentation. + +

+ And then the last thing, installing the library. Run: +

+      make install
+
+ with the same options you passed to 'make' in order to build the library. + +

+ You have now installed Allegro! See the rest of the documentation and + examples to learn more about it. + + + +


+

Using Allegro

+ +

+ All the Allegro functions, variables, and data structures are defined + in allegro.h. You should include this in your programs, and link with + either the optimised library liballeg.a, the debugging library + liballd.a, or the profiling library liballp.a. You should include the + Allegro DLLs in any software you release to the public. + +

+ When using a statically linked library, you must define the preprocessor + symbol ALLEGRO_STATICLINK before including any of the Allegro headers and + link your program against Allegro and the main Win32/DirectX libraries + in that order (see the variable LIBRARIES in makefile.mgw). The names of + the statically linked Allegro libraries are post-fixed with '_s' so that + you will link with either liballeg_s.a, liballd_s.a or liballp_s.a. + +

+ Don't forget that you need to use the END_OF_MAIN() macro right after + your main() function. + + + +


+

Compiling manually with MinGW

+ +

+ A simple example of a command line to compile an Allegro program with + MinGW looks like: +

+      gcc foo.c -Wl,--subsystem,windows -O2 -Wall -o foo.exe -lalleg
+
+ If you are compiling with Cygwin, the compiler option '-mno-cygwin' must + be added, both at compile-time and at link-time: +
+      gcc foo.c -Wl,--subsystem,windows -mno-cygwin -O2 -Wall -o foo.exe -lalleg
+
+ Note that, if you want to make a console application, you must use + '-Wl,--subsystem,console' instead of '-Wl,--subsystem,windows'. + + + +


+

Creating a program with Dev-C++

+ +

+ A simple example on how to create a little program with Dev-C++: + +

+ Launch Dev-C++ and create a new project (File/New Project). Select + "Windows Application", then click on the "Ok" button. Name your + project and give associate it to a new file. You should now see a + sample code in a window. Close that window since you won't be + needing it (Allegro is much simpler to use than this). Create a + new file (File/New Source File), then write a small Allegro + program. You can inspire yourself by the Allegro examples if you + wish. Here's a small program you can type to see if everything + worked until now: +

+      #include <allegro.h>
+
+      int main() {
+         allegro_init();
+         allegro_message("Hello World!");
+         return 0;
+      }
+      END_OF_MAIN()
+
+ You now need to tell Dev-C++ that you'd like to make a program that + uses Allegro. For that, go in the Project Options screen + (Project/Project Options menu), then enter -lalleg (or -lalld for + the debug mode) in the box under 'Further object file or linker + options' or select 'Parameters tab' and enter -lalleg (or -lalld for + the debug mode) in the box under 'Linker'. + +

+ Compile your project! Simply click on the green check mark on + your Dev-C++ toolbar. Correct any syntax errors in your code, + then click on "Execute" to run the program. If all worked + you will see a message box pop up with "Hello World" inside of it. + +

+ Happy coding! + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/msvc.html b/lib/allegro/allegro-htmldocs-4.2.1/build/msvc.html new file mode 100644 index 0000000..8ac577f --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/msvc.html @@ -0,0 +1,249 @@ + + +Allegro MSVC-specific information + + + + +

+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                 MSVC-specific information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

MSVC notes

+ +

+ Status: complete. + +

+ The screensaver example is built, but you must copy scrsave.scr to + your windows/system directory (or winnt/system32 directory + under Windows NT/2k/XP) if you want to test it. + + + +


+

Required software

+ +

+

+ Allegro should work ok with MSVC versions 4, 5, 6, 7.0 (.NET), + 7.1 (.NET 2003) and 8.0 (.NET 2005). However note that the lowest tested + version is 6. + +

+ The DirectX SDK can be obtained directly from Microsoft. An old version + of the headers is included with MSVC 6, but Allegro requires more recent + files. You should either copy the current headers into your MSVC include + and lib directories, or alter your INCLUDE and LIB environment variables + to put the DirectX SDK files in front of the standard MSVC locations. + +

+ If you choose to use DJGPP as your GNU environment, the DJGPP compiler and + associated tools can be downloaded from your nearest SimTel mirror site, + in the /pub/simtelnet/gnu/djgpp/ directory, or you can use the zip picker + on http://www.delorie.com/djgpp/. See the djgpp readme.1st file for + informations about how to install DJGPP. + +

+ If you choose MinGW, download the MinGW compiler and associated tools from + 'http://www.mingw.org' or 'http://sourceforge.net/projects/mingw/'. You + can download the complete distribution instead of the individual packages + if you don't want to install each package manually. + +

+ If you choose Cygwin, get setup.exe from 'http://sources.redhat.com/cygwin/'. + Start the Cygwin setup program and download the required packages. Then + install the packages (run setup.exe once more). When setup asks you which + line endings you want, select unix-style instead of DOS. + +

+ Remember that the chosen set of tools have to be on your PATH during the + building of Allegro. + + + +


+

Installing Allegro

+ +

+ This is a source-only distribution, so you will have to compile Allegro + before you can use it. To do this you should: + +

+ Set up your environment so that MSVC can be used from the commandline. + You probably have a vcvars32.bat file that will do this for you (usually + located in the VC98\BIN folder where you have MSVC installed, for example + C:\Program Files\Microsoft Visual Studio\). Under either Windows NT or + Windows 2000, you will have to run this file every time you open a DOS box + or configure the environment variables in Control Panel/System/Environment. + +

+ The make process needs all the path variables to be in DOS 8.3 format, and + since MSVC is usually installed in something like + "C:\Program Files\Microsoft\Microsoft Visual Studio .NET 2003", + this will cause a problem. Run "echo %MSVCDir%" (%VCINSTALLDIR% + under MSVC 8) from the command line to see if you have this problem. + If you are using MSVC 6 or lower the output should already be in DOS 8.3 + format so you should not have any troubles. With higher versions of MSVC + it will probably show the long path with spaces. There are two solutions + for this. + +

+ If you have chosen MinGW and have installed it with the w32api package + you can solve this problem simply by passing the --msvcpaths + parameter to fix.bat (see below). + +

+ Otherwise if you are using vcvars32.bat, you will have to + edit it so that it sets the 8.3 paths, not the long versions. + To get 8.3 path names, you can use the command prompt (cmd.exe). + Type in "dir /x" to get a listing of the 8.3 file and directory + names alongside of their full names. You can also use the DOS prompt + (command.exe) and "dir", but this will only show + you the 8.3 names. + +

+ If you are using Cygwin as the GNU environment, start the Cygwin bash shell + from the command prompt (if you used the command prompt to run vcvars32.bat + then you must start Cygwin in the same command-prompt window you used to + run vcvars32.bat unless you configured the environment variables in Control + Panel/System/Environment). This is usually done via "C:\cygwin\cygwin.bat". + +

+ Go to the directory where you have installed Allegro by using 'cd'. + +

+ If you are using Cygwin, type "./fix.sh msvc --utod". Otherwise (i.e if + you are using DJGPP or MinGW), type "fix.bat msvc". If you are + using MinGW and want the fix.bat to solve problems with long paths, + type "fix.bat msvc --msvcpaths". + +

+ If you are using MSVC 7 you can specify "msvc7" instead of "msvc" to enable + better optimizations. Likewise, you can specify "icl" to use the Intel + commandline compiler. If you are using MSVC 8 you should specify "msvc8" + otherwise you will get a lot of deprecation warnings. For MSVC 6 and older + you can use also "msvc6". + +

+ If you are compiling from CVS, before continuing you must run both + "make depend" and "misc/fixdll.sh" as explained below, or the build will + fail asking for some .inc file. + +

+ Type "make". Then go do something interesting while everything compiles. + When it finishes compiling, type "make install" to set the library up + ready for use. + +

+ If you also want to install a debugging version of the library (highly + recommended), now type "make install DEBUGMODE=1". Case is important, so + it must be DEBUGMODE, not debugmode! + +

+ If you also want to install a profiling version of the library, now type + "make install PROFILEMODE=1". + +

+ If you want statically linked libraries as well as the default DLLs, pass + additionally "STATICLINK=1" to the make commands above. + +

+ If your copy of Allegro doesn't include the makefile.dep dependency files + (unlikely, unless you have run "make veryclean" at some point or are + building the CVS version), you can regenerate them by running + "make depend". + +

+ If your copy of Allegro doesn't include the linker .def file (unlikely, + unless you have run "make veryclean" at some point or are building the CVS + version), you can regenerate it by running "misc\fixdll.bat". Cygwin users + can run "misc/fixdll.sh" instead. + +

+ Once the build is finished you can recover some disk space by running + "make compress", which uses the UPX program to compress the executable + files and the optimized dll. Before running "make compress", you must set + the environment variable UPX_BIN to point to upx.exe. You will have to + do run "make compress" before "make install" if you want the compressed + dll to be copied to the windows directory. To recover even more disk + space, you can run "make clean" to get rid of all the temporary files and + HTML format documentation. + + + +


+

Using Allegro

+ +

+ All the Allegro functions, variables, and data structures are defined in + allegro.h. You should include this in your programs, and link with one of + the libraries: +

+      alleg.lib      - optimised DLL import library
+      alld.lib       - debugging DLL import library
+      allp.lib       - profiling DLL import library
+      alleg_s.lib    - statically linked optimised library
+      alld_s.lib     - statically linked debugging library
+      allp_s.lib     - statically linked profiling library
+
+ When using a statically linked library, you must define the preprocessor + symbol ALLEGRO_STATICLINK before including any of the Allegro headers and + link your program against Allegro and the main Win32/DirectX libraries + in that order (see the variable LIBRARIES in makefile.vc). You have also + to make sure that your program is linked against the right C run-time + library, ie. the multi-threaded DLL version of MSVCRT (or the debug + version if you are using the debug library). You can change this option + at Project - Settings - C/C++ - Category: Code Generation - Use run-time + library. + +

+ Don't forget that you need to use the END_OF_MAIN() macro right after + your main() function! + +

+ If you use one of the DLL versions, you will obviously need to distribute + the appropriate DLL along with your program: these can be found in the + allegro/lib/msvc/ directory. + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/qnx.html b/lib/allegro/allegro-htmldocs-4.2.1/build/qnx.html new file mode 100644 index 0000000..c915b44 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/qnx.html @@ -0,0 +1,118 @@ + + +Allegro QNX-specific information + + + + +

+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                 QNX-specific information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

QNX notes

+ +

+ Status: it works. Only annoying bug left seems to be the display switching + in fullscreen mode; just don't try to change workspace while in fullscreen + or your program will crash... Also, video bitmaps and hardware acceleration + are still not yet implemented. + + + +


+

Required software

+ +

+ The library works with QNX 6.0 RTP. You need the development tools + installed on your system; if you don't have them, you can get them from the + QNX online repository using the Package Manager. + + + +


+

Installing Allegro

+ +

+ As Allegro is a multiplatform library, you first need to set it up for use + on QNX RTP, by running: +

+      chmod +x fix.sh
+      ./fix.sh qnx
+
+ Now you may want to generate the dependencies; this step is optional if + you are using an official release, but it is required if you got a CVS + snapshot of the library. +
+      make depend
+
+ Then you need to build Allegro: +
+      make
+
+ And finally install it (you need to be root for this): +
+      su -c "make install"
+
+ Installing the library will copy the header files to /usr/include, the + library file to /usr/lib and the allegro-config script into /usr/bin. + + + +


+

Using Allegro

+ +

+ Linking with Allegro requires you to link also other libraries to your + executables. To avoid you having to work out the right linker commands for + yourself, the installation creates a script, allegro-config, that will + print out a suitable commandline. You can use this inside a backtick + command substitution, for example: +

+      gcc myfile.c -o myprogram `allegro-config --libs`
+
+ Or if you want to build a debug version of your program, assuming that + you have installed the debug version of Allegro: +
+      gcc myfile.c -o myprogram `allegro-config --libs debug`
+
+ Unix newbies, take note that these are ` backticks, not normal ' quotes! + +

+ There are also switches for printing out the Allegro version number and + overriding the install paths. Run allegro-config without any arguments + for a full list of options. + +

+ Don't forget that you need to use the END_OF_MAIN() macro right after + your main() function! + + + +


+

Final notes

+ +

+ Allegro for QNX requires you to be running the Photon MicroGUI environment; + if Photon cannot be found, the library will fail to initialize. If this + happens, you're probably in a text console; just run "ph" to start Photon. + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/tmpfile.txt b/lib/allegro/allegro-htmldocs-4.2.1/build/tmpfile.txt new file mode 100644 index 0000000..18f7a67 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/tmpfile.txt @@ -0,0 +1 @@ +This file is needed because some unzip programs skip empty directories. diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/unix.html b/lib/allegro/allegro-htmldocs-4.2.1/build/unix.html new file mode 100644 index 0000000..1c01e6a --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/unix.html @@ -0,0 +1,376 @@ + + +Allegro Unix-specific information + + + + +

+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                 Unix-specific information.
+
+         See readme.txt for a more general overview.
+
+   Also see docs/build/linux.txt for Linux-specific information.
+
+ + + +


+

Unix notes

+ +

+ On Linux you have two different system drivers -- one for running using + X, and one for running without X. This file describes the X version, + which should in theory be totally portable to any Unix variant. For + information about the Linux-specific console routines, see + docs/build/linux.txt. + + + +


+

Required software

+ +

+ Since you are using a Real Operating System, the chances are that you + already have all the necessary development tools, at least for compiling + and installing the library. However, you may also need GNU autoconf if you + make any changes that require you to regenerate the configure script. + + + +


+

Installing Allegro

+ +

+ If you downloaded Allegro as a Unix format .tar archive, it will already + be set up ready to go. If you downloaded a DOS or Windows format .zip + version, though, you will need to convert it into Unix format before you + can begin, by running: +

+      chmod +x fix.sh
+      ./fix.sh unix
+
+ From here on everything is a pretty standard Unix-style install process. + First you configure it: +
+      ./configure
+
+ It should automatically build dependencies. Then you build it: +
+      make
+
+ And finally you install it (as root -- see below for information on what + to do if you can't be root): +
+      su -c "make install"
+
+ You may also wish to install the man pages: +
+      su -c "make install-man"
+
+ And perhaps the info docs as well: +
+      su -c "make install-info"
+
+ The configure script has many options for changing the install paths, + deciding which parts of the library to include or leave out, and + specifying whether to build release libs, debug libs, etc. Run + ./configure --help for a list of switches. Especially useful options are: +
+      --enable-static      - builds a statically linked library
+      --disable-shared     - disables the default shared libraries
+      --enable-dbglib      - builds a debug version of the library
+      --enable-dbgprog     - links test programs with the debug library
+
+ These switches work in combination, for example if you pass + --enable-static but not --disable-shared, you will get both shared and + statically linked versions of Allegro. + +

+ By default, Allegro will probably install into the /usr/local filesystem. + If this hasn't already been set up on your machine, you may have trouble + with programs being unable to find the Allegro shared library. On some + Unices (for example Linux), you can fix this by adding "/usr/local/lib" to + your /etc/ld.so.conf file and then running `ldconfig' as root. On others + (for example Solaris), you can hardcode the location of the library into + the executables by passing "-R/usr/local/lib" to the compiler or linker. + Alternatively, you can add the path to your LD_LIBRARY_PATH environment + variable. + +

+ If you are compiling a CVS version of Allegro, you need to generate the + configure header and script prior to doing anything else. Make sure that + GNU autoconf 2.53 or newer is installed on your system and type: +

+      autoheader   
+      autoconf
+
+ It is possible to add compilation and link flags to the make command line. + This is done by passing CFLAGS and/or LDFLAGS to make, with the flags + you want. This is meant as a generic customization ability and you should + really use configure to set the flags if possible. Note that any flags you + pass using the make command line are transient: they will only apply to + whatever compilation and link happen to be spawned by this particular + invokation of make. + When you pass CFLAGS and/or LDFLAGS to the make command line Allegro's + build system will use these as a starting point and will add its own + flags to those. This means that you should be aware that flags you pass + this way may be overridden. For this reason, it is best to only use this + to specify flags that do not interfere with the code generation. Useful + flags to pass are -save-temps, or -pipe. + + + +


+

Shared files

+ +

+ Installing Allegro will copy the library and header files plus other + support files. These are: +

+ On the other hand, there are files which you, as system administrator, are + required to installed manually. These are: + + You can find more information about some of these files and other + suggestions in the chapter "Unix specifics" of the main Allegro manual. + + + +


+

Using Allegro

+ +

+ The options for linking with Allegro are quite complicated, since + for static versions of the library, depending on how it was configured, + it may need to pull in other libraries (X, SVGAlib), as well as just + Allegro itself, and for all versions the library is split into two chunks + -- one of which is always static, and the other of which is sometimes + shared. To avoid you having to work out the right linker commands for + yourself, the installation creates a script, allegro-config, that will + print out a suitable commandline. You can use this inside a backtick + command substitution, for example: +

+      gcc myfile.c -o myprogram `allegro-config --libs`
+
+ Or if you want to build a debug version of your program, assuming that + you have installed the debug version of Allegro: +
+      gcc myfile.c -o myprogram `allegro-config --libs debug`
+
+ Unix newbies, take note that these are ` backticks, not normal ' quotes! + +

+ There are also switches for printing out the Allegro version number, + overriding the install paths, and selecting between shared and static + libraries, in case you installed both. Run allegro-config without any + arguments for a full list of options. + +

+ Don't forget that you need to use the END_OF_MAIN() macro right after + your main() function! + + + +


+

Setting an X11 icon

+ You can set the X11 icon for your application to use. To do this, you need + to include the icon in .xpm format and then point the symbol allegro_icon + to the .xpm data before calling set_gfx_mode(). + Alternatively, you can use the xfixicon.sh shellscript to produce a C file + that will do this for you automatically when you link it with your project. + No other steps are required. The xfixicon.sh utility will also accept + bitmaps that are not in .xpm format, interpreting magic pink as transparent. + You will need to have the ImageMagik tools installed for this to work. + + + +


+

Shared library compatibility

+ +

+ Allegro can interface with a lot of other libraries -- in particular, + various X libraries and SVGAlib. If you link statically to Allegro, + your program will depend upon all these other libraries so you may want + to link statically to them too. If you link dynamically to Allegro, your + binary will only depend upon the Allegro version (and things like libc); + in this case your binary is more easily portable, but it does depend + upon the way Allegro was configured. + +

+ The easiest way to make your program portable is to distribute it in + source form. That way the users can configure Allegro for themselves, + and will always end up using exactly the right set of libraries for + their particular system. + +

+ Having said that, if you enable dynamic module support (default), then + you should have few (if any) problems. + +

+ Security note: Make sure that untrusted users cannot write to either of + the `/usr/local/lib/allegro/' or `/usr/lib/allegro/' directories. + Allegro looks for dynamically loaded modules in those directories, and + loads all of them listed in `modules.lst' at startup. + +

+ See also the ABI compatibility document for more information (abi.txt). + + + +


+

What if you're not root?

+ +

+ Allegro can be installed on a system where you don't have root + privileges. Using the standard configure script option `--prefix' you + can change the target directories for installation -- for example, + you can write: +

+      ./configure --prefix=$HOME
+
+ Be a bit careful, --prefix=~ works in bash but not tcsh -- it's safer + to use $HOME if you're not sure. + +

+ Then binaries will be installed to the `bin' subdirectory of your home + directory, libraries to `lib', etc. Now you need to set up your system + so that it knows where to find a few things, if this has not been done + already. You might want to add these commands to your .bash_profile + or similar startup script. If you use a csh-style shell, you want to + use `setenv', not `export'. + +

+ Your PATH must include the `bin' directory: +

+      export PATH=$PATH:$HOME/bin
+
+ If you are using Allegro as a shared library, you need to tell the dynamic + loader where to find the Allegro libraries: +
+      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib
+
+ GCC needs to know where to find header and library files: +
+      export C_INCLUDE_PATH=$C_INCLUDE_PATH:$HOME/include
+      export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$HOME/include
+      export LIBRARY_PATH=$LIBRARY_PATH:$HOME/lib
+
+ Note: in fact `allegro-config' can handle the last step for you, if + you use it for compilation as well as linking: +
+      gcc -c mygame.c `allegro-config --cflags`
+      gcc -o mygame mygame.o `allegro-config --libs`
+
+ But, it's better to set the environment variables too. Most people + don't tend to bother with `allegro-config' when compiling. + +

+ Alternatively, you can get the required environment changes from + allegro-config, by typing at a shell prompt: +

+      allegro-config --env
+
+ You can catenate the output to your .bash_profile, which is pretty + much like adding all of the above commands. Note that `allegro-config' + itself is in the `bin' directory of the installation, so either make + sure that directory is in your path before running `allegro-config' or + specify the path exactly, for example: +
+      ~/bin/allegro-config --env >> ~/.bash_profile
+
+ + +


+

Notes on drivers

+ +

+

System:
+ On initialisation, Allegro will try to connect to an X server. If it + can't find one, it will give up and try to use some different system + driver instead (such as the Linux console). This means that to run + it in X mode, you must either launch your programs from inside an X + session, or have set the DISPLAY environment variable to indicate + what server you would like to use.
+ +

+

Graphics:
+ There are two different X graphics drivers: GFX_XWINDOWS uses only + standard X calls, while GFX_XDGA2 uses the XFree86 DGA 2.0 extension + (shipped with XFree86 4.0.x) which allows it to write directly to the + screen surface, and use hardware acceleration if available. It is + normally much faster than the standard X mode, but requires root + permissions and will not work remotely. + +

+ If your program requests a different color depth to the current X + display, Allegro will emulate the depth you asked for, so that your + program will still work, albeit more slowly than if the color depths + were identical. To find out whether this emulation is taking place, + look at the gfx_driver->desc field (which is displayed in the middle of + the screen by the tests/test program). If this says "matching", the + color formats are identical, so no conversions are required. If it says + "fast", some simple conversions are taking place, but nothing too + painful. If it says "slow", you are in trouble :-) This is not valid + for the DGA 2.0 driver, as it'll always change the video mode to the + specified resolution and color depth.

+
+ + +


+

Irix Notes

+ +

+ If the Irix compiler spits strange lines such as the following when + compiling your Allegro program: +

+      include/allegro/alcompat.h:59: conflicting types for `ceilf'
+      /usr/include/math.h:311: previous declaration of `ceilf'
+      include/allegro/alcompat.h:60: conflicting types for `floorf'
+      /usr/include/math.h:333: previous declaration of `floorf'
+      include/allegro/alcompat.h:63: conflicting types for `tanf'
+      /usr/include/math.h:176: previous declaration of `tanf'
+      include/allegro/alcompat.h:64: conflicting types for `acosf'
+      /usr/include/math.h:106: previous declaration of `acosf'
+      include/allegro/alcompat.h:65: conflicting types for `asinf'
+      /usr/include/math.h:116: previous declaration of `asinf'
+
+ then you should #define ALLEGRO_NO_FIX_ALIASES prior to + the #include <allegro.h> line. + + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/build/watcom.html b/lib/allegro/allegro-htmldocs-4.2.1/build/watcom.html new file mode 100644 index 0000000..c6dc0bb --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/build/watcom.html @@ -0,0 +1,114 @@ + + +Allegro Watcom-specific information + + + + +
+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                Watcom-specific information.
+
+         See readme.txt for a more general overview.
+
+ + + +


+

Watcom notes

+ +

+ Status: complete and fully functional, but not so widely used and tested + as the djgpp code. This version is heavily based on the djgpp version, + basically just emulating whatever parts of the djgpp libc aren't provided + by Watcom. See docs/build/djgpp.txt for information about the available + hardware drivers: the djgpp and Watcom versions are 100% identical in this + respect. + +

+ This library works with version 10.6 and the various 11.0 versions of the + Watcom C compiler, as well as with Open Watcom 1.0 or later. + + + +


+

Required software

+ +

+

+ Except for the Watcom compiler itself, all of the above packages can be + downloaded from your nearest SimTel mirror site, in the + /pub/simtelnet/gnu/djgpp/ directory, or you can use the zip picker on + http://www.delorie.com/djgpp/. See the djgpp readme.1st file for + information about how to install djgpp. + + + +


+

Installing Allegro

+ +

+ This is a source-only distribution, so you will have to compile Allegro + before you can use it. To do this you should: + +

+ Type "cd allegro", followed by "fix.bat watcom", followed by "make". Then + go do something interesting while everything compiles. When it finishes + compiling, type "make install" to set the library up ready for use. + +

+ The makefile will try to guess whether you are using Watcom 10.6 or 11.0 + by checking for the presence of wdisasm.exe. If it gets this wrong, you + may need to override it by passing WATCOM_VERSION=10.6 or + WATCOM_VERSION=11 as arguments to make, or setting the WATCOM_VERSION + environment variable. + +

+ If you also want to install a debugging version of the library (highly + recommended), now type "make install DEBUGMODE=1". Case is important, so + it must be DEBUGMODE, not debugmode! + +

+ If you also want to install a profiling version of the library, now type + "make install PROFILEMODE=1". + +

+ If your copy of Allegro doesn't include the makefile.dep dependency files + (unlikely, unless you have run "make veryclean" at some point), you can + regenerate them by running "make depend". + + + +


+

Using Allegro

+ +

+ All the Allegro functions, variables, and data structures are defined in + allegro.h. You should include this in your programs, and link with either + the optimised library alleg.lib, the debugging library alld.lib, or the + profiling library allp.lib. Programs that use Allegro must be compiled to + use the stack based calling convention (wcl386 option '-5s'), and with + stack overflow checks disabled (wcl386 option '-s'). You will also have + to increase the stack size from the miserly Watcom default, using a + wcl386 option like '-k128k', or a linker command like 'option stack=128k'. + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/changes.html b/lib/allegro/allegro-htmldocs-4.2.1/changes.html new file mode 100644 index 0000000..05cb10b --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/changes.html @@ -0,0 +1,5411 @@ + + +Allegro Changes + + + + + +

+

Changes from 4.2.1 RC1 to 4.2.1 (November 2006)

+

+ +

+

Changes from 4.2.0 to 4.2.1 RC1 (May 2006)

+

+ +

+

Changes from 4.2.0 RC2 to 4.2.0 (November 2005)

+

+ +

+

Changes from 4.2.0 RC1 to 4.2.0 RC2 (August 2005)

+

+ +

+

Changes from 4.2.0 beta 4 to 4.2.0 RC1 (August 2005)

+

+ +

+

Changes from 4.2.0 beta 3 to 4.2.0 beta 4 (June 2005)

+

+ +

+

Changes from 4.2.0 beta 2 to 4.2.0 beta 3 (May 2005)

+

+ +

+

Changes from 4.2.0 beta 1 to 4.2.0 beta 2 (April 2005)

+

+ +

+

Changes from 4.1.18 to 4.2.0 beta (March 2005)

+

+ +

+

Changes from 4.1.17 to 4.1.18 (January 2005)

+

+ +

+

Changes from 4.1.16 to 4.1.17 (December 2004)

+

+ +

+

Changes from 4.1.15 to 4.1.16 (October 2004)

+

+ +

+

Changes from 4.1.14 to 4.1.15 (July 2004)

+

+ +

+

Changes from 4.1.13 to 4.1.14 (April 2004)

+

+ +

+

Changes from 4.1.12 to 4.1.13 (March 2004)

+

+ +

+

Changes from 4.1.11 to 4.1.12 (Nov 2003)

+

+ +

+

Changes from 4.1.10 to 4.1.11 (Jun 2003)

+

+ +

+

Changes from 4.1.9 to 4.1.10 (Jun 2003)

+

+ + +


+

Changes from 4.1.8 to 4.1.9 (Jan 2003)

+

+ + +


+

Changes from 4.1.7 to 4.1.8 (Dec 2002)

+

+ + +


+

Changes from 4.1.6 to 4.1.7 (Dec 2002)

+

+ + +


+

Changes from 4.1.5 to 4.1.6 (Nov 2002)

+

+ + +


+

Changes from 4.1.4 to 4.1.5 (Nov 2002)

+

+ + +


+

Changes from 4.1.3 to 4.1.4 (Oct 2002)

+

+ + +


+

Changes from 4.1.2 to 4.1.3 (Sep 2002)

+

+ + +


+

Changes from 4.1.1 to 4.1.2 (Sep 2002)

+

+ + +


+

Changes from 4.1.0 to 4.1.1 (Aug 2002)

+

+ + +


+

Changes from 4.0.2 to 4.1.0 (Jul 2002)

+

+ + +


+

Changes from 4.0.1 to 4.0.2 (Jun 2002)

+

+ + +


+

Changes from 4.0.0 to 4.0.1 (Mar 2002)

+

+ + +


+

Changes from 3.9.40 to 4.0.0 (Dec 2001)

+

+ + +


+

Changes from 3.11 to 3.9.40 (Nov 2001)

+

+ + +


+

Changes from 3.11 to 3.12 (Aug 1999)

+

+ + +


+

Changes from 3.1 to 3.11 (Feb 1999)

+

+ + +


+

Changes from 3.0 to 3.1 (Jan 1999)

+

+ + +


+

Changes from 3.0 beta to release (Dec 1997)

+

+ + +


+

Changes from 2.2 to 3.0 beta (Nov 1997)

+

+ + +


+

Changes from 2.11 to 2.2 (Feb 1997)

+

+ + +


+

Changes from 2.1 to 2.11 (Nov 1996)

+

+ + +


+

Changes from 2.0 to 2.1 (June 1996)

+

+ + +


+

Changes from 2.0 beta to release (March 1996)

+

+ + +


+

Changes from 1.x to 2.0 beta (Jan/Feb 1996)

+

+ + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/const.html b/lib/allegro/allegro-htmldocs-4.2.1/const.html new file mode 100644 index 0000000..f4dd5bd --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/const.html @@ -0,0 +1,162 @@ + + +Allegro `const'-correctness + + + + +

+Allegro `const'-correctness +

+
+ +This is a short document about the introduction of `const'-correctness +to Allegro. It details what changes have occurred to internal library +code, the API changes (mainly transparent) and what you will need to do +to adapt code to compile without warnings (again, mainly nothing). + + + +


+

Contents

+ +

+

+ + + +


+

Library changes

+ +

+There are very few actual changes to the library code itself; only some +symbol declarations and definitions have been altered to include +AL_CONST. See below for a description of the AL_CONST preprocessor +define. In a few places, some string was changed that should not have +been - in these cases, the string is simply duplicated and then the +duplicate is erased on exiting the function. + +

+In all, there were very few changes to the library code. + + + +


+

The AL_CONST preprocessor define

+ +

+In order to support compilers which don't know about the `const' +keyword, or perhaps use a different keyword, the preprocessor symbol +AL_CONST is used wherever `const' would normally be used. Note that in +the documentation, I have used `const' for readability. + + + +


+

Allegro API changes

+ +

+These are, generally speaking, totally transparent to the user. I did +not change the behaviour of any function; only its parameter types. +Basically, if you can pass it as type* ptr, then you can +pass it as const type* ptr without any problem whatsoever. +Note also that certain changes may remove warnings in your program as +static strings, etc, are now treated as `const' by Allegro functions. + +

+There are a few places, described below, where there will be an effect +on existing code. + +

+`const'-correctness is deemed important for two reasons. Firstly, it can +increase code readability and comprehension of Allegro functions (for +instance, you can see which parameters are altered and which are not). +Secondly, it ensures that the Allegro code is not changing data which it +should not be, and that client callback functions are not breaking +Allegro by changing data they should not be. + + + +


+

Callback functions and Pointers to Pointers

+ +

+Certain callback functions now have a different type - they take `const' +pointers as opposed to non-`const' pointers. As far as I know, a +compiler will issue a warning about incompatible pointer types. You +should update your callback function to the new format (which will be +listed in the main Allegro documentation). + +

+Also, when passing a pointer to a pointer to an Allegro function which +is declared as taking an AL_CONST type** ptr, you will need +to cast your pointer to be `const' if it is not already. For instance: +

+   int some_allegro_function(AL_CONST char** p);
+   
+   void my_func(char** x)
+   {
+       some_allegro_function((AL_CONST char**) x);
+   }
+
+I realise that this is a change to the Allegro API, and that we are +supposed to avoid those at all costs, but this is essentially fixing a +bug in Allegro and changing behaviour. It also ensures that +client-supplied callback functions are functioning correctly, and not +altering data that they should not. Callback functions which do not +treat relevant parameters as `const' are, in a small (but potentially +signficant) way, broken. + +

+Please note that for the Unicode function ugetx(), I have provided an +alternative version ugetxc(), which takes a `const char**' parameter as +opposed to a `char**' parameter. This is because it is valid to pass +either a `char**' or a `const char**', but unfortunately there is no way +to tell the compiler exactly what we mean. + + + +


+

BITMAP objects

+ +

+Allegro represents both a screen bitmap and a memory bitmap by a single +object; a BITMAP. Unfortunately, these two things can be very different. +For instance, reading a pixel from a bitmap would not seem to change it, +but if it is a screen bitmap we are reading from, then it is possible +that some parameter of the video card is changed to select the correct +line, etc. + +

+Therefore, a const BITMAP parameter does not make sense, and is not used +throughout the library. This is unfortunate, but I cannot see any way +around it. + + + +


+

Finally...

+ +

+Allegro `const'-correctness has been tested for quite enough time to say +that it is working OK. However, if you still find problems with a compiler, +please contact the Allegro mailing list; see `Contact info' in the Allegro +documentation (readme.txt). + +

+Email: lwithers@lwithers.demon.co.uk. + +

+Thanks for listening :-) + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/dat.html b/lib/allegro/allegro-htmldocs-4.2.1/dat.html new file mode 100644 index 0000000..f1f0cb5 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/dat.html @@ -0,0 +1,281 @@ + + +dat + + + + + +

+The DAT archiver +

+
+ +


+

Commandline options

+ +

+As an alternative to the graphical grabber program, you can use the command +line dat utility. This accepts the following options: + +

+ '-a <files>' + +

+ Adds the named files to the datafile, for example: + +

+         dat myfile.dat -a title.pcx scream.wav
+
+ +

+ If the objects are already present in the datafile, their current + contents will be replaced. Names for the new objects will be generated + from the input filenames, and the object type will be detected from + the file extensions. In some cases this is ambiguous, for example a + PCX file can be read as a bitmap, RLE sprite, compiled sprite, or font + object, so you may need to explicitly specify the object type with the + '-t' flag. For example, to insert alien.pcx as an RLE sprite, use the + command: + +

+         dat myfile.dat -a alien.pcx -t RLE
+
+ +

+ '-bpp colordepth' + Specifies which color format bitmap data should be grabbed in (valid + depths are 8, 15, 16, 24, and 32 bits per pixel). + +

+ '-c0' - no compression + +

+ '-c1' - compress objects individually + +

+ '-c2' - global compression on the entire datafile + +

+ Sets the compression mode (see below). These can be used on their own + to convert a datafile from one format to another, or in combination + with any other options. + +

+ '-d <objects>' + +

+ Deletes the named objects from the datafile. + +

+ '-dither' + +

+ Dithers graphics when reducing color depths. + +

+ '-e <objects>' + +

+ Extracts the named objects from the datafile. To extract everything, + use the wildcard * as the object name. To set the output filename or + directory, use the '-o filename' option. For example, to extract an + object called TITLE_SCREEN to the file title.pcx, use the command: + +

+         dat myfile.dat -e title_screen -o title.pcx
+
+ +

+ To extract the entire contents of the datafile to the directory + c:\output, use: + +

+         dat myfile.dat -e * -o c:\output\
+
+ +

+ '-f' + +

+ Stores the references to original files as relative filenames instead of + absolute filenames. This greatly increases the portability of complete + source trees containing the source data. + +

+ '-g x y w h' + +

+ Grabs bitmap data from a specific grid location. + +

+ '-h outputfile.h' + +

+ Sets the output header file, for exporting object index definitions. + This may be used on its own to produce a header file from an existing + datafile, or in combination with any other commands. You can also use + the '-p prefixstring' option to set a prefix string for the object + definitions. + +

+ '-k' + +

+ Keep original names while grabbing objects. Without this switch, a + file called image.pcx will be imported as an object called IMAGE_PCX, + to ensure that all the object names are valid symbols for the output + header defines. + +

+ '-l' + +

+ Lists the contents of the datafile. This can be combined with the '-v' + option to list object properties along with the names, and you can + specify particular objects to produce a partial listing. + +

+ '-m dependencyfile' + +

+ Writes a set of makefile dependencies into the specified file, which + can be used to automatically update the file whenever any of the + source data changes. + +

+ '-n0' - no sort: list the objects in the order they were added + +

+ '-n1' - sort the objects of the datafile alphabetically by name + +

+ Sets the sort mode (see below). These can be used on their own to + sort the objects of the datafile, or in combination with any other + options. + +

+ '-o output' + +

+ Sets the output file or directory when extracting data. + +

+ '-p prefixstring' + +

+ Sets the prefix for the output header file. + +

+ '-pal objectname' + +

+ Specifies which palette to use. + +

+ '-r' + +

+ Recursively adds directories as nested datafiles. This makes it possible + to maintain the data hierarchy within the datafile. + +

+ '-s0' - no strip: save everything + +

+ '-s1' - strip grabber specific information from the file + +

+ '-s2' - strip all object properties and names from the file + +

+ '-s-PROP' do not strip object property PROP from the file + +

+ Sets the strip mode (see below). These can be used on their own to + strip properties from the datafile, or in combination with any other + options. + +

+ '-t type' + +

+ Sets the object type when adding files. + +

+ '-transparency' + +

+ Preserves transparency when converting between color depths. + +

+ '-u' + +

+ Updates the contents of the datafile. See below. + +

+ '-v' + +

+ Selects verbose mode. This can be used in combination with any other + options to produce more detailed output. + +

+ '-w' + +

+ Always updates the entire contents of the datafile. + +

+ '-x <objects>' + +

+ Alias for '-e <objects>'. + +

+ '-007 password' + +

+ Sets the file encryption key. + +

+ '<objects> PROP=value' + +

+ Sets properties for the specified objects. This works like environment + variables, in that setting a property to an empty string removes it. + Because object names are stored as NAME properties, you can use this + command to rename objects. For example, to rename MY_OBJECT to + WHAT_A_SILLY_NAME, use the command: + +

+         dat myfile.dat my_object NAME=what_a_silly_name
+
+ +

+ You can use the wildcard * to apply the property to everything in the + file, so to remove the ORIG property from the entire datafile, you + could execute: + +

+         dat myfile.dat * ORIG=
+
+ +

+You can create hierarchical nested datafiles by inserting one datafile into +another with the '-a' command. Objects in the nested datafile can then be +referred to by as "parentname/objectname". For example if the datafile +myfile.dat contains a nested datafile called nestedfile, which contains a +bitmap called thepicture, you could export the bitmap with the command: + +

+         dat myfile.dat -e nestedfile/thepicture -o output.pcx
+
+ + + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/dat2c.html b/lib/allegro/allegro-htmldocs-4.2.1/dat2c.html new file mode 100644 index 0000000..fe58fd9 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/dat2c.html @@ -0,0 +1,142 @@ + + +dat2c + + + + + +

+The dat2c utility +

+
+ +


+

Contents

+ + +

+

Introduction

+ + +


+The utility dat2c can be used in much the same way as dat2s, above, except +that it writes C code rather than assembler. This has the advantage that it +is portable - you can compile it anywhere you can use Allegro. + + + +


+

Commandline Options

+ + +


+Each option may appear only once. To specify which datafile to convert, +give the filename without a preceding option. + +

+--cfile, -o + Arguments: filename + +

+ Gives the name of the C source file to output. Won't add a .c + extension, even if you don't specify one. By default, dat2c will + write to stdout. + +

+--hfile, -h + Arguments: filename + +

+ Gives the name of the C header file to output. Won't add a .h + extension, even if you don't specify one. + +

+--prefix, -p + Arguments: prefix (must be a valid macro name) + +

+ If you specify a prefix, then this will be used when constructing a + macro name for each object in the datafile. This is the same as the + grabber; if you don't specify a prefix, the macro name is simply + <obj_name>, but if you do, then the macro name becomes + <prefix>_<obj_name> . + +

+--crlf, -C + Arguments: none + +

+ Forces the file to be output in CRLF (DOS) format. This is the + default on DOS/Windows platforms. + +

+--unix, -U + Arguments: none + +

+ Sets the output to be in Unix (LF only) text format. This is the + default on non-DOS non-Mac platforms. + +

+--mac, -M + Arguments: none + +

+ Sets the output to be in Macintosh (CR only) text format. This is + the default on Mac platforms. + +

+--global, -g + Arguments: none + +

+ Specifies that the objects should be globally visible (default is + for objects to be local to the compilation unit). If they are + globally visible, then you can refer to them in your code. + +

+--convert-compiled-sprites, -S + Arguments: none + +

+ (See note below for more info on compiled sprites). Tells dat2c to + convert any compiled sprite objects it finds into bitmap objects. + More a convenience feature for lazy people :-) + +

+--datafile-name, -n + Arguments: C identifier + +

+ By default, the datafile is exported as: + PREFIX_data + or data + But with this option, you can change 'data' to be something else. + + + +


+

Notes

+ +

+ - If your datafile contains truecolor images, be sure to call + fixup_datafile() after you have set the graphics mode. You must + also call fixup_datafile() if your platform does not support + constructors (currently any non GCC-based platform). + +

+ - Compiled sprites are *not* supported (but see the commandline option + --convert-compiled-sprites , above). This is because Allegro silently + switches to an RLE_SPRITE implementation on platforms which don't + support compiled sprites, and to get dat2c to implement that behaviour + would be more effort than it is worth (especially since you can just + call get_compiled_sprite() anyway!). + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/dat2s.html b/lib/allegro/allegro-htmldocs-4.2.1/dat2s.html new file mode 100644 index 0000000..3b754e7 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/dat2s.html @@ -0,0 +1,109 @@ + + +dat2s + + + + + +

+The dat2s utility +

+
+ + + +


+

Compiling Datafiles to Assembler

+ + +


+The utility dat2s can be used to convert a datafile into an asm (.s) source +file, which can then be assembled and linked into your program. This avoids +the need for a separate datafile to accompany your program, and means the +data will automatically be loaded into memory at startup. You should be +aware, though, that large datafiles can take a long time to compile, and +that it is not possible to compress data which is compiled in this way. + +

+The simplest way to invoke dat2s is with the command: + +

+ dat2s filename.dat -o output.s + +

+The resulting asm file can then be assembled with the command: + +

+ gcc -c output.s + +

+This will produce an object module called output.o, which can be linked into +your program, for example: + +

+ gcc myprog.c -o myprog.exe output.o -lalleg + +

+Your program can then access the contents of the datafile as simple global +variables. Definitions for these variables can be obtained by telling dat2s +to output a header file as well as the asm file, with the '-h' option. You +can also use '-p' to set a prefix string for all the object names. For +example, when applied to the datafile: + +

+ "BMP" - A_BITMAP + "BMP" - ANOTHER_BITMAP + "SAMP" - EXPLODE + "PAL" - SOME_COLORS + "FONT" - THE_FONT + +

+the command: + +

+ dat2s filename.dat -o output.s -h output.h -p item + +

+produces the header: + +

+ extern BITMAP item_a_bitmap; + extern BITMAP item_another_bitmap; + extern SAMPLE item_explode; + extern PALETTE item_some_colors; + extern FONT item_the_font; + extern DATAFILE item_data[]; + +

+You can refer to these objects directly, for example: + +

+ blit(&item_a_bitmap, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); + +

+Alternatively, you can use the datafile array for compatibility with code +that was originally written for separately loaded datafiles, with the +standard syntax item_data[index].dat. + +

+If your datafile contains truecolor images, be sure to call fixup_datafile() +after you have set the graphics mode. You must also call fixup_datafile() +if your platform does not support constructors (currently any non GCC-based +platform). + +

+Note that compiled sprites are not supported and will cause dat2s to +abort whenever it encounters one of them. However you can use the '-S' +option to instruct dat2s to convert them to regular BITMAP objects. + +

+Note that datafiles compiled by dat2s must not be appended to shared objects, +only to standalone executables. Use dat2c for this purpose. + + + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/datafile.html b/lib/allegro/allegro-htmldocs-4.2.1/datafile.html new file mode 100644 index 0000000..ef44d5d --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/datafile.html @@ -0,0 +1,333 @@ + + +Datafile format + + + + + +

+Datafiles format information. +

+
+ + +


+

Contents

+ +

+

+ + + +


+

Introduction

+ +

+An Allegro datafile is a bit like a zip file in that it consists of lots of +different pieces of data stuck together one after another, and optionally +compressed. This means that your game doesn't have to clutter up the disk +with hundreds of tiny files, and it makes programming easier because you can +load everything with a single function call at program startup. Another +benefit is that the LZSS file compression algorithm works much better with +one large file than with many small ones. + +

+Datafiles have the extension .dat, and can be created and edited with the +graphical grabber program or the command line dat utility. They can be +stored as separate files and loaded into memory by the load_datafile() +function, or you can use dat2s to convert them into asm code which can then +be linked directly into your executable. + +

+

Objects

+ +

+Each datafile contains a number of objects, of varying types. Object types +are represented by 32 bit integer ID's, which are interpreted as four +character ASCII strings. These ID's can be constructed with the DAT_ID() +macro, for example a DATA object is represented by DAT_ID('D','A','T','A'), +or you can use the predefined DAT_* constants for the standard data types: + +

+

+ +

+

Properties

+ +

+Each object can have any number of properties attached to it. These are +ASCII strings describing attributes of the object, such as its name and +where it came from. Like the objects themselves, properties are identified +by 32 bit integer ID's which are constructed from four character strings by +the DAT_ID() macro. Allegro defines the standard properties: + +

+

+ +

+You can use whatever other ID's you like to store custom information about +your objects (the grabber internally use some other properties stored in a +hidden DAT_INFO object, so they won't conflict with yours). + + + +


+

File format specification

+ +

+In case anyone wants to do some serious hackery, and for my own future +reference, here are some details of the innards of the datafile format. + +

+Note that this is different to the datafile format used by Allegro versions +2.1 and earlier. Allegro can still load files from the old format, but it +was much less flexible and didn't support nice things like object +properties, so you should load any old files into the grabber and save them +out again to convert to the new format. + +

+Nb. if all you want to do is write a utility that manipulates datafiles in +some way, the easiest approach is probably to use the helper functions in +datedit.c, which are currently shared by the dat, dat2s, and grabber +programs. These functions handle loading, saving, inserting and deleting +objects, and modifying the contents of datafiles in various ways, but life +is too short for me to bother documenting them all here. Look at the +source... + +

+Anyway. All numbers are stored in big-endian (Motorola) format. All text is +stored in UTF-8 encoding. A datafile begins with one of the 32 bit values +F_PACK_MAGIC or F_NOPACK_MAGIC, which are defined in allegro.h. If it starts +with F_PACK_MAGIC the rest of the file is compressed with the LZSS +algorithm, otherwise it is uncompressed. This magic number and optional +decompression can be handled automatically by using the packfile functions +and opening the file in F_READ_PACKED mode. After this comes the 32 bit +value DAT_MAGIC, followed by the number of objects in the root datafile (not +including objects nested inside child datafiles), followed by each of those +objects in turn. + +

+Each object is in the format: + +

+   OBJECT =
+      var    - <property list>      - any properties relating to the object
+      32 bit - <type ID>            - object type ID
+      32 bit - <compressed size>    - size of the raw data in the file
+      32 bit - <uncompressed size>  - see below
+      var    - <data>               - the contents of the object
+
+ +

+The property list can contain zero or more object properties, in the form: + +

+   PROPERTY =
+      32 bit - <magic>              - "prop"
+      32 bit - <type ID>            - property type ID
+      32 bit - <size>               - size of the property string, in bytes
+      var    - <data>               - property string, _not_ null-terminated
+
+ +

+If the uncompressed size field in an object is positive, the contents of the +object are not compressed (ie. the raw and compressed sizes should be the +same). If the uncompressed size is negative, the object is LZSS compressed, +and will expand into -<uncompressed size> bytes of data. The easiest way to +handle this is to use the pack_fopen_chunk() function to read both the raw +and compressed sizes and the contents of the object. + +

+The contents of an object vary depending on the type. Allegro defines the +standard types: + +

+   DAT_FILE =
+      32 bit - <object count>       - number of objects in the sub-file
+      var    - <object list>        - objects in the same format as above
+
+   DAT_FONT =
+      16 bit - <font size>          - 8, 16, -1, or 0
+
+      if font size == 8 {           - obsolete as of version 3.9.x!
+         unsigned char[95][8]       - 8x8 bit-packed font data
+      }
+
+      if font size == 16 {          - obsolete as of version 3.9.x!
+         unsigned char[95][16]      - 8x16 bit-packed font data
+      }
+
+      if font size == -1 {          - obsolete as of version 3.9.x!
+         95x {
+            16 bit - <width>        - character width
+            16 bit - <height>       - character height
+            var    - <data>         - character data (8 bit pixels)
+         }
+      }
+
+      if font size == 0 {           - new format introduced in version 3.9.x
+         16 bit - <ranges>          - number of character ranges
+         for each range {
+            8 bit  - <mono>         - 1 or 8 bit format flag
+            32 bit - <start>        - first character in range
+            32 bit - <end>          - last character in range (inclusive)
+            for each character {
+               16 bit - <width>     - character width
+               16 bit - <height>    - character height
+               var    - <data>      - character data
+            }
+         } 
+      }
+
+   DAT_SAMP =
+      16 bit - <bits>               - sample bits (negative for stereo)
+      16 bit - <freq>               - sample frequency
+      32 bit - <length>             - sample length
+      var    - <data>               - sample data
+
+   DAT_MIDI =
+      16 bit - <divisions>          - MIDI beat divisions
+      32x {
+         32 bit - <length>          - track length, in bytes
+         var    - <data>            - MIDI track data
+      }
+
+   DAT_FLI =
+      var - <data>                  - FLI or FLC animation, standard format
+
+   DAT_BITMAP =
+   DAT_C_SPRITE =
+   DAT_XC_SPRITE =
+      16 bit - <bits>               - bitmap color depth
+      16 bit - <width>              - bitmap width
+      16 bit - <height>             - bitmap height
+      var    - <data>               - bitmap data
+
+      Valid color depths are 8, 15, 16, 24, 32, and -32. Both 15 and 16 bit 
+      images are stored in 5.6.5 RGB format, and 24 and 32 bit images as 
+      8.8.8 RGB. The special -32 flag indicates that the data is in true 32 
+      bit RGBA format.
+
+   DAT_RLE_SPRITE =
+      16 bit - <bits>               - sprite color depth
+      16 bit - <width>              - sprite width
+      16 bit - <height>             - sprite height
+      32 bit - <size>               - data size, in bytes
+      var    - <data>               - RLE compressed sprite data
+
+      Valid color depths are 8, 15, 16, 24, 32. and -32. Both 15 and 16 bit 
+      images are stored in 5.6.5 RGB format with 16 bit skip counts and EOL 
+      markers, and 24 and 32 bit images as 8.8.8 RGB. with 32 bit skip 
+      counts and markers. The special -32 flag indicates that the data is in 
+      true 32 bit RGBA format.
+
+   DAT_PALETTE =
+      256 x {
+         8 bit - <red>              - red component, 0-63
+         8 bit - <green>            - green component, 0-63
+         8 bit - <blue>             - blue component, 0-63
+         8 bit - <pad>              - alignment padding
+      }
+
+ +

+I think that covers everything. + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/faq.html b/lib/allegro/allegro-htmldocs-4.2.1/faq.html new file mode 100644 index 0000000..149ec9d --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/faq.html @@ -0,0 +1,1077 @@ + + +Allegro FAQ + + + + +

+The Allegro FAQ
+If the answer isn't here, ask and it will be added...

+
+

+

Contents

+ +

+

+ + + +


+

Trivial problems

+ +
+


+

What is Allegro?

+ See readme.txt. + + +


+

Where can I get it?

+ From any SimTel mirror (http://alleg.sourceforge.net/mirrors.html), in + the directory gnu/djgpp/v2tk/, or from the Allegro homepage, + http://alleg.sourceforge.net/. + + +


+

How do I use it?

+ See allegro.txt. +
+ + + +


+

The giftware licence

+ +

+ The Allegro licence is absolutely clear unless you are a lawyer. + However, it's written quite informally so this mini-FAQ tries to clarify + some things. + +

+


+

Does the licence mean that Allegro is public domain?

+ No. Every Allegro contributor holds the copyright for the code he or + she wrote. This means he or she grants you the right to use it for + any purpose you want. But the fact that the contributor holds the + copyright means that you e.g. cannot claim that you wrote the code. + +


+

Can I use Allegro for commercial purposes?

+ Yes. + +


+

Is Allegro compatible with licence XXX (e.g. GPL)?

+ Because the Allegro licence has no restrictions on use you can combine + it with any licence you want. + +


+

Is Allegro open source (OSI) compatible?

+ See the previous question. Since Allegro is compatible with about any + license, it also is OSI compatible. It clearly is compatible with all the + points in the OSD (open source definition). You can search the OSI + mailing list for "Allegro" to see that OSI shares this view. (OSI + officials still were reluctant to consider it for approval though and + suggested to use an existing license like MIT instead.) + +


+

How are modifications of the library licensed?

+ You can modify Allegro and distribute the modified Allegro under + any licence you want, but the original unmodified parts will still + be licenced under the Allegro licence. If you offer your + modifications to be included in the official Allegro distribution + (e.g. by sending them to the Allegro developers mailing list) you + automatically agree with licencing the modification under the + Allegro licence. + +


+

I took your code. Will you sue me? + Your library destroyed my PC. Who do I sue?

+ We are programmers not lawyers. This FAQ represents our current + understanding of copyright law (or copyright laws in different + countries). But given the license, which allows everything, and + the disclaimer, which says we take no responsibility for anything, + we really don't see how there could be any problems. +
+ + + +


+

DJGPP problems

+ +
+


+

What is this make program that I'm supposed to run?

+ Make is part of the standard djgpp distribution, in the file + v2gnu/mak*b.zip (whatever the latest version number is). + You can get this from http://www.delorie.com/djgpp/. + + +


+

Make doesn't work properly.

+ Are you sure that you have installed djgpp correctly? Check the + instructions in the djgpp readme.1st file, and in particular confirm + that you have set the DJGPP environment variable and added the + djgpp\bin directory to your path. + + +


+

My djgpp installation is fine, but make still doesn't work properly.

+ Are you sure that you are using the GNU make program, and not some + other version like the Borland one? If in doubt, run make -v and + check that the GNU copyright message is displayed. + + +


+

When I run make, it asks me for some parameters. What do I type?

+ You shouldn't be running make from the Win95 explorer! Bring up a DOS + box, change to your Allegro directory, and type make at the command + prompt. + + +


+

When I run make, it says "makefile has modification time in the future".

+ Are you sure that your system time and date are set correctly? + Alternatively you may have downloaded a fresh file made by someone in a + more eastern timezone. In the latter case you can either wait a few + hours, temporarily set your clock forward, or use a utility such as + touch to change the timestamp of the files. + + +


+

When I run make, it says "virtual memory exhausted".

+ +

+ As the error message suggests, you need to provide more memory for the + compiler to use. The go32-v2 program will tell you how much is + currently available. If you are running under DOS, try to free up more + disk space for use as a swapfile. When using win95, increase the DPMI + memory limit in the properties for your DOS session to 65535 (you'll + have to type this in by hand, because the pulldown list doesn't go + above 16384). + + +


+

When I run make, it says "conflicting types for va_list".

+ +

+ As the error message suggests, there is a conflict between newer + versions of gcc and older versions of the libc. You must upgrade your + djdevxxx.zip package to the latest update (timestamp 11 August 2002) + of DJGPP-2.03 or above. + + +


+

When I try to compile a program using Allegro, I get lots of errors like:

+ C:\TEMP\ccdaaaaa(.text+0x9):x.c: undefined reference to `allegro_init'
+ C:\TEMP\ccdaaaaa(.text+0xe):x.c: undefined reference to `install_keyboard'
+ +

+ You haven't read the docs, have you? :-) You need to link your program + with the library file, liballeg.a. First, make sure you have installed + everything properly (running make install should do this for you). + Second, if you are compiling from the command prompt or with a makefile, + add -lalleg to the end of your gcc command line, or if you are using Rhide, + go to the Options/Libraries menu, type alleg into the first empty field, + and make sure the box next to it is checked. + + +


+

I give up: I can't compile this! Can you send me a precompiled version?

+ +

+ No, sorry. For starters, liballeg.a is about 450k, but you'd probably + also want various utilities like the grabber, sound setup, etc. And + what about all the example programs? If we included compiled versions + of everything, a binary distribution would be over 7 megs: way too big + to be practical! More seriously though, there just isn't any reason + why you can't build it yourself. A compiler is a deterministic + process: given a particular input file and command line, it will always + produce the same output. If this isn't working, you either have the + wrong input files (ie. your copy of Allegro is broken in some way), or + the wrong command line (it is hard to see how that could happen, since + all you have to do is type make...) or your compiler is broken, ie. you + didn't install djgpp properly. You need to find and fix the problem, + not just sweep it under the carpet by getting someone else to compile + Allegro for you... + + +


+

Compile errors scroll off the screen too quickly for me to read them!

+ +

+ GNU tools write their error messages to the error stream, stderr. + Unfortunately command.com is too stupid to know how to redirect this, + but fortunately DJ was smart enough to work around that, so you can + use his redir program to capture the output messages, for example +

+         redir -eo make > logfile.txt
+      
+
+ + +


+

DOS problems

+ +
+


+

Does the DOS version of Allegro work under Windows NT?

+ +

+ Your mileage may vary. Some people have reported problems, while + others say that it works fine. Use the Windows version of Allegro + if you want to make Windows programs. If you want to run DOS + programs, use DOS! + + +


+

Does Allegro work under OpenDOS?

+ +

+ Yes, but with some caveats. If you are using the OpenDOS version of + EMM386, you must disable their DPMI implementation (specify DPMI=OFF + on the EMM386.EXE device line in your config.sys). You should also + make sure the PIC=OFF flag is set, but this is the default so it won't + be a problem unless you have specifically enabled it. + + +


+

How can I extend the 256k limit on Mode-X video memory? + I have two megs in my card.

+ +

+ You can't. The limit is imposed by the VGA hardware, not by Allegro. + To access more than 256k of video memory you need to use an SVGA mode, + which means either switching to a higher resolution or getting a copy + of the SciTech Display Doctor, which provides several low resolution + SVGA modes. + + +


+

Does DOS Allegro work with the SB-Live soundcard?

+ +

+ It does for some people, but not for others. The problem is that + Creative Labs refuse to release any specs, so we don't know how to + write a driver for it. Complain to them, or buy a different card from + a more reasonable manufacturer. + + +


+

Why does DOS Allegro play sounds so much quieter than in Windows?

+ +

+ This might be because you have the volume set very low: try changing + this in the setup program. Also, Allegro is mixing several sounds into + a single output buffer, unlike the Windows sound player that only + plays one sample at a time, so each individual sound can only get a + smaller percentage of the total output volume. This is just the price + you pay for multiple output channels. If you don't like it, use the + setup program to tweak the number of channels: this can be any power + of two less than or equal to 64, and the smaller you make it, the + louder the sound will be. Alternatively, use set_volume_per_voice(), + described in the docs. This will enable you to adjust the overall + volume of Allegro's digital sound output. + + +


+

Why doesn't it work with my video card?

+ +

+ Try using a FreeBE/AF driver (http://www.talula.demon.co.uk/freebe/), + or the commercial SciTech Display Doctor (http://www.scitechsoft.com). + If it still doesn't work, post a description of your problem to the + Allegro mailing list, along with a copy of the output from running the + afinfo and vesainfo programs. + + +


+

Why not use some sort of dynamic linking system?

+ +

+ The VBE/AF interface already provides this for the video drivers: see + the FreeBE/AF project on http://www.talula.demon.co.uk/freebe/. + For more general things like the sound, VESA, and mode-X routines, + this would be very difficult to do because the drivers depend on a lot + of helper functions from the core lib. The djgpp DXE format is nowhere + near flexible enough to support this, and we don't want to make Allegro + dependent on any other dynamic linking packages. + + +


+

I get an "out of environment space" error when I run fix.bat or + vcvars32.bat!

+ +

+ Well duh, you need to increase the size of your environment then :-) + You can do this by changing the settings for your DOS box (click the + system menu and select "properties"), or at startup in your config.sys + file (eg. shell=c:\command.com /e:8192 /p). +

+ + +


+

Windows problems

+ +
+


+

I get an "out of environment space" error when I run fix.bat or + vcvars32.bat!

+ +

+ Well duh, you need to increase the size of your environment then :-) + You can do this by changing the settings for your DOS box (click the + system menu and select "properties"), or at startup in your config.sys + file (eg. shell=c:\command.com /e:8192 /p). + + +


+

When I run make, it says "missing separator".

+ +

+ Make sure that you don't have a semi-colon appended to your MSVCDIR + variable if you are using MSVC, to your MINGDIR variable if you are + using MinGW or to your BCC32DIR variable if you are using BCC. + Also run make -v from the command line and make sure you are using + GNU make and not Borland make or Microsoft make. + + +


+

I get lots of compile errors about things like "LPDIRECTDRAWSURFACE2"!

+ +

+ You need to tell your compiler how to find the DirectX include files + and libraries: put the DirectX SDK /include and /lib directories in the + compiler/linker path. Alternatively, if you don't want to modify any + configuration stuff, you can simply copy the files from the DirectX SDK + /include and /lib directories to the corresponding ones for your + compiler. + + +


+

I get lots of compile errors about things like "DDEDM_STANDARDVGAMODES"!

+ +

+ You need to upgrade to a more recent version of the DirectX SDK, at + least version 5, which you can get from the Microsoft Developer site. + + +


+

When I run make, it says "windres: no resources".

+ +

+ If an anti-virus software (Norton or McAfee for example) is running in + the background on your computer, try to disable it temporarily. + + +


+

I get an error about a missing WinMain() or main() function!

+ +

+ You need to write END_OF_MAIN() just after your main() function. + Allegro uses this, along with some preprocessor magic, to turn a normal + main() function into a Windows-style WinMain() entry point. + + +


+

I get an error about an "unresolved external symbol _main"!

+ +

+ Make sure you're building a Windows GUI Application, and not a Windows + Console Application. This is a setting when you create the project in + MSVC, Dev-C++ or Borland C++ Builder. Alternatively, this is specified + on the command line by the -subsystem:windows option for the MSVC + linker, by the -Wl,--subsystem,windows option for the MinGW compiler + or the -tW option for the Borland C++ compiler. Either that, or define + the preprocessor symbol ALLEGRO_USE_CONSOLE prior to including Allegro + headers if you really need the console for your program. + + +


+

I get lots of compile errors about conflicting types for "struct BITMAP"!

+ +

+ If your program directly includes Win32 API header files, see the + "Windows specifics" section of the documentation. +

+

+ If your program only includes header files of the C++ standard library, + you're very likely trying to compile it with gcc 3.x for MinGW; if so, + define the symbol __GTHREAD_HIDE_WIN32API on the compiler command line: +

+         g++ -D__GTHREAD_HIDE_WIN32API program.cpp -lalleg
+      
+ + +


+

In windowed mode artifacts are left on the desktop when the window + is moved or when another window is placed on top of it.

+ +

+ Disable direct updating for the DirectX windowed driver by using the + dedicated configuration variable. See the 'Configuration routines' + section in the docs and the allegro.cfg template file for more + detailed informations. + + +


+

In windowed mode the screen stays black unless the window is placed + under another window on the desktop.

+ +

+ Disable direct updating for the DirectX windowed driver by using the + dedicated configuration variable. See the 'Configuration routines' + section in the docs and the allegro.cfg template file for more + detailed informations. +

+ + +


+

Unix problems

+ +
+


+

I get an error about "_mangled_main_address" being undefined!

+ +

+ You need to write END_OF_MAIN() just after your main() function. + Allegro uses this, along with some preprocessor magic, to get a copy + of your argv[] parameters (it needs those for various internal things). + + +


+

I get an error about a duplicate definition of the "_main" symbol!

+ +

+ You are probably on a Darwin/MacOS X system. If so, make sure the symbol + USE_CONSOLE is not defined in your program: it is a deprecated symbol + that must be replaced by ALLEGRO_USE_CONSOLE. Also note that the magic + main can't be disabled on such a system: you simply can't define the + symbol ALLEGRO_NO_MAGIC_MAIN in a program linked against Allegro. + + +


+

Compile errors scroll off the screen way too quickly for me to read them!

+ +

+ You need to redirect stderr into a file, so you can view them later. + The method for doing this depends on your shell: if you are using a + Bourne-style shell like bash, try make 2> logfile.txt + + +


+

When I try to run Allegro programs, I get "error while loading shared libraries: + liballeg.so.4.1: cannot open shared object file: No such file or directory".

+ +

+ You need to teach the dynamic linker where to find the Allegro shared library. + See docs/build/unix.txt, near the end of the 'Installing Allegro' section. + + +


+

When I try to use DGA2, I get "resolution not supported", but the + X server does actually support that resolution !

+ +

+ There are two possible reasons: + 1) DGA2 may support different resolutions/color depths than X, + run the gfxinfo program to know what combinations you can use, + 2) You may have a buggy DGA2 implementation, see next question. + + +


+

When I try to use DGA2, the screen goes black and the PC completely + halts!

+ +

+ You are probably using a XFree86 server with a very buggy DGA2 + implementation, such as 4.0.3 (shipped with Red Hat 7.1 for example). + Upgrading to 4.1.0 will probably solve your problem. You can obtain + it from ftp://ftp.xfree86.org/pub/XFree86/4.1.0/binaries/ selecting + the directory suited to your platform and following the instructions + you find in the Install file. +

+ + +


+

General problems

+ +
+


+

I'm trying to compile the grabber, but it doesn't work!

+ +

+ The grabber needs to be linked with the code in datedit.c. But you + shouldn't have to worry about doing this by hand: just run make and + that will build everything for you. + + +


+

When I compile Allegro, make fails with something like `Error: operands + given don't match any known 386 instruction' or `Error: no such + instruction `maskmovq %mm3, %mm1''.

+ +

+ You need to update your version of GNU binutils. See readme.txt to + find out what the minimum required version you need is. + + +


+

Can I use Allegro with my <foobar> compiler?

+ +

+ Not unless <foobar> is mentioned in readme.txt as one of the + supported platforms. You could port it, but that is usually a lot of + work. If <foobar> is a 16 bit DOS compiler like Borland C, you + might as well just forget the idea :-) + + +


+

What is this "Allegro WIP" that I see people talking about?

+ +

+ WIP stands for "work in progress", and refers to any changes that are + more recent than the last official release. WIP versions of the + library can be obtained as patches from the Allegro website + (http://alleg.sourceforge.net/), and are usually + quite stable, although obviously not so well tested as a final release + version. + + +


+

I got the WIP patch, but I can't apply it.

+ +

+ Do you have a copy of patch.exe? If not, go and get it from the same + place that you downloaded the rest of djgpp: this tool is a standard + part of the compiler distribution. Similarly, you can get the Mingw + compiled version from http://sourceforge.net/projects/gnuwin32/. +

+

+ If you do have the patch program but it isn't working properly, make + sure that you are installing the patch over the top of an unmodified + copy of whatever Allegro version it is intended to update (this will + usually be the most recent official release from before the WIP was + made, but check the text file that comes with the WIP to be sure). + + +


+

When I run the demo game, it says it can't find demo.dat.

+ +

+ That file is distributed separately in the WIP versions. It is here: + http://alleg.sourceforge.net/wip.html. (alldata.zip) + + +


+

How can I display several different images at the same time? + When I show the second one it messes up the palette for the first.

+ +

+ This is just the way that the video hardware works: there can only be + one palette in use at any given moment. Either convert your images so + they all use the same palette, or switch to a truecolor graphics mode. + + +


+

How can I convert my graphics to all use the same 256 color palette?

+ +

+ See the Allegro.cc homepage (http://www.allegro.cc/) + for some utilities, for example FixPal and Smacker. + + +


+

My colors always come out wrong. And how can I make a greyscale palette + with 256 different shades?

+ +

+ The VGA hardware only uses 6 bits for each color component, which + means the red, green, and blue values in the palette structure range + from 0 to 63, not all the way up to 255. That gives you a potential + 2^18 = 262144 different colors, or 64 shades of grey. If you need more + than this you could try using VESA function 0x4F08 to select an 8 bit + wide DAC, but Allegro doesn't support this directly and I don't know + how reliable it will be across different hardware. + + +


+

Why do I have a funny color border at the edges of my monitor?

+ +

+ When you are in a 256 color mode, the VGA card displays color #0 + around the border of the display area (in truecolor modes it displays + black). Your funny color will go away if you change the palette so + that color #0 is black. + + +


+

How can I fade the screen in a truecolor graphics mode?

+ +

+ With great difficulty :-) There is no such easy trick as just altering + the palette, so you will have to repeatedly redraw the image in a + lighter or darker form. You could draw black translucent rectangles + over the screen to darken it down, or use draw_lit_sprite() to tint a + bitmap while copying it to the screen, but be warned that these + operations are expensive and will require a fast PC! +

+

+ Also, have a look at http://www.allegro.cc/ for add-on packages + (notably FBlend v0.5) that attempt to make this operation as fast as + possible. + + +


+

I tried using fade_in() and fade_out() with truecolor modes but nothing + happened. What am I doing wrong?

+ +

+ fade_in() and fade_out() only work in 8-bit paletted modes. + See the previous question for details. + + +


+

How can I generate FLI or FLC format animations?

+ +

+ See the Allegro.cc homepage (http://www.allegro.cc/) + for some utilities, for example DTA and Smacker. Also, you can use ASE + (Allegro Sprite Editor, http://ase.sourceforge.net/), which allows + drawing/editing each frame of the animation and save it as a FLI. Or + you can use The GIMP (http://www.gimp.org/) along with it's GFli + plugin, using layers as frames, and saving your work as file.fli. + The GIMP allows you to edit existent FLI files too. + + +


+

How can I make parts of my sprite transparent in truecolor modes? + I don't understand what the docs mean by "bright pink"...

+ +

+ In your favourite paint program, get hold of the RGB sliders and drag + the red and blue ones up as far as they go (usually to 255, but this + will depend on what units your software uses), and the green one right + down to zero. The result is a special shade of Magic Pink, or as some + people prefer to call it, magenta. + + +


+

I can't get the 3D polygon functions to work!

+ +

+ Remember that the vertex positions are stored in fixed point format, + so you must use the itofix() macro or shift your coordinates 16 bits + to the left. + + +


+

I can't get the rotate_sprite() function to work!

+ +

+ Remember that the angle of rotation is stored in fixed point format, + so you must use the itofix() macro or shift your coordinates 16 bits + to the left. For example, rotate_sprite(bmp, spr, x, y, itofix(32)) + will rotate the graphic by 45 degrees. + + +


+

I can't get the d_bitmap_proc() or d_icon_proc() GUI object to work!

+ +

+ You are probably trying to initialise the dialog structure with a + pointer to your bitmap, right? That won't work because the dialog is + created at compile time, but the bitmap is only loaded at runtime, so + the compiler doesn't yet know where it will be located. You need to + fill in the dialog structure with a NULL pointer, and then copy the + real bitmap pointer into the dp field as part of your program init + code, after you've loaded the bitmap into memory. + + +


+

Should I use regular bitmaps, RLE sprites, or compiled sprites?

+ +

+ It depends on exactly what you are doing. If your images are totally + opaque, there is no advantage to using an RLE sprite, and it will + probably be faster to use a regular bitmap with the blit() function. + If your graphics contain masked areas, an RLE sprite may be both smaller + and faster than the draw_sprite() function, depending on your CPU + and your bitmaps. + Compiled sprites are in general quite a bit faster than both the + others for masked images, and slightly faster for opaque graphics, but + this is far more variable. They are at their best with small sprites, + on older machines and in mode-X, and may actually be slower than + blit() when using SVGA modes on a pentium (the large size of a + compiled sprite is very bad for the cache performance). + + +


+

How can I make my game run at the same speed on any computer?

+ +

+ You need to make sure the game logic gets updated at a regular rate, + but skip the screen refresh every now and then if the computer is too + slow to keep up. This can be done by installing a timer handler that + will increment a global variable at your game logic speed, eg: +

+      volatile int speed_counter = 0;
+
+      void increment_speed_counter()
+      {
+         speed_counter++;
+      }
+
+      END_OF_FUNCTION(increment_speed_counter)
+
+      void play_the_game()
+      {
+         LOCK_VARIABLE(speed_counter);
+         LOCK_FUNCTION(increment_speed_counter);
+
+         install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));
+
+         while (!game_over) {
+            while (speed_counter > 0) {
+               update_game_logic();
+               speed_counter--;
+            }
+
+            update_display();
+         }
+      }
+ + +


+

How can I take a screenshot of my Allegro program?

+ +

+ Add a call to save_bitmap() somewhere in your code. See the + save_bitmap() documentation for a discussion of one common pitfall + when doing this, and some example code. + + +


+

How can I generate a random number?

+ +

+ Call srand(time(NULL)) at the beginning of your program, and then use + rand()%limit to obtain a pseudo-random number between 0 and limit-1. + + +


+

Why not make a "lite" version of Allegro? + I don't need any of the sound, maths, or GUI routines...

+ +

+ There is no need. The linker will only include the parts of the + library that you actually use, so if you don't call any of, say, the + texture mapping or FLIC playing functions, they will be left out of + your executable. This doesn't work perfectly because a lot of the + Allegro code uses tables of function pointers that cause some + unnecessary routines to be linked in, so the majority of the graphics + functions will be included in every executable, but I have tried to + keep this to a minimum. See allegro.txt for information about more + precise ways to remove some of the graphics and sound drivers. + + +


+

Will you ever add support for 3D accelerator hardware?

+ +

+ No. This sort of hardware support would be most useful as part of a + proper 3D API, which Allegro is not, and will never be. If you want + to do some work on this, the MESA library (a free implementation + of OpenGL) is IMHO the place to start. +

+

+ However, if you are interested in using OpenGL for graphics and Allegro + for everything else, you can try the various add-ons libraries linked + from http://www.allegro.cc/ such as AllegroGL. + + +


+

Why not add a MOD playing function?

+ +

+ Several very good ones already exist, for instance the JGMOD or DUMB + packages. See the audio library extensions section on the Allegro.cc + website (http://www.allegro.cc/). You are not allowed to suggest + that one of these libraries be merged into Allegro, because this topic + has already been done to death on the mailing list and we are tired of it. + + +


+

Why not add networking support?

+ +

+ There are several networking packages currently in development or + floating around on the net, though, and in our opinion this sort of + code is more useful as an external library than it would be as part of + Allegro. + + +


+

Why can't Allegro read GIF files?

+ +

+ Unisys has a patent on the LZW compression algorithm that is used by + the GIF format. We want everything in Allegro to be freely usable + without any restrictions whatsoever, which means we can't include any + code that is subject to licensing or the payment of royalties. + + +


+

My program crashes all the time. Could this be a bug in Allegro?

+ +

+ Perhaps. Try to isolate the smallest fragment of code that is able to + reproduce the problem, and we'll have a look at it. If you can send us + a 10 line program, we will fix it. 100 lines, and we can probably fix + it. 1000 lines, and we don't have a chance :-) + + +


+

Can I use Allegro in my <whatever> commercial application?

+ +

+ Sure. See the giftware terms in readme.txt. We don't mind what you do + with it, and there are no problems with commercial usage. + + +


+

When will <foobar> be finished? I can't wait...

+ +

+ Whenever it is done! A little encouragement is always welcome, but we + don't have any completion deadlines and we're not going to make one up + for you :-) As soon as it is finished, it will be released. + + +


+

Where can I get some fonts to use with Allegro?

+ +

+ The grabber can import directly from GRX or BIOS format .fnt files, or + you can draw them onto a .pcx image using any paint program. See + http://www.talula.demon.co.uk/ttf2pcx/ for a utility that + will convert Windows TrueType fonts into this .pcx format. + + +


+

Where can I find a set of instrument samples for the DIGMID driver?

+ +

+ See the Allegro homepage (http://alleg.sourceforge.net/) + for some links. You can use Gravis patches (.pat format), or SoundFont + 2.0 (.sf2) files, but the latter must be converted into a patches.dat + file with the pat2dat utility. + + +


+

How can I convert the documentation into Windows Help format?

+ +

+ You need to download the makertf conversion utility + (ftp://ftp.coast.net/Coast/win3/winhelp/mkrtf104.zip), and the Windows + Help compiler (ftp://ftp.microsoft.com/Softlib/MSLFILES/HC505.EXE). + Make a temporary directory, copy the allegro.txi file from the + allegro/docs dir, and run the commands makertf --no-warn allegro.txi + -o allegro.rtf -J allegro.hpj followed by hcp allegro.hpj. The + second command will give a lot of warnings, but they can safely be + ignored. + + +


+

How can I print out the documentation?

+ +

+ The allegro.rtf file can be read directly into Microsoft Word and + printed from there, but you should right-click and update the table of + contents and index fields to fill them with the correct data first. + Alternatively you can install the TeX package and use the tex and + dvips programs to convert allegro.txi into Postscript format. + + +


+

Where can I find example source code, add-on packages, and tutorials?

+ +

+ Check the Allegro.cc homepage, http://www.allegro.cc/. + If you have anything to add to this, please post the URL! + + +


+

Why is it considered good coding practice to define PI as a constant, + rather than just using the value 3.141592 in my code?

+ +

+ It simplifies the maintenance of your program, in case the value of PI + ever needs to be changed. Also it will make your program more portable + to other compilers that use different values of PI. + + +


+

Why doesn't vsync() seem to work?

+ +

+ A number of graphics cards have buggy or incomplete VESA + implementations, and often the vsync() function is not implemented. For + examples on flicker-free drawing, look at the code for the demo game, + which uses a variety of methods to draw itself. + + +


+

Why doesn't busy waiting on the key array work? For example, + "while (!key[KEY_ENTER]);" doesn't work.

+ +

+ If the code works without optimisations, then it could be the + compiler's fault. You can try beating the compiler into submission, + for example: +

+      while (!key[KEY_ENTER])
+         rest(0);
+ +

+ For this case, however, it would be better to use readkey() instead. + Or consider upgrading or downgrading your compiler. + + +


+

I get lots of errors when I try to compile my C++ Allegro program.

+ +

+ You are probably declaring the use of a namespace before including + Allegro headers. For example: +

+      #include <iostream>
+      using namespace std;
+
+      #include <allegro.h>
+ +

+ Move the `using' declaration after the `include' directives referring + to Allegro headers: +

+      #include <iostream>
+      #include <allegro.h>
+
+      using namespace std;
+ + +


+

I'm still confused. Where can I get help?

+ +

+ See http://alleg.sourceforge.net/maillist.html. +

+ + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/grabber.html b/lib/allegro/allegro-htmldocs-4.2.1/grabber.html new file mode 100644 index 0000000..4d38060 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/grabber.html @@ -0,0 +1,343 @@ + + +grabber + + + + + +

+The grabber +

+
+ +


+

Contents

+ + +

+

Commandline options

+ +

+The grabber accepts a few different commandline options: + +

+ '-bpp' + Sets the color depth, eg. -8, -16, -32. + +

+ '-WxH' + Sets the screen resolution, eg. -320x200, -1024x768 + +

+ '-windowed' + Forces the grabber to start up in a window. + +

+ '-fullscreen' + Forces the grabber to start up in fullscreen mode. + +

+ '-nosound' + Disables audio output. + +

+ '-pkey' + Use 'key' as the datafile password. + +

+ 'filename.dat' + Loads the named datafile. + +

+

Using the grabber

+ +

+Various options can be set using the buttons and text fields at the top of +the screen. You can edit the name of the datafile, the name of the header +file for exporting object indexes (leave this blank if you don't want to +output a header), and the prefix string for the header file definitions. You +can change the grid settings for grabbing bitmaps, and alter the compression +mode (see below). You can enable or disable backups: if this box is checked, +the old version will be renamed to a .bak extension when datafiles are saved. +You can also turn dithering on (this can improve the image quality when you +reduce graphics from 15, 16, 24 or 32-bit color to 8-bit color and from 24 or +32-bit color to 15 or 16-bit color) and enable transparency preserving (this +will ensure that the masked areas in bitmaps stay exactly the same through +color conversion). + +

+The contents of the datafile are listed in the box at the bottom left of the +screen, and can be selected with the mouse or arrow keys. Multiple objects +can be selected by holding down the shift or control keys while you click +on the list or move the cursor. The selected object can be edited with +commands from the Object menu, or using the shortcut menu produced by +pressing Esc or right-clicking on an object. Double-clicking on an object +performs a function which varies depending on the type of the object. +Bitmaps are displayed full-screen (use the plus and minus keys to zoom in +and out), samples and MIDI files are played, palettes are selected (meaning +that they will be used when displaying and exporting bitmaps), and fonts can +be edited by adding and removing specific character ranges. + + + +


+

Modifying objects

+ +

+New objects can be created using the menus or by pressing Insert while the +item list has the input focus. To make nested datafiles, create a FILE +object (New/Datafile), and select it before inserting other objects. + +

+To insert information into a datafile you must first create an object of the +appropriate type, and then select the grab command (keyboard shortcut +ctrl+G). For most objects this will bring up a file selector for you to +select the file to read, but for graphic objects (bitmaps, RLE sprites, +compiled sprites, and palettes) it will grab from the current contents of +the image buffer, so you must previously have read a picture into this +buffer with the File/Read Bitmap command (keyboard shortcut ctrl+G). You can +use the mouse or arrow keys to select which portion of the image to grab. +With the mouse, select the top left corner, click and hold the left mouse +button, and move to the bottom right corner before releasing the button. +Press the right mouse button to cancel. With the keyboard, use the arrow +keys to select the top left corner, press Space or Enter, adjust the size +with the arrow keys, and press Space or Enter again. By default the position +will snap to a 16x16 grid, which can be adjusted by changing the values in +the X-grid and Y-grid fields. Alternatively you can use the Box Grab +command, in which case you should draw a bounding box in color #255 around +your sprites, and can then just click once inside a box to grab the contents. + +

+Note that palette data is not stored along with bitmap and sprite objects. +To store the entire contents of a PCX or BMP file, you will need to create +both bitmap and palette objects, and grab data into both of them. When you +reload the datafile the bitmap will probably be displayed with the wrong +palette. This can be corrected by double-clicking on the palette object, +which will select its contents as the current palette, meaning that it will +be used when displaying and exporting bitmaps. + +

+The properties of the selected object are listed in the box to the right of +the item list. These can be edited by double-clicking on one of the +properties, and deleted by selecting one and pressing Del. You can insert +new properties by pressing Insert while the property list has the input +focus, or using the Object/Set Property command. Object names are stored as +NAME properties, so the rename command is simply a shortcut for editing this +property. + + + +


+

Bitmap grabbing

+ +

+To simplify the process of grabbing several related images from a single +bitmap (for example a set of frames which form an animation), you can use +the File/Grab from Grid command. Like the normal bitmap grab command, this +uses data from the image buffer, so you must read in a bitmap before you use +it. You will then be able to adjust the grabbing parameters, enter a name +for the new objects, and choose the type of object to create (bitmap, RLE +sprite, or compiled sprite). Because several objects may be created, their +names will be formed by adding a number to the end of the name you supply, +for example if you enter "a_picture", the grabber will create the objects +"a_picture000", "a_picture001", etc. There are two grabbing modes: using +cutouts of color 255, and using a regular grid. The regular grid option +simply divides the bitmap up into a set of equally sized tiles, using the +specified grid size, and grabs each of these as a separate object. If you +set the Skip Empties flag, the grabber will ignore tiles that don't contain +any data (ie. those that are a single solid color). The color 255 option is +more flexible. It expects the bitmap to contain information describing the +position and size of each tile, in the form of a bounding box drawn in color +255. The most reliable way to do this is to fill all the image except the +parts you want with color 255, but the grabber should be able to understand +more complicated layouts, even if you simply draw color 255 lines along the +top and left edges of the area you want to be grabbed. For truecolor images +where color 255 is not particularly meaningful, use a cyan bounding box +(maximum blue and green, zero red), with a single yellow (maximum red and +green, zero blue) pixel in the top left corner of the box. + + + +


+

Configuration

+ +

+By default, the grabber will run in a 640x480 resolution, using the highest +color depth possible on your graphics card. If you want to override this, +you can specify an alternative color depth or resolution on the commandline, +eg. "grabber -8" for a 256 color mode, "grabber -16" for 16 bit hicolor +graphics, "grabber -320x200" to use VGA mode 13h, or "grabber 1024x768". +Warning: editing datafiles that contain truecolor graphics is very slow in +256 color video modes, and the grabber is not really usable in resolutions +lower than 640x400. + +

+You can configure the grabber to use external tools for editing data, by +setting some variables in the [grabber] section of the allegro.cfg file. +These are in the form "type=command", where the type is a four letter object +ID, and the command is whatever program you want to be invoked to edit this +kind of data. For these variables to be seen, the allegro.cfg file must +either be in the same directory as the grabber executable, or in the +directory pointed to by your ALLEGRO environment variable. To invoke this +feature, select the Shell Edit command or press ctrl+Z. The grabber will try +to invoke the tool on the original version of the file if it knows where you +grabbed the data from in the first place, or otherwise it will write the +object out into a temporary file prior to editing. + + + +


+

Saving datafiles

+ +

+Datafiles can be saved using any of three compression types, selected from +the list at the top right of the grabber screen, or with the '-c0', '-c1', +and '-c2' options to dat. With type 0, the data is not compressed at all. +Type 1 compresses each object individually, while type 2 uses global +compression over the entire file. As a rule, global compression will give +better results than per-object compression, but it should not be used if you +intend to dynamically load specific objects with the load_datafile_object() +function or "filename.dat#objectname" packfile syntax. + +

+There are also three strip modes for saving datafiles, selected with the +File/Save Stripped command in the grabber, or using the '-s0', '-s1', and +'-s2' options to dat. With zero stripping, all object properties are written +to the datafile, which is normally what you will want. With strip mode 1, +properties specific to the grabber (the ones describing the origins and +dates of each object) are removed, which will marginally reduce the file +size, but will prevent the update command from working. For the smallest +possible file sizes, strip mode 2 removes all properties, including object +names and any custom properties you have added. This level of stripping +should obviously be used with extreme caution, although in some cases it may +be possible to recover the object names even after they have been stripped +out of the datafile. If the grabber and dat utilities cannot find any name +properties in a datafile, they will look for a header (.h) file with the +same name, and attempt to parse this to recover the names. This is far from +foolproof, and will not work for nested datafiles, but in some situations +it allows the names to be read back from the index definition header. In +addition to those three strip modes, you can define properties to be kept, +whatever the strip mode. For example, if you want to strip all properties +but the NAME, this command will do the job: + +

+   dat -s2 -s-NAME file.dat
+
+ +

+The objects of the datafile can be sorted alphabetically by name. This is +selected by the Sort checkbox in the grabber, or by using the '-n0' and +'-n1' options to dat. With zero sorting, objects are listed in the order +they were added to the datafile. With sort level 1, they are listed in +alphabetical order according to their NAME property, including inside +nested datafiles. + + + +


+

Updating datafiles

+ +

+Both the grabber and the dat utility have an update command, which scans +through the datafile checking if any objects have changed, and replacing +those which are out of date. This depends on the origin and date properties +which were set when the data was grabbed in the first place, so it won't +work if these properties have been stripped out of the file. This command +can be very useful if you build a datafile containing hundreds of objects +grabbed from external bitmaps, and later go back and change some of these +bitmaps. Rather than having to figure out which objects are out of date and +then manually re-grab all the affected data, the update command will +automatically refresh the modified objects. + + + +


+

Fonts

+ +

+Fonts can be read from GRX format .fnt files, 8x8 or 8x16 BIOS format .fnt +files, and from bitmap images, or you can import a multiple-range Unicode +font by writing a .txt script that specifies a number of different source +files for each range of characters. The script file contains a number of +lines in the format "filename start end", which specify the source file for +that range of characters, the Unicode value of the first character in the +range, and the end character in the range (optional, if left out, the entire +input file will be grabbed). If the filename is replaced by a hyphen, more +characters will be grabbed from the previous input file. For example, the +script: + +

+   ascii.fnt 0x20 0x7F
+   - 0xA0 0xFF
+   dingbats.fnt 0x1000
+
+ +

+would import the first 96 characters from ascii.fnt as the range 0x20-0x7F, +the next 96 characters from ascii.fnt as the range 0xA0-0xFF, and the entire +contents of dingbats.fnt starting at Unicode position 0x1000. + +

+When reading a font from a bitmap file, the size of each character is +determined by the layout of the image, which should be a rectangular grid +containing all the ASCII characters from space (32) up to the tilde (126), +unless you are using the script mechanism described above, in which case the +range(s) should match the one(s) specified in the .txt file. The spaces +between each letter should be filled with color 255. If each character is +sized exactly 8x8 or 8x16 the grabber will create a fixed size font, +otherwise it will make a proportional font. Probably the easiest way +to get to grips with how this works is to load up the demo.dat file and +export the TITLE_FONT into a PCX file. Have a look at the resulting picture +in your paint program: that is the format a font should be in... + + + +


+

Alpha channel

+ +

+Bitmap and RLE sprites can store an alpha channel along with the color +information, as long as they are in a 32 bit format. Alpha data can be read +directly from 32 bit TGA files, or you can use the alpha channel commands +(in the Object menu, or the right mouse button popup menu) to import a +greyscale alpha image over the top of an existing object. This menu also +contains options for viewing the alpha channel of the selected object, +exporting the alpha data to a greyscale image file, and deleting the alpha +data to leave only pure color information. You can also use the File menu to +import an alpha channel over the top of a bitmap that you have loaded with +the Read Bitmap command, after which the alpha information will be included +when you next perform a Grab or Grab From Grid operation. + + + +


+

Datafile passwords

+ +

+Datafiles can be encrypted with a password, by typing it into the +"Password:" field in the grabber, or using the '-007 password' option to the +dat utility. Passwords may be up to 256 characters in length, and are case +sensitive. Encrypted files _cannot_ be read without the password, so please +don't forget it and then come crying to me for help :-) To read an encrypted +file into your program, call the packfile_password() function before +load_datafile(). It is also a good idea to call packfile_password(NULL) +afterwards, to set everything back to normal. + + + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/help.html b/lib/allegro/allegro-htmldocs-4.2.1/help.html new file mode 100644 index 0000000..784c8be --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/help.html @@ -0,0 +1,436 @@ + + +What to do when your Allegro program doesn't work + + + + +

+What to do when your Allegro program doesn't work +

+
+

+

Contents

+ +

+

+ + + +


+

Introduction

+ +

+ When things go wrong, it often seems like a good idea to ask other people + for help. Fortunately for people in this situation, there are many people + (both Allegro developers and users) who are happy to spend their time + answering support questions of this type, but there are various things + you can do to make this process work more efficiently. This document + describes some steps to take whenever you have a problem with an Allegro + program, suggesting ways that you can try to solve it yourself, and also + giving some tips about when/how to ask for help. Following these + guidelines will make life easier both for the helper (because all the + relevant information will be presented to them in a concise and useful + way), and for the helpee (because they are more likely to get a prompt + and accurate reply). + + + +


+

Part 1 - who is the culprit?

+ +

+ Is the problem a bug in Allegro, or in your code? To find out, try + running the Allegro test programs, in particular the test.exe (for + graphics related problems), the play.exe (for soundcard troubles), and + the entire contents of the examples directory (for anything that is going + wrong). If you can't reproduce the problem with any of these, it is + probably your fault, in which case you should skip to part 3 below. + +

+ If the problem is related to DOS graphics modes, you should start by + getting a copy of Display Doctor from http://www.scitechsoft.com/. + If this fixes the trouble, it almost certainly means that your original + VESA driver was broken in some way. I'm not interested in hearing reports + about problems of this type: there is nothing I can do to fix them, so + I'm afraid your only option is to get a better VESA driver, for instance + by downloading Display Doctor. This is now free for download from SciTech's + website, but there is no longer support for it. Alternatively, you can see + if there is a FreeBE/AF driver for your card (see + http://www.talula.demon.co.uk/freebe/). + +

+ For Windows graphics modes, you should probably check if DirectX is + installed properly on your system and if new drivers have been released for + your card. + + + +


+

Part 2 - when Allegro is at fault

+ +

+ If you still think the problem lies with Allegro, post a system report + containing a description of the problem, what platform and library + version you are using, your hardware specs, and a list of exactly which + programs you were able to reproduce the problem with (it is important to + know not only what programs had trouble, but also which ones worked + correctly, if any). + +

+ Try running the test.exe program with various display drivers (any native + drivers that you think might work with your card), and in various video + modes, and report exactly what modes and color depths cause problems. If + you are able to use any high resolutions at all, run test.exe with the + Autodetect option and report the entire text that it displays in the + middle of the screen. + +

+ If the problem is related to DOS graphics modes, you should also post the + output from running the afinfo and vesainfo programs (the short version + is enough unless you are explicitly asked to add the -v switch: all that + extra data isn't usually needed). + +

+ If the problem is related to the sound system, try using the setup + program to manually configure your card. You may need to manually enter + the hardware parameters, and if it is an SB clone card, try selecting + some earlier breed of SB card than whatever it is autodetecting (SB Pro, + SB 2.0, or SB 1.0). If you are still unable to get anything working, your + post should include the name and descriptions of whatever digital and + MIDI sound drivers are being autodetected (this information is displayed + by the play.exe program). + + + +


+

Part 3 - when your program crashes

+ +

+

crashes under DOS

+ When a djgpp program crashes, you will usually get a stack traceback + looking something like: +

+      Exiting due to signal SIGSEGV
+      General Protection Fault at eip=00001eca
+      [snip]
+
+      Call frame traceback EIPs:
+        0x00001eca
+        0x00001590
+        0x00001aea
+
+ This information tells you exactly where the crash occurred. To make + sense of it, you should compile your program with debugging information + (using the -g switch), and then run "symify program.exe" while this + traceback is displayed onscreen. That will change the traceback to + something along the lines of: +
+      Call frame traceback EIPs:
+        0x00001eca   _strcpy+14
+        0x00001590   _main+56, line 7 of t.c
+        0x00001aea   ___crt1_startup+138
+
+ In this case, you can see that the crash occurred in the strcpy() + function, which was called at line 7 of the main() function in the t.c + source file. Now you just have to go to that line, have a look at + whatever you are doing there, and change it to be correct :-) + +

+ Note: if the crash happens deep inside an Allegro function, this + traceback may not be so useful. When this happens you can recompile + Allegro with debugging information (see the readme file), and then + link your program with the debugging library version. + +

+ Note 2: even when this crash traceback points to one of the Allegro + functions, that does not necessarily mean the Allegro routine is at + fault. Anything will crash if you pass it invalid parameters, so unless + you can duplicate the problem in one of the Allegro example programs, you + should start out by assuming that it is a case of operator error and + double-check exactly what you are passing to the Allegro function. + +

+

crashes under Linux/Unix

+ When your Allegro compiled Linux/Unix program crashes, you will usually + get a not very meaningful message along with a core dump: +

+      Shutting down Allegro due to signal #11
+      Segment violation (core dumped)
+
+ Look at your filesystem: there should be a file named core or something + similar with information telling you exactly where the crash occurred. + If there is no core, check your environment settings, under bash this is + done with the 'ulimit -a' command. Usually 'ulimit -c unlimited' + somewhere in your login scripts should work fine. + +

+ Just like with djgpp, to make sense of the core, you should compile your + program with debugging information (using the -g switch), and then run + the GNU debugger on it "gdb binary core". That will load the debugger, + print some information about linked libraries and leave you at a prompt. + Now you can get the full backtrace: +

+      (gdb) backtrace
+      #0  0x08065237 in utf8_getx (s=0xbffffc5c) at ./src/unicode.c:347
+      #1  0x0806953f in ustrzcpy (dest=0x0, size=2147483646, src=0x0) at ./src/unicode.c:1770
+      #2  0x08057575 in _mangled_main () at t.c:9
+      #3  0x0806c9bf in main (argc=1, argv=0xbffffd14) at ./src/unix/umain.c:39
+      #4  0x4015414f in __libc_start_main () from /lib/libc.so.6
+
+ In this case, you can see that the crash occurred in the ustrzcpy() + function, which was called at line 9 of the main() function in the t.c + source file. Now you just have to go to that line, have a look at + whatever you are doing there, and change it to be correct :-) + +

+ Note that the crash happened deep inside an Allegro function, which is + also revealed by the traceback. However, the binary was linked against a + static debug version of Allegro, we wouldn't have had so much luck with + a non debug or dynamically linked version. + +

+ Since gdb is an interactive debugger, you could also select a frame and + check out the values of the variables, to see better who is the culprit: +

+      (gdb) frame 2
+      #2  0x08057575 in _mangled_main () at t.c:9
+      9          ustrcpy(p1, p2);
+      (gdb) list
+      4
+      5       int main(void)
+      6       {
+      7          char *p1 = 0, *p2 = 0;
+      8          allegro_init();
+      9          ustrcpy(p1, p2);
+      10         return 0;
+      11      }
+      12      END_OF_MAIN()
+      (gdb) print p1
+      $1 = 0x0
+      (gdb) print p2
+      $2 = 0x0
+
+ Yuck! Playing with NULL values doesn't really pay off. Ok, while this was + a slightly out-of-the-can example, you surely get the point. Remember to + check out GDB's manual to learn about more useful commands and/or how to + debug your program while it's running and many other things. You might also + want to check out Peter Wang's "Debugging with GDB" article, featured in + the ninth number of the Pixelate online magazine + (http://pixwiki.bafsoft.com/). + + + +


+

Part 4 - things people don't do (but should)

+ +

+ One of the most common errors made by programmers is to neglect to check + the return value from a function that may fail. Such an error will often + lead to unexpected and downright unusual errors, making for a debugging + nightmare. There are many functions in and out of Allegro that may or may + not work depending on varying circumstances. They are, however, nice + enough to let you know whether or not they were successful through + documented return values. + +

+ Whenever you call a function that might fail (most importantly + set_gfx_mode(), install_sound(), and anything that loads data from the + disk), it is _essential_ that you check the return code from this, and + respond accordingly. + +

+ Another commonly forgotten but important tool is to use whatever option + enables strict warnings for your compiler (gcc uses -Wall), when + compiling your code. Any warnings reported by this option will almost + certainly represent errors in your program, and should be fixed before + doing anything else. When using gcc, a useful trick is to compile with + the -O setting as well, because this causes gcc to examine the program's + actions in more detail, enabling more useful warnings. You should + normally disable optimisation while debugging, though. Although it gives + better compile time warnings, it is likely to upset any debugging tools + that you later try to use. + + + +


+

Part 5 - asking for help

+ +

+ Ok, so you've tried everything described above, and your program still + doesn't work. You have no idea what to do next, so it is time to cast + yourself unto the mercies of the net, in hopes of finding some kind of + wise man, seer, or oracle that holds an answer for your question... + +

+ The best places to ask are the Allegro mailing list (see readme.txt for + details) and the Allegro.cc forums. Please remember that the mailing list + is an Allegro-specific list. Problems relating to the C language or djgpp + compiler belong in other forums (comp.lang.c and comp.os.msdos.djgpp + respectively). The Allegro.cc forums can be found at + http://www.allegro.cc/. You can usually ask any question related + to Allegro here. + +

+ Both the Allegro and djgpp mailing lists are archived, and can be + searched via their respective homepages. It is very likely that you will + be able to find a solution to your problem by looking through the answers + to past questions, which will save you needing to post a query at all. + +

+ In accordance with proper netiquette, it is assumed that when you post to + any forum on the Internet you have at least consulted the relevant + documentation first, if not read it in its entirety. If the problem you + are having is worth asking hundreds of people the answer for, then it is + certainly worth taking a few minutes to try to solve the problem + yourself. Allegro is extensively and painstakingly documented and it is + considered a prerequisite to posting that you have not only read the + text, but examined the example programs as well. + + + +


+

Part 6 - learn from my mistakes

+ +

+ What not to do, Part One: +

+      "My program crashes. Please tell me why."
+
+ Yes, people really do sometimes send me questions like this :-) Despite + years of practice I am still totally unable to read minds, so this is a + very pointless thing to ask. In order to get help with a problem you must + describe it in enough detail that other people will be able to understand + and reproduce it: this usually means posting some of your source code. + + +


+ What not to do, Part Two: +

+      "I've got a problem with my program. I'm attaching a 500k zip file 
+      containing ten thousand lines of source code and all the graphics and 
+      sound data: can you please debug it and tell me what the trouble is?"
+
+ After wasting the time and phone bills to download such a huge file, it + is unlikely that anyone will even _want_ to help you, let alone invest + the amount of time it would take to read and understand such a huge mess + of information. You must try to isolate a smaller chunk of code that + demonstrates the trouble: the smaller you can make it, the more chance + that someone will be able to help you with it. Remember that you are + asking other people to do you a favour, so it is your responsibility to + make this process as easy for them as you possibly can. + + + +


+

Part 7 - wording your plea

+ +

+ The most important thing is to include code that can be compiled and + tested by the person reading your message. Don't just post your entire + program: try to extract a small section that includes the specific lines + causing your problem, or reproduces the trouble in a simpler way (you + will often find that you can locate the error yourself in the process of + making this simpler version, so it is a good exercise in itself). This + code should be a small but complete program that can actually be compiled + and run, because it is very hard to debug incomplete code fragments. + +

+ It is best to include the code directly in the text of your email + message, because it is easier for people to read this than if they have + to extract it from an attachment. + +

+ Ideally your example should avoid using any external graphics and data + files. It is ok to include a small (max 2k) zip containing such + information, or failing that a description of what other files it needs + (eg. "put a 32x32 .pcx file called 'tile.pcx' into the same directory as + the program). If there is no way that you can simplify things this far, + you should upload the program and data to a website and then just post + that URL in your message. + +

+ You should say what compiler options you used to build the program. These + should include extra warnings. If you use gcc, post the list of compiler + switches you used. + +

+ Describe what you intended this program to do (it may not be instantly + obvious to other people), and also what it really does when you run it. + There is usually no need to post the actual crash traceback (other people + can duplicate this for themselves as long as they are able to compile and + run your code), but you should say whether you do get such a traceback, + or a lockup, or just incorrect results (and if so, in exactly what way + they differ from what you were expecting). It is useful to mark your + source with a comment to show what line the crash traceback points to. + +

+ Any other information that you can include may also be useful. Most + importantly a brief machine description, information about any relevant + drivers, and your Allegro version (please don't just say "WIP", but give + the exact date if you are using anything other than an official numbered + release). + + + +


+

Part 8 - a model of perfection

+ +

+ For reference, here is an example of what I would consider to be an ideal + problem report: + +

+   I'm having some trouble using the hicolor video modes in my program, 
+   although they work fine with the Allegro tests. I'm using Allegro 4.0 
+   with MinGW 3.1.0 (gcc version 3.3.1) on a Pentium 1.2GHz, running under
+   Windows 2000 and an ATi Radeon 7000 videocard.
+
+   This program is supposed to select a 640x480 16 bit resolution, draw a 
+   blue rectangle near the top left corner of the screen, and then wait for 
+   a keypress before quitting, but I just get a General Protection Fault 
+   when I run it.
+
+   I compile it using "gcc -Wall t.c -o t.exe -lalleg", and don't get any 
+   warnings.
+
+
+   --- cut here, t.c ---
+
+   #include <stdio.h>
+   #include <allegro.h>
+
+   void main()
+   {
+      BITMAP *bmp = screen;
+
+      install_keyboard();
+
+      if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
+         printf("Error setting video mode\n");
+         return;
+      }
+
+      set_color_depth(16);
+
+      /* crashes during this rectangle call! */
+      rectfill(bmp, 32, 32, 64, 64, 0x001F);
+
+      readkey();
+   }
+
+ + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/index.html b/lib/allegro/allegro-htmldocs-4.2.1/index.html new file mode 100644 index 0000000..e0d0353 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/index.html @@ -0,0 +1,36 @@ + + +Allegro Documentation Index + + + + +
+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/
+
+
+                A game programming library.
+
+ + + + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/license.html b/lib/allegro/allegro-htmldocs-4.2.1/license.html new file mode 100644 index 0000000..89d97c2 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/license.html @@ -0,0 +1,40 @@ + + +Giftware license + + + + +

The giftware license

+ +

+ Allegro is gift-ware. It was created by a number of people working in + cooperation, and is given to you freely as a gift. You may use, modify, + redistribute, and generally hack it about in any way you like, and you do + not have to give us anything in return. + +

+ However, if you like this product you are encouraged to thank us by making + a return gift to the Allegro community. This could be by writing an add-on + package, providing a useful bug report, making an improvement to the + library, or perhaps just releasing the sources of your program so that + other people can learn from them. If you redistribute parts of this code or + make a game using it, it would be nice if you mentioned Allegro somewhere + in the credits, but you are not required to do this. We trust you not to + abuse our generosity. + +

+ Disclaimer: + +

+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/makedoc.html b/lib/allegro/allegro-htmldocs-4.2.1/makedoc.html new file mode 100644 index 0000000..7bd5058 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/makedoc.html @@ -0,0 +1,151 @@ + + +makedoc + + + + + +

+The makedoc tool +

+
+ +


+

Using makedoc

+ +

+Not only the library is built from source code but the actual documentation +too. Allegro is bundled with makedoc, a convulsed C program which started +small and has grown to support many different output formats. The +documentation source and documentation generator can be found both under the +`docs/src' directory. Running `make' in Allegro's top directory will generate +the documentation along with the library, but there are more specific make +targets which you can use to selectively build only the documentation or +specific versions of the documentation which by default won't be generated. +You can find more about these in the "Makefile targets" chapter. + +

+

Output formats

+Makedoc output will be placed in the `docs/format' directory or directly in +the `docs' directory. Usually if an output format requires an external tool +which doesn't come bundled with Allegro you will have to generate it manually +with the correct makefile target. +

+ +

+

Customizing the output

+Some of the output formats can be customized even further by modifying some +of the generated files or directly the original source file. The +documentation source file format is described with more detail in +`docs/src/makedoc/format.txt'. Usually the interesting bits to users are: +

+Note that all the above which applies to HTML output also applies to +documentation formats which are HTML based, like Devhelp or CHM. + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/mistakes.html b/lib/allegro/allegro-htmldocs-4.2.1/mistakes.html new file mode 100644 index 0000000..8e7d219 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/mistakes.html @@ -0,0 +1,113 @@ + + +Common mistakes + + + + +

+Common mistakes +

+
+ +


+

Contents

+ +

+

+ + +


+

Ignoring this manual.

+ Most problems are addressed in this manual. If you aren't sure about + some parts of Allegro check particular section of manual. The FAQ + section can also be very useful. + +


+

main() not returning int.

+ On platforms that need it, Allegro uses END_OF_MAIN to + mangle your main() function and supply its own that is required by the + platform. Allegro assumes that main() returns an integer, as required + by various C standards. If you change the return type of your main() to + something else Allegro's main() will get confused and return some + nonsense value which some system can recognize as an error and crash + your program. + +


+

Semicolon at END_OF_MAIN.

+
+         int main(void)
+         {
+            allegro_init();
+            /* more stuff goes here */
+            ...
+            return 0;
+         }
+         END_OF_MAIN(); /* wrong */ 
+ +

+ The semicolon is not only unnecessary after END_OF_MAIN(), but it can + also cause some compilers to issue a warning. + +


+

Getting bitmap's size.

+ Many people don't know how to get the dimensions of a bitmap. This can + be done by accessing the `w' and `h' fields of the BITMAP structure: +
+         BITMAP *image;
+         ...
+         allegro_message("Bitmap size: %d x %d\n",
+                         image->w, image->h);
+ +


+

Creating bitmaps before loading.

+
+         BITMAP *image = create_bitmap(width, height);
+         image = load_bitmap("image.bmp", pal);
+ +

+ When loading a bitmap, Allegro will automatically create a bitmap big + enough to store it. In the above code the address returned by + create_bitmap() is overwritten by the second assignment statement, to + the return value of the call to load_bitmap(). Since the address of + the first (unnecessary) bitmap has been lost, there is no way to + destroy it so there is a memory leak. + +


+

Loading a bitmap/font/sound inside a global object constructor.

+ Almost all Allegro functions require Allegro to be initialized first, + before they can be used. Since global object constructors are called + before main() (from where allegro_init() would be called) this + condition is violated. You need to postpone calls to Allegro functions + to after initializing Allegro. + +


+

Calling set_color_depth without resetting graphic mode.

+ set_color_depth() tells Allegro which color depth to use the next time a + graphic mode is set or bitmap is created or loaded. It doesn't change + the color depth of the current graphic mode or existing bitmaps. You + need to be sure that all your bitmaps and/or graphic mode are in the + same color depth or Allegro will be forced to do slow color conversions + between them. + +


+

Destroying global objects like `screen'.

+ Unlike other bitmaps `screen' is created by calling set_gfx_mode() and + must not be destroyed by calling destroy_bitmap(). The proper way to + destroy `screen' is calling set_gfx_mode(GFX_TEXT, 0, 0, 0, 0). + + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/packfile.html b/lib/allegro/allegro-htmldocs-4.2.1/packfile.html new file mode 100644 index 0000000..5fab7fe --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/packfile.html @@ -0,0 +1,122 @@ + + +Packfile format + + + + +

+Packfile format information. +

+
+ + +


+

Contents

+ +

+

+ + + +


+

Introduction and scope

+ +

+ This document describes the format of Allegro's packfiles from a + decompression point of view. It does not describe how to do the + compression (read the source, or ask Google about LZSS). + +

+ file.c says "This compression algorithm is based on the ideas of Lempel + and Ziv, with the modifications suggested by Storer and Szymanski.", if + that means anything to you. + + +


+

Packfile signature

+ +

+ All compressed packfiles begin with a four byte signature "slh!" (ASCII), + which in hexadecimal is 0x73, 0x6C, 0x68, 0x21 (in that order). + +

+ Another form of packfiles are uncompressed packfiles, which begin with the + four byte signature "slh." (ASCII), in hexadecimal 0x73, 0x6C, 0x68, 0x2B. + The rest of the file is then completely raw. Uncompressed packfiles will + not be discussed further. + + +


+

Format and decompression algorithm

+ +

+ Decompression requires a ring buffer of 4096 bytes and a ring index (which + indexes into the ring buffer). The ring index starts at 4078, assuming + 0-based indices. New bytes may be stored into in the position in the ring + buffer that the index points to. When a byte is stored, the index is + incremented by one, wrapping around to zero as necessary. + +

+ Packfiles must be decompressed sequentially. The first byte following the + signature in the packfile is the "flags" byte, which determines how the + following "tokens" in the file are to be interpreted. + +

+ Bit 1 (the least significant bit) corresponds to the first token following + the flags byte. Bit 2 corresponds to the second token, etc. After every + eight tokens, there is another flag byte and another eight tokens, and so + on, until the end of file. + +

+ If the bit I of the flags byte is set, then token I is a single byte to be + sent to the output. In addition, it must put onto the ring buffer and the + ring index incremented. + +

+ Otherwise, if bit I of the flags byte is not set, then token I is a two + byte sequence containing an index and a length. The index is the first + byte OR'd together with the higher 4 bits of the second byte as the higher + order bits, thus making a 12-bit unsigned number (0-4095). The length is + the lower 4 bits of the second byte, plus 3. + In less hand-wavy C syntax: +

+      index  = byte1 | ((byte2 & 0xF0) << 4);
+      length = (byte2 & 0x0F) + 3;
+
+ Then, "length" number of bytes from the ring buffer, starting at "index", + are to be sent to the output. In addition, all these bytes must be put + onto the ring buffer, and the ring buffer incremented accordingly. + +

+ Decompression ends at the end of the file. There is no end-of-file + marker. If the number of tokens is not a multiple of eight, the unused + bits in the latest flags byte are always zero. + + +


+

Summary

+ +

+ In brief, compressed packfiles take the form: +

+      signature -- 4 bytes
+
+      flags     -- 1 byte
+      token 1   -- each token 1 or 2 bytes
+      token 2
+       ...
+      token 8
+      flags
+       ...
+      (repeat flags and tokens 1-8 until EOF)
+
+ + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/readme.html b/lib/allegro/allegro-htmldocs-4.2.1/readme.html new file mode 100644 index 0000000..bae74a1 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/readme.html @@ -0,0 +1,392 @@ + + +A general introduction to Allegro + + + + +
+     ______   ___    ___
+    /\  _  \ /\_ \  /\_ \
+    \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+     \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+      \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+       \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+        \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+                                       /\____/
+                                       \_/__/     Version 4.2.1
+
+
+                A game programming library.
+
+             By Shawn Hargreaves, Nov 26, 2006.
+
+                See the AUTHORS file for a
+               complete list of contributors.
+
+ + +


+#include <std_disclaimer.h> +

+ "I do not accept responsibility for any effects, adverse or otherwise, + that this code may have on you, your computer, your sanity, your dog, + and anything else that you can think of. Use it at your own risk." +
+ + + +


+

Introduction

+ +

+ Allegro is a cross-platform library intended for use in computer games + and other types of multimedia programming. It was initially conceived on + the Atari ST, but that platform sadly died during childbirth. After a + brief stay with Borland C, it was adopted by the fantastic djgpp + compiler, where it grew to maturity. In the fullness of time it gave + birth to children of its own, who went to live in such exotic locations + as DirectX and the X Server, but the entire family is now back together + again, living in harmony as a single portable entity. How about that for + a mixture of metaphors? :-) + +

+ A wide range of extension packages and add-on modules are also available, + which can be found in the "Library Extensions" section of the Allegro.cc + website, http://www.allegro.cc/. + +

+ According to the Oxford Companion to Music, Allegro is the Italian for + "quick, lively, bright". It is also a recursive acronym which stands for + "Allegro Low Level Game Routines". + + + +


+

Supported platforms

+ +

+ For instructions on how to install Allegro, how to link your programs + with it, and any additional information specific to each of the supported + platforms, see one of the files included in the distribution package: +

+   DOS/djgpp         - see docs/build/djgpp.txt
+   DOS/Watcom        - see docs/build/watcom.txt
+   Windows/MSVC      - see docs/build/msvc.txt
+   Windows/MinGW     - see docs/build/mingw32.txt
+   Windows/Cygwin    - see docs/build/mingw32.txt
+   Windows/Borland   - see docs/build/bcc32.txt
+   Linux (console)   - see docs/build/linux.txt
+   Unix (X11)        - see docs/build/unix.txt
+   Darwin (X11)      - see docs/build/darwin.txt
+   BeOS              - see docs/build/beos.txt
+   QNX               - see docs/build/qnx.txt
+   MacOS X           - see docs/build/macosx.txt
+
+ General API information can be found in the main manual, usually referred + to as docs/txt/allegro.txt, allegro.txt or simply "The Allegro manual" + throughout this document. The Allegro manual source is available as a set + of files in the docs/src directory. During the build process of the + library, these source files will be converted to HTML, TexInfo, and RTF + formats (among others) and placed in their respective doc/FORMAT + directory. + +

+ Information about changes in the API and deprecated features can be found + in docs/txt/api.txt (also available in HTML, TexInfo, and RTF format as + part of the Allegro manual). + + + +


+

Features

+ + + +


+

Copyright

+ +

+ Allegro is gift-ware. It was created by a number of people working in + cooperation, and is given to you freely as a gift. You may use, modify, + redistribute, and generally hack it about in any way you like, and you do + not have to give us anything in return. However, if you like this product + you are encouraged to thank us by making a return gift to the Allegro + community. This could be by writing an add-on package, providing a useful + bug report, making an improvement to the library, or perhaps just + releasing the sources of your program so that other people can learn from + them. If you redistribute parts of this code or make a game using it, it + would be nice if you mentioned Allegro somewhere in the credits, but you + are not required to do this. We trust you not to abuse our generosity. + +

+ Disclaimer: + +

+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + +

+

Configuration

+ +

+ Allegro reads information about your hardware from a file called + allegro.cfg. If this file doesn't exist it will autodetect (ie. guess :-) + You can write your config file by hand with a text editor, or you can use + the setup utility program (located in the setup directory). + +

+ Normally the setup program and allegro.cfg will go in the same directory + as the Allegro program they are controlling. This is fine for the end + user, but it can be a pain for a programmer using Allegro because you may + have several programs in different directories and want to use a single + allegro.cfg for all of them. If this is the case you can set the + environment variable ALLEGRO to the directory containing your + allegro.cfg, and Allegro will look there if there is no allegro.cfg in + the current directory. + +

+ The mapping tables used to store different keyboard layouts are stored in + a file called keyboard.dat. This must either be located in the same + directory as your Allegro program, or in the directory pointed to by the + ALLEGRO environment variable. If you want to support different + international keyboard layouts, you must distribute a copy of + keyboard.dat along with your program. + +

+ Various translations of things like the system error messages are stored + in a file called language.dat. This must either be located in the same + directory as your Allegro program, or in the directory pointed to by the + ALLEGRO environment variable. If you want to support non-English versions + of these strings, you must distribute a copy of language.dat along with + your program. + +

+ Under Unix, BeOS and MacOS X, the config file routines also check for + ~/allegro.cfg, ~/.allegrorc, /etc/allegro.cfg, and /etc/allegrorc, in + that order, and the keyboard and language files can be stored in your + home directory or in /etc/. If under MacOS X, the application bundle + Contents/Resources directory, if any, is also scanned first. + +

+ See docs/txt/allegro.txt for details of the config file format. + + + +


+

Notes about sound

+ +

+ The DIGMID wavetable driver uses standard GUS format .pat files, and you + will need a collection of such instruments before you can use it. This + can either be in the standard GUS format (a set of .pat files and a + default.cfg index), or a patches.dat file as produced by the pat2dat + utility. You can also use pat2dat to convert AWE32 SoundFont banks into + the patches.dat format, and if you list some MIDI files on the command + line it will filter the sample set to only include the instruments that + are actually used by those tunes, so it can be useful for getting rid of + unused instruments when you are preparing to distribute a game. See the + Allegro website for some links to suitable sample sets. + +

+ The DIGMID driver normally only loads the patches needed for each song + when the tune is first played. This reduces the memory usage, but can + result in a longish delay the first time you play each MIDI file. If you + prefer to load the entire patch set in one go, call the + load_midi_patches() function. + +

+ The CPU sample mixing code can support between 1 and 64 voices, going up + in powers of two (ie. either 1, 2, 4, 8, 16, 32, or 64 channels). By + default it provides 8 digital voices, or 8 digital plus 24 MIDI voices (a + total of 32) if the DIGMID driver is in use. But the more voices, the + lower the output volume and quality, so you may wish to change this by + calling the reserve_voices() function or setting the digi_voices and + midi_voices parameters in allegro.cfg. + + + +


+

Contact info

+ +

+ The latest version of Allegro can always be found on the Allegro + homepage, http://alleg.sourceforge.net/. + +

+ There are three mailing lists for Allegro-related discussion, each with a + slightly different purpose. +

+ To subscribe to one of the three lists, simply go to it's web page and use + the online forms to subscribe yourself. You can remove yourself from a + list going to the same page above, which can be used to remind you of your + password too, in case you have forgotten it. + +

+ To send a message to one of the lists, write to + alleg-main@lists.sourceforge.net or + alleg-developers@lists.sourceforge.net. You don't need to be subscribed to + these mailing lists before you can post there, but it is a good idea to + subscribe in order to see the replies. + +

+ Before posting tech-support questions to the Allegro list, please take a + moment to read the guidelines in docs/txt/help.txt. See docs/txt/ahack.txt + for information about the style of code we use, and how to create your + patches. + +

+ If you want to search through the archives of any of those mailing lists, + you will have to check the available options at + http://alleg.sourceforge.net/maillist.html. + +

+ Please don't send messages in HTML format. The increased size places an + unnecessary load on the server, and many subscribers have a hard time + reading these posts. + +

+ Please do not crosspost between these lists. Choose the most appropriate + one for your message, and then send it only to that list. + +

+ Please don't send large binary attachments to any of the lists, they will + be rejected by the size limit filter, which is set to 100KB for the + developers mailing list, and 40KB for the others. Upload your files to a + website and then post the URL, or if you can't do that, post an + announcement asking people to write to you privately, and then send the + file by individual email to whoever responded. + +

+ Please use English in your messages. You could eventually post messages in + whatever language you prefer, but that would terribly limit the chances of + getting a useful answer. + +

+ Remember that the RFC 1855: netiquette guidelines + (http://www.rfc-editor.org/rfc/rfc1855.txt) describes other general + guidelines you should follow as a correct internet user (in mailing lists + and other places as well), and provides more verbose descriptions and + explanations about why you should follow the above guidelines. + +

+ One of the important guidelines you should be aware of is how to quote + correctly the message you are replying to. The previous RFC doesn't really + explain how to do it, so you might want to read the document "How do I + quote correctly in Usenet?" at + http://www.netmeister.org/news/learn2quote.html. Quoting correctly is + easier to say than to do, especially for users of Microsoft Outlook. If + you are such a user, you can help yourself using the Outlook-QuoteFix + extension written by Dominik Jain, which you can find at + http://home.in.tum.de/~jain/software/outlook-quotefix/. + + + + diff --git a/lib/allegro/allegro-htmldocs-4.2.1/thanks.html b/lib/allegro/allegro-htmldocs-4.2.1/thanks.html new file mode 100644 index 0000000..b6da7d8 --- /dev/null +++ b/lib/allegro/allegro-htmldocs-4.2.1/thanks.html @@ -0,0 +1,1495 @@ + + +Allegro Contributors + + + + +

The Hall of Fame


+ +We hope to have remembered everyone who ought to be mentioned here. If your +name should be included, accept our apologies, and please tell us so we can +correct the oversight! + + + +


+

Contributors

+ +

+ Acho A. Tang (acho at telus dot net).
+ Added a Sidewinder Precision Pro joystick driver to the DOS port. + +

+ Adrian Oboroc (doba at corefx dot com).
+ Wrote the LBM loader. + +

+ aj.
+ Reported many problems, suggested a lot of improvements to the + documentation, added AMD64/IA64/SSE3 detection code, added DirectX 8 and 9 + detection to the Windows port, added MSVC7 specific options to the makefile, + cleaned up a C99-ism in makedoc, fixed a beep when alt+character was pressed + in windowed mode in Windows and made TARGET_ARCH_EXCL also work with MSVC. + +

+ Alex Demko (alex_demko at mbnet dot mb dot ca).
+ Suggested lots of improvements to the datafile system and provided code + for handling the 8x16 BIOS font format. + +

+ Alessandro Monopoli (almonopo at tin dot it).
+ Added the Italian translation of the system messages. + +

+ Andreas Kluge (bitland at aol dot com).
+ Wrote the Ensoniq Soundscape driver and fixed division bugs in the fix + class. + +

+ Andrei Ellman (ae-a-alleg2 at wacko dot wackonet dot net).
+ Contributed the polygon_z_normal() function, suggested some additions to + the docs, updated the Cygwin section in docs/build/mingw32.txt, got + Allegro for MSVC to build with Cygwin, improved the performance of the + hsv_to_rgb() function, corrected a rounding issue in hsv_to_rgb(), + improved the exrgbhsv example and the Windows screensaver, fixed problems + in the MSVC makefile when using Cygwin and did plenty of other things too. + +

+ Andrew Cottrell (andrewc at dbworld dot net dot au).
+ Changed the grabber to use a more robust (locale-independent) date format. + +

+ Andrew Ellem (krand at ican dot net).
+ Wrote the original version of the digital audio streaming code. + +

+ Andrew Geers (andy at geerswj dot clara dot net).
+ Added the -ppassword and -nosound options to the grabber, scrolling + support in the image viewer and the flipped rotated sprite routines. + +

+ Andy Goth (unununium at openverse dot com).
+ Made the gfx_card config variable more flexible, added the 256x256 tweaked + VGA mode, wrote the d_text_list_proc() dialog object and fixed the + constructor support in dat2s on Unix. + +

+ Angelo Mottola (a dot mottola at libero dot it).
+ Added the BeOS joystick, MIDI and windowed graphics drivers, added mouse + wheel, display switching and close button support for BeOS, wrote the + DGA2 driver and close button support for X, contributed the bfixicon + utility, added triple buffering support, a BWindow-based windowed driver + and a fullscreen overlay driver to the BeOS port and reorganized its gfx + subsystem. And, oh, contributed the QNX and MacOS X ports too. + +

+ Annie Testes (annie at kezako dot net).
+ Added font_height, render_char, char_length hooks to FONT_VTABLE, fixed + several glitches in the unicode support, added a pack_fdopen() function, + caught a misordering in the X system shutdown, fixed some device name + strings, lifted several hardcoded length limitations in the configuration + routines, added a mouse driver based on the event interface (EVDEV) to the + Linux port, fixed numerous bugs and did plenty of other things too. + +

+ Antoine Mathys (mmathys at bluewin dot ch).
+ Added the Swiss keyboard mapping. + +

+ Anton Ragnarsson (anton dot ragnarsson at swipnet dot se).
+ Contributed the Swedish keyboard mapping table. + +

+ Antti Haapala (ztane at lyseo dot edu dot ouka dot fi).
+ Fixed the setup program to display the right frequency list for each + type of soundcard and contributed the Finnish translation of the system + messages. + +

+ Antti Koskipaa (antti dot koskipaa at nic dot fi).
+ Wrote the DOS driver for WSS (Windows Sound System) cards. + +

+ Arne Steinarson (arst at ludd dot luth dot se).
+ The fixed point square root routine came from his fix-float library. + +

+ Arthur Huillet (email unknown).
+ Fixed a typo in the docs. + +

+ Attila Szilagyi (attilabox at hotmail dot com).
+ Fixed SVGAlib horizontal scrolling. + +

+ Ben Chauveau (bendomc at worldnet dot fr).
+ Added support for Tseng ET6000 cards (now available as part of the + FreeBE/AF project). + +

+ Ben Darnell (bdarnell at vnet dot net).
+ Put together the 2.11 release of Allegro while I was away from the net + and wrote the original version of the Allegro FAQ. + +

+ Ben Davis (entheh at users dot sf dot net).
+ Added set_volume_per_voice(), made silent voices continue playing, + fixed other minor bugs in the mixer, fixed a bug in create_rgb_table(), + adapted polygon functions to handle two coincident vertices, added the + set_window_close_button() and set_window_close_hook() framework, added + support for timers with parameters under Windows, corrected several + compilation warnings and documented the behaviour of pack_feof(). + +

+ Benjamin Joel Stover (stovertech at intellisys dot net).
+ Wrote the initial version of the fullscreen X-Windows graphics driver. + +

+ Benny Colyn (email unknown).
+ Added a Dutch translation. + +

+ Bertrand Coconnier (bcoconni at club-internet dot fr).
+ Modified 3D polygones routines for subpixel and subtexel accuracy, made + speed enhancements in these routines, fixed blending in C version of + atex_lit scanline functions, added scanline subdivisions in C scanline + functions and Z-buffer polygon functions and merged in Calin Andrian's + P3D library. + +

+ Bobby Ferris (baf at bafsoft dot com).
+ Added the SciTE API output format to makedoc and temporarily hosted + Allegro's SVN repository while SourceForge's SVN was in beta. + +

+ Burton Radons (loth at gec dot net).
+ Optimised the truecolor pixel blending function, converted the blenders + to the new single-handler format, and added the range of + Photoshop-compatible blender functions. + +

+ Calin Andrian (calin at ibd dot dbio dot ro).
+ Wrote the truecolor, MMX, 3DNow!, masked lit mode, translucent and + Z-buffered polygon rendering routines, the clip3d_f() function and also + the scanline sorting functions for 3D scene rendering, and his P3D + addon library was merged in. + +

+ Calvin French (frenchc at home dot com).
+ Added the -w (always update) switch to dat.exe. + +

+ Carsten Schmidt (email unknown).
+ Wrote the the initial version of the Linux GGI driver. + +

+ Carsten Sorensen (csorensen at ea dot com).
+ Wrote the the ESS AudioDrive soundcard driver. + +

+ Catatonic Porpoise ().
+ Added OpenBSD detection, fixed an issue with executable rights not set + on the memory for the i386 stretcher on UNIX systems, and fixed the + documentation for stretch_sprite. + +

+ Cloud Wu (cloudwu at 263 dot net).
+ Optimised the truecolor pixel blending functions. + +

+ Charles Bilyue (Esaelon at aol dot com).
+ Optimized the i386 blitters and suggested to not force yielding timeslice + with non-blocking menus. + +

+ Charles Wardlaw (kattkieru at yahoo dot com).
+ Fixed warnings with gcc 4 on MacOS X and helped resolve a problem with + setAppleMenu under Tiger. + +

+ Chris Graham (chris_graham at postmark dot net).
+ Suggested to add a new flag for Windows NTFS compressed files. + +

+ Chris Jones (cj at jibblers dot plus dot com).
+ Fixed a bug with 16-bit samples loading, worked around a problem with DOS + file attributes under Win2k, let the MIDI player pass controller events to + the raw player by default, made the MIDI player handle the 'All Sound Off' + controller message, added support for the bitfield compressed BMP image + format, fixed the behavior of numeric keys when NumLock is on, and fixed + loading of certain .wav files. + +

+ Chris La Mantia (celamantia at home dot com).
+ Wrote the d_radio_proc(), d_icon_proc(), and d_slider_proc() dialog + objects, added the D_DISABLED flag, improved the GUI handling of + different font heights, and added the right aligned text functions. + +

+ Chris Robinson (crobin_99 at yahoo dot com).
+ Wrote the fixed point clip3d() function, improved the performance of the + DIGMID driver, implemented the digmid_set_pan function, rewrote part of + the Allegro mixer, made the Allegro mixer the default one in Windows, + improved the threaded UNIX timer code, helped improve responsiveness under + X11, tweaked tests/play.c, added drawing primitives and video bitmap locking + to the X11 port and did plenty of other things too. + +

+ Christer Sandberg (christer dot sandberg at mdh dot se).
+ Made dat2c work better with ISO C90 compilers, made dat2c correctly detect + the native line ending, fixed a problem with the include guard generated + by dat2c, fixed a bug in the 24-bit graphics code of fixup_datafile(), + fixed a problem with Electric Fence. + +

+ Christian Schueler (cschueler at gmx dot de).
+ Changed the optimisation settings for better performance. + +

+ Daniel Nilsson (daniel7 at algonet dot se).
+ Enlarged the starfield in exstars, and fixed an incorrect range in + exlights. + +

+ Daniel Schlyder (daniel at bitblaze dot com).
+ Fixed problems with get_executable_name() under Windows, another one with + set_window_title() under BeOS, potentially unsafe constructs in the + Windows code, the installall makefile target under Windows, added + set_allegro_resource_path(), fixed make uninstall with mingw make, + added ALLEGRO_LIB_BUILD flag for gcc variants not using configure, + fixed a bunch of warnings in MinGW and did plenty of other things too. + +

+ Daniel Verkamp (i_am_drv at users dot sourceforge dot net).
+ Added a MIDI input driver to the Windows port anda dded support for .rmi + MIDI files to the MIDI loader. + +

+ Dark Nation (email unknown).
+ Restored support for old-style encrypted packfiles, which had been removed + in 4.1.18. + +

+ David A. Capello (dacap at users dot sourceforge dot net).
+ Made dotted_rect() avoid bank switches, fixed a problem with lost GUI + mouse clicks, made d_menu_proc() steal/return focus when activated then + deactivated, fixed a problem with submenus, fixed a bug with FLI frames + containing odd-sized chunks, made makedoc write sub-section headings + for .txt output, made override_config_file also be used for writing to + the config file and did plenty of other things too. + +

+ David Kuhling (dkuelhin at hell1og dot be dot schule dot de).
+ Optimised the fsqrt() routine, and added fhypot(). + +

+ Dave Physics.
+ Some documentation fixes. + +

+ Dave Thomson (gameskitchen at geocities dot com).
+ Added the RGB <-> HSV conversion routines, the autocrop function to + the grabber and wrote the 3d starfield example program (exstars.exe). + +

+ David Calvin (calvid at rpi dot edu).
+ Wrote the original version of the sound setup utility. + +

+ David Cullen (dcullen7 at bellsouth dot net).
+ Added multiple bullets and extra lives to the demo game. + +

+ Deepak T (coolbool at gmx dot net).
+ Fixed clipping in three C sprite drawing routines. + +

+ Dennis Busch (email unknown).
+ Fixed a bug in d_clear_proc, fixed a Unicode bug in the mode selector, + and fixed the short description of add_clip_rect. + +

+ Dmitriy Kazimirow (mariann at mail dot ru).
+ Provided the Russian keyboard mapping and message translation files. + +

+ Dominique Biesmans (Dominique dot Biesmans at ping dot be).
+ Wrote the mode-X version of draw_sprite() and the mode-X <-> linear + blitting functions. + +

+ Doug Eleveld (D dot J dot Eleveld at anest dot azg dot nl).
+ Wrote the d_textbox_proc() dialog object and the new grabber help system. + +

+ Dustin Dettmer (dustin at mize dot org).
+ Spotted a typo in save_bitmap. + +

+ Eduard Bloch (edi at gmx dot de).
+ Fixed a freeze caused by the ESD detection code, fixed a bad behaviour + of the config routines and suggested better ways to find the path to + the executable on Unix. + +

+ Edward Boone (Lucien dot Boone at ping dot be).
+ Provided scancode mapping tables for the AZERTY keyboard layout. + +

+ Elias Pschernig (elias at users dot sf dot net).
+ Added a COLORCONV_KEEP_TRANS mode, contributed the wfixicon utility, + contributed several enhancements to the grabber, fixed menu dimensions in + the GUI engine, fixed the get_camera_matrix*() functions, added support + for the CHM and Devhelp documentation formats, fixed a bug in midi_seek(), + made load_datafile_object() load the object properties, made the GUI code + scare the mouse more intelligently and did plenty of other things too. + +

+ Eric Botcazou (ebotcazou at libertysurf dot fr).
+ Made the DGA driver work better in 8bpp and 32bpp modes, improved the + DirectX windowed driver and Windows graphics subsystem, partially + revamped the Unicode API and added uszprintf(), added file_select_ex(), + the unified al_find*() interface, an Unicode example, a new filetest, + rewrote the fixdll script, revamped the Borland C++ build process, fixed + lots of bugs and did plenty of other things too. + +

+ Erik Sandberg (eriksandberg at geocities dot com).
+ Optimised the 8 bit draw_sprite() and draw_trans_sprite() functions and + helped with the Swedish message translation. + +

+ Ettore Perazzoli (ettore at comm2000 dot it).
+ Optimised the linear -> mode-X blitting function. + +

+ Evert Glebbeek (eglebbk at dds dot nl).
+ Put set_gfx_mode on a diet, added a config entry for specifying the card + to be used for GFX_AUTODETECT_WINDOWED, added a '-fullscreen' switch to + the grabber, cleaned up the grabber/plugins code, added various commands + to the grabber, added the detection of SunOS/Solaris, added configure + options for x86 processor optimisations on Unix systems, added the support + for relative filenames and did plenty of other things too. + +

+ EvilTypeGuy (eviltypeguy at icculus dot org).
+ Cleaned up and fixed the RPM spec file for RedHat 9. + +

+ Fabian Nunez (faybs at iafrica dot com).
+ Added support for the CH Flightstick Pro and Logitech Wingman Extreme + joysticks, 3-button mice, and the extended keys on a Microsoft keyboard. + +

+ Fabrizio Gennari (faybs at iafrica dot com).
+ Contributed the DB9 and TurboGraFXoystick drivers. + +

+ Francisco Pires (fmlvp at hotmail dot com).
+ Added an FPS counter and an option to disable vsync to the excamera + example. + +

+ Francois Charton (deef at pobox dot oleane dot com).
+ Wrote the Paradise graphics driver (now available as part of the + FreeBE/AF project), improved the VGA palette setting code and helped + with the TexInfo conversion of the docs. + +

+ Frodo Baggins (l41273 at alfa dot ist dot utl dot pt).
+ Made the Portuguese keyboard mapping. + +

+ Garret Thomson (g at sirsonic dot com).
+ Wrote the music used in the demo game. + +

+ George Foot (gfoot at users dot sourceforge dot net).
+ Did a great deal of work on the Linux console version, wrote the AWE32 + driver, added the MIDI pause/seek functions, provided the basis of the + SoundFont reader used in the pat2dat utility, fixed the C fceil() + function, added the ffloor() function and added non-FM support to the + OSS MIDI driver. + +

+ Gorka Olaizola (olsago at jet dot es).
+ Added the Redhat RPM .spec file. + +

+ Grady Martin (shadygrady at budweiser dot com).
+ Fixed a bug in the handling of %n in the printf style text functions, added + a move command to the grabber and standardised some of the grabber dialog + boxes. + +

+ Greg Hackmann (hacker at ididitmyway dot com).
+ Contributed the Borland C++ Builder port. + +

+ Greg Lee (greg at ling dot lll dot hawaii dot edu).
+ Pointed out that Linux joystick driver should read all events. + +

+ Grzegorz Adam Hankiewicz (gradha at users dot sourceforge dot net).
+ Wrote several of the example programs, suggested the "compress" makefile + target, translated the docs and system error messages into Spanish, + suggested the idea of embedding the setup utility into other programs, + wrote some documentation and corrected the .texi generation to improve + texi2dvi output, improved the makedoc utility and contributed a new doc + format, added reload_config_texts() and did plenty of other things too. + +

+ Grzegorz Godlewski (email unknown).
+ Contributed a Polish localization patch, and added support for lower and + upper altgr tables. + +

+ Grzegorz Ludorowski (pajonk at ajax dot umcs dot lublin dot pl).
+ Wrote several of the example programs, and made the intro animation and + graphics for the demo game. + +

+ Guilherme Silveira (thedarkage at geocities dot com).
+ Modified the file selector to only list valid drive letters. + +

+ Gunter Ladwig (gladwig at iname dot com).
+ Wrote the OS/2 detection routines and added the three-button mouse + emulation. + +

+ Hans de Goede. + Fixed a problem with dynamically generated stretcher code not being + properly marked as executable on Linux, fixed a busy wait in the X11 vsync + simulation, added a fullscreen driver for X11 which does not need XVidMode + extension, fixed a problem where switching to fullscreen mode under X11, + made digmid work with absolute pathes in patches.cfg, and fixed a problem + with the Alsa driver on big endian systems. + +

+ Harshavardhana Reddy N (nharsha at gmail dot com).
+ Added a Kannada greeting to exunicod. + +

+ Haruhiko Okumura (email unknown).
+ Wrote the original version of the LZSS compression code. + 12-2-404 Green Heights, 580 Nagasawa, Yokosuka 239, JP. + +

+ Hein Zelle (hein at icce dot rug dot nl).
+ Revamped the cross-compilation section of docs/build/mingw32.txt, + clarified a requirement when cross-compiling from Linux, reworked the + paragraph on the location of shared libraries under Unix in the docs and + added a FAQ entry on the same subject. + +

+ Henrik Schmidt (hbs at ks dot informatik dot uni-kiel dot de).
+ Found a workaround for the switching problem under Windows, made gcc pass + '-h' instead of '-soname' to the linker and replaced '-L' by '-h' in shell + comparisons so as not to break on Solaris. + +

+ Henrik Stokseth (hensto at online dot no).
+ Contributed a native Mingw32 port which can also be built with a + cross-compiler and the Cygwin compiler, much improved OS detection, added + get_gfx_mode_list() and methods for querying the VGA, Mode-X, Xtended, + VESA, VBE/AF and DirectX drivers for a list of possible GFX modes, + rewrote the mode-selector to use get_gfx_mode_list(), reworked the build + system many times and did plenty of other things too. + +

+ Hrvoje Ban (spoofer255 at gmail dot com).
+ Pointed out a bug in the mode selector, fixed several double ;'s, fixed + ASSERT() in Windows, helped write a documentation section about common + pitfalls, and added the create_datafile_index function. + +

+ Igor Gnip (gnipi at mindnever dot org).
+ Removed the requirements for fileutils on DOS/Windows platforms and added + the detection of MSYS to the MingW32 port. + +

+ Isaac Cruz (icruzbal at teleline dot es).
+ Fixed a bug with accelerated drawing onto sub bitmaps of DirectDraw + surfaces, added the GFX_DIRECTX_WIN driver, fixed a Windows sub bitmap + locking bug, added Windows desktop_color_depth and yield_timeslice + routines, and made extensive modifications to other aspects of the + Windows code. + +

+ Ivan Baldo (lubaldo at adinet dot com dot uy).
+ Wrote the 15/16 bit dithering code and optimised the sprite rotation + routines. + +

+ Jaime Moreno (daviangel at hotmail dot com).
+ Helped track down a problem with dependency generation in MacOS X. + +

+ Jakub Wasilewski (krajzega at meditech dot pl).
+ Fixed a bug when loading greyscale TGA images. + +

+ James Arthur (jaa at arfa dot clara dot net).
+ Documented the Photoshop-style truecolor blender routines. + +

+ James Hyman (frooge at mindless dot com).
+ Added support for quoted strings in the get_config_argv() function and + the dithering code for paletted images. + +

+ James Lohr (email unknown).
+ Fixed a problem with mouse acceleration in fullscreen modes under Windows. + +

+ James Ponder (james at squish dot net).
+ Suggested to remove the DJGPP makefile from the Unix tar archive and + clarified a requirement when cross-compiling from Linux. + +

+ Jan Bruun Andersen (jba-dk at users dot sourceforge dot net).
+ Fixed a compilation problem with Cygwin. + +

+ Jan Hubicka (hubicka at horac dot ta dot jcu dot cz).
+ Vastly improved the speed of the create_rgb_table() function. + +

+ Jason Wilkins (fenix at io dot com).
+ Wrote the quaternion math routines and contributed the BeOS port. + +

+ Javier Gonzalez (xaviergonz at hotmail dot com).
+ Corrected mouse movement speed, made allegro_message() use title from + set_window_title(), added close button hook support and improved + switching in Windows, fixed bad clearing of subbitmaps, made bug + reports and suggestions for improvement, contributed bidirectional + looping support, backward playing support and bugfixes for the + DirectSound driver and did plenty of other things too. + +

+ Jeff Mitchell (email unknown).
+ Fixed the location of grabber.txt in the spec file. + +

+ Jeremiah Blanchard (squirminworm at yahoo dot com).
+ Contributed modifications in order for Allegro to build on Darwin/MacOS X + and updated the build instructions for this new port afterwards. + +

+ Jim Flynn (jflynn at pacbell dot net).
+ Removed floating point calculations from the AWE32 MIDI driver. + +

+ Jim Grainger (Grainger_Jim/world_europe_samuro_WYN-CTV at samsung dot co dot kr).
+ Spotted a broken link in the docs and updated it. + +

+ Jiri Gabriel (email unknown).
+ fixed loading of multiple ranges in a single bitmap with txt fonts and helped + fix an off-by-one mistake for the last glyph in extract_font_range. + +

+ Joaquin Hierro Diaz (Joaquin dot Hierro dot Diaz at fresno dot csic dot es).
+ Made the mapping table for Spanish keyboards. + +

+ Joerg Rueppel (sharky-x at gmx dot net).
+ Added more flexible wildcard matching for object names in dat.exe and + the find_datafile_object() function. + +

+ Johan Peitz (d98peitz at dtek dot chalmers dot se).
+ Fixed and enhanced the Win32 joystick driver, and contributed the 'Alex + the Allegator' icon. + +

+ Johan Venter (leonjventer at bigpond dot com).
+ Fixed some problems with the RSXNT and Mingw32 makefiles. + +

+ John Holden (johnh at psych dot usyd dot edu dot au).
+ Fixed a bug in load_wav(). + +

+ John Utz (Johnut01 at noa dot nintendo dot com).
+ Corrected a wrong assumption about the VRAM layout in the Linux + framebuffer console driver. + +

+ Jon Rafkind (workmin at ccs dot neu dot edu).
+ Added more ASSERTs to the code, implemented the Cohen-Sutherland clipping + algorithm for the line() function and supplied an m4 macro for allegro. + +

+ Jonas Petersen (joXonoX at berlin dot snafu dot de).
+ Added the save_bmp() function and support for the OS/2 BMP format. + +

+ Jonathan Tarbox (jonattar at rocketmail dot com).
+ Wrote the mode-X setup code, the FLI/FLC player and contributed parts of + the joystick handler. + +

+ Jorrit Rouwe (j dot rouwe at cpedu dot rug dot nl).
+ Provided a new and much cooler set of FM instrument definitions for the + Adlib MIDI driver. + +

+ Jose Antonio Luque (skylord at LatinMail dot com).
+ Improved the Windows joystick driver, and optimised the 16-bit blit() and + masked_blit() functions. + +

+ Joshua Heyer (joshua_heyer at yahoo dot com).
+ Wrote the original version of the OSS sound driver. + +

+ J. P. Morris (email unknown).
+ Fixed a bug rest_callback under unix. + +

+ Julien Cugnière (jcugniere at free dot fr).
+ Improved the support for non-blocking menus, fixed a bug related to the + retrieval of the inital volume when no primary buffer was present under + Windows, fixed the crash on exit with the aRts sound driver, added an + X11 message box for allegro_message under X11 and fixed a crash in the GUI + when a dialog was opened while a menu was still open. + +

+ Kalle Toivonen (allegro at korpiq dot iki dot fi).
+ Fixed a bug in _parallelogram_map(). + +

+ Keith Gerdes (kwg at softhome dot net).
+ Fixed the DirectDraw overlay mode driver. + +

+ Kerry High (khigh01 at umr dot edu).
+ Contributed the SNES joypad driver. + +

+ Kester Maddock (dmaddock at xtra dot co dot nz).
+ Wrote the Wingman Warrior joystick driver. + +

+ Knut Pape (Knut_Pape at t-online dot de).
+ Improved the Mingw32 readme file. + +

+ Kronoman X (kronoman_x at hotmail dot com).
+ Added a FAQ entry about the conflict between Allegro headers and the C++ + 'using' directive. + +

+ Krzysztof Krzyzaniak (eloy at arrakis dot cs dot put dot poznan dot pl).
+ Wrote the load_voc() function. + +

+ Laurence Withers (lwithers at users dot sf dot net).
+ Added destroy hook to font structure, worked on const-correctness + throughout the library, implemented the new FONT structure, made + some modules avoid linking dependencies, contributed the dat2c + utility, added two fixed point ratios for converting to and from + radians, added a '-windowed' switch to the grabber, added a new text + API and did plenty of other things too. + +

+ Lee Killough (email unknown).
+ Added the low-level hook routine to the keyboard handler and fixed a + couple of bugs. + +

+ Lennart Rolland (chimeni at hotmail dot com).
+ Contributed the Norwegian message translation. + +

+ Lennart Steinke (lst at steinke dot net).
+ Added the exconfig example, contributed keyboard layout detection code + for Windows and suggested the true colour font rendering. + +

+ Lisa Parratt (lisa at thecommune dot org dot uk).
+ Contributed the SGI Audio Library sound driver, spotted a BSDism that + IRIX doesn't like at all, added IRIX detection and improved the + performances of the SGI audio driver + +

+ Lorenzo Petrone (_lano_ at libero dot it).
+ Contributed the gfxinfo utility, added two FAQ entries, added a + xwin_set_window_name() function to the X11 port, added support for + switch callbacks under X11 and refactored the display switching code. + +

+ Lucas Vignoli Reis (lucasvr at bestway dot com dot br).
+ Added the Portuguese (Brazil) message translation and keyboard mapping. + +

+ Magnus Henoch (mange at freemail dot hu).
+ Made the gfx mode selector keep the current selection as much as possible + and fixed a problem when compiling without 8bpp support. + +

+ Maiolino Carmelo (cmaiolino at ctonline dot it).
+ Added the Italian keyboard mapping table. + +

+ Manni Heumann (manfred dot heumann at uni-bielefeld dot de).
+ Fixed some problems with the German keyboard mapping table. + +

+ Marcel de Kogel (m dot dekogel at student dot utwente dot nl).
+ Not content with fixing my broken MPU-401 driver, Marcel went on to + provide a set of vastly improved drum sounds for the OPL driver, to help + me sort out some problems with reentrant interrupts, to supply the half + of the joystick code that didn't come from Jonathan and to locate a + stupid mistake in my VESA linear framebuffer code. + +

+ Marcel Smit (marcel dot athlon at hccnet dot nl).
+ Corrected a bug that caused errors when drawing persp. correct polygons + facing the screen, corrected an error in the packfile format write-up and + made the show_video_bitmap() method of the Windows windowed driver wait + for a vsync. + +

+ Márcio Fialho (maaf1980 at yahoo dot com dot br).
+ Fixed several issues with the DJGPP port and the VBE/AF driver and fixed + some bugs related to author credits. + +

+ Marco Campinoti (marco at etruscan dot li dot it).
+ Added 15 and 24 bit support to the native Tseng ET4000 driver (now + available as part of the FreeBE/AF project). + +

+ Marco Marmulla (Viper005 at usa dot net).
+ Added 16 bit support to the load_voc() routine. + +

+ Marian Dvorsky (marian at step dot sk).
+ Wrote the Windows GDI interface routines. + +

+ Marius Fodor (iceman at teleport dot com).
+ Added support for the Sidewinder and Gravis GamePad Pro. + +

+ Marek Habersack (grendel at ananke dot amu dot edu dot pl).
+ Did the original Linux console port (brave man: this was the first ever + work done on porting Allegro away from DOS), which is the basis of the + code we are still using today and added support for the more recent + Trident chipsets (now available as part of the FreeBE/AF project). + +

+ Mark Wodrich (mwodric at eleceng dot uct dot ac dot za).
+ The brain behind sub-bitmaps, flicker-free mouse pointers, and the + ability to import GRX .FNT files into the grabber. + +

+ Markus F.X.J. Oberhumer (markus dot oberhumer at jk dot uni-linz dot ac dot at).
+ Fixed the Video-7 scrolling function (now available as part of the + FreeBE/AF project), optimised the color mapping routines, and made many + useful suggestions like the addition of a vid_phys_base field to the + graphics driver structure. + +

+ Martijn Van Lersel (amarillion at yahoo dot com).
+ Fixed an overflow in create_light_table(). + +

+ Martijn Versteegh (m dot versteegh at hccnet dot nl).
+ Added the config hook extension mechanism. + +

+ Mathieu Lafon (mlafon at ifhamy dot insa-lyon dot fr).
+ Added the French keyboard mapping, support for the Pause/PrtScr keys and + changed the key[] table to a normal/extended bitfield. + +

+ Matt Witherspoon (spoon at vt dot edu).
+ Fixed a bug in the scroll() method of the Linux SVGAlib driver. + +

+ Matthew Bowie (catcat at nmt dot edu).
+ Added support for 4-button joysticks. + +

+ Matthew Leverton (matthew at allegro dot cc).
+ Fixed a bug with mouse mickeys in windowed mode under Windows, fixed a + problem with al_find*() and NTFS partitions under Windows, added missing + header files to be installed by the Windows binary distribution, made the + DOS/Windows makefiles use 'copy /B' instead of 'copy', added the detection + of left-hand mouse configuration under Windows, fixed a bug with + pack_fgets(), made an online diff generator and did lots of other things too. + +

+ Maxime Carey (werfu at users dot sourceforge dot net).
+ Contributed the Canada (French) keyboard mapping file. + +

+ Michael Bevin (michael dot bevin at stonebow dot otago dot ac dot nz).
+ Optimised the create_trans_table() function. + +

+ Michael Bukin (M dot A dot Bukin at inp dot nsk dot su).
+ Ported the whole thing to Unix/X, and contributed a _lot_ of patches to + improve the portability, robustness, and performance of pretty much the + entire library. + +

+ Michael Faerber.
+ Pointed out a mistake in the documentation for text_height(). + +

+ Michael Rickmann (mrickma at gwdg dot de).
+ Ported the Windows code to Mingw32. + +

+ Michael Tanczos (webmaster at logic-gate dot com).
+ Fixed some bugs in the FLIC player. + +

+ Michal Mertl (mime at eunet dot cz).
+ Wrote all the 24 bit graphics code, the optimised palette generation + function and a fair amount of the other truecolor stuff too (bitmap + scaling, image loading, etc). + +

+ Michal Molhanec (molhanec at seznam dot cz).
+ Simplified the build instructions for Dev-C++, replaced all occurences + of MingW32 by MinGW in the docs, added an faq section about the giftware + license, fixed problems with long filenames when building for MSVC, + corrected a problem with the Watcom port, added MSVC7 options to the + makefile, fixed a linker problem with the MSVC port, fixed some const + warnings in the grabber code and did plenty of other things too. + +

+ Michail Pishchagin (mblsha at users dot sourceforge dot net).
+ Contributed the ustrnicmp() function. + +

+ Milan Mimica (milan dot mimica1 at pu dot htnet dot hr).
+ Fixed bugs in the keyconf utility, the alsa 9 volume settings and + extract_font_range(), helped fix an off-by-one mistake for the last glyph + in extract_font_range, fixed a bug where a font would be converted to 8 + bit, a bug with is_color_font, made the Linux console driver more robust, + fixed some spin loops in the test program, and added the get_volume and + get_hardware_volume functions, and did plenty of other things too. + +

+ Miran Amon (miran dot amon at gmail dot com).
+ Fixed an undocumented arbitrary limit in get_config_argv() + +

+ Nathan Albury, aka Rubicant (gt4558a at prism dot gatech dot edu).
+ Improved the fire routine in examples/exflame.c (my original version + didn't really look very much like flames :-) and gave me some extremely + useful ideas about how to implement translucency. + +

+ Nathan Smith (white_door at dread dot nl).
+ Implemented the recursive handling of directories for the dat utility. + +

+ Neil Townsend (neil at robots dot ox dot ac dot uk).
+ Improved the accuracy of the timer routines and added the callback + parameters. + +

+ Neil Roy (neilroy at cogeco dot ca).
+ Suggested many improvements to the documentation. + +

+ Neil Walker.
+ Implemented a hardware accelerated stretch_blit() for the Windows DX port, + and fixed a bug with draw_sprite and sub-bitmaps. + +

+ Nicholas Davies (master_goodbytes at hotmail dot com).
+ Made the fix class not trigger warnings with gcc -Weffc++. + +

+ Nick Kochakian (nickk at worldnet dot att dot net).
+ Wrote the DirectSound input driver. + +

+ Ole Laursen (98zOLaw at aalborghus dot dk).
+ Contributed the Danish keyboard mapping table and system message + translation, and made the Unicode utolower() and utoupper() functions + understand the entire 16 bit character set. + +

+ Olivier Blin (oblin at mandriva dot com).
+ Fixed compilation problems for the ModeX driver. + +

+ Olly Betts (olly at muscat dot co dot uk).
+ Modified the djgpp makefile to support cross-compiling on a Linux machine. + +

+ Omar Cornut (cornut at noos dot fr).
+ Spotted an asm locking bug under Windows, bumped the maximum number of + buttons per joystick to 32, fixed the Windows joystick driver to handle a + weird peculiarity of the DirectInput API and improved the handling of + KEY_COLON2 on Japanese keyboards. + +

+ Oscar Giner (O_giner at hotmail dot com).
+ Added the Catalan translation, corrected the Spanish translation, fixed a + bug with binary data exporting in the grabber and fixed a conflict between + the magic main and the MFC. + +

+ Owen Embury (owen at gememail dot demon dot co dot uk).
+ Wrote part of the translucency/lighting code. + +

+ Owen Rudge (alleg at orudge dot freeuk dot com).
+ Contributed a DLL version resource script and the mkdata.bat script. + +

+ Ove Kaaven (ovek at arcticnet dot no).
+ Fixed a bug in the ATI mach64 driver (now available as part of the + FreeBE/AF project), added native truecolor and linear framebuffer support + to the ATI driver, contributed the Norwegian keyboard mapping, and added + MIDI and sample input features to the MPU and SB drivers respectively. + +

+ Paavo Ahola (email unknown).
+ Helped fix a problem with BCC and the C implementations of fixmul. + +

+ Patrick Hogan (patter at iname dot com).
+ Wrote the draw_gouraud_sprite() function, and made Windows audiostreams + work properly. + +

+ Paul Bartrum (bartrum at xtra dot co dot nz).
+ Contributed the ellipse drawing functions. + +

+ Paul Eipper.
+ Reported a bug where libdir from autotools was not used for the modules path. + +

+ Paul Furber (paul at sprintlink dot co dot za).
+ Provided the floating point apply_matrix_f() function. + +

+ Paul Hampson (Paul dot Hampson at Pobox dot Com).
+ Improved and fixed some problems in the SNES gamepad driver. + +

+ Paul Pinault (diskaleg at infonie dot fr).
+ Translated the system error messages into French. + +

+ Pavlos Touboulidis (gtoub at otenet dot gr).
+ Made file_select() able to include or exclude files based on their + attributes. + +

+ Pedro Cardoso (pcardoso at viriato dot ipv dot pt).
+ Contributed the tweaked 80x80 VGA mode. + +

+ Peter Cech (7cech at nw dot fmph dot uniba dot sk).
+ Added grabber support for the 8x8 BIOS font format, support for + hot-swapping between a custom keyboard layout and the standard US + mapping, optimised the alpha sprite blending routines and added non-ASCII + space recognition to uisspace(). + +

+ Peter Hull (peterhull90 at users dot sourceforge dot net).
+ Made the file selector work with directories that have more than 2048 + files, solved some compiling issues on MacOS X, fixed a bug in rest() + that caused it to wait too long on that platform, fixed several problems + with the hardware mouse cursor, fixed a deadlock in the software mouse + updating code, fixed compilation problems under MacOS X tiger, added a + MacOS X helpfile and did plenty of other things too. + +

+ Peter Johansson (email unknown).
+ Reported a problem with system cursors not working in Windows. + +

+ Peter Monks (pmonks at iname dot com).
+ Wrote the Video-7 graphics driver (now available as part of the FreeBE/AF + project) and showed me how to set up the unchained 640x400 mode. + +

+ Peter Palotas (blizzar at hem1 dot passagen dot se).
+ Added the keyboard callback routine. + +

+ Peter Pavlovic (Peter dot Pavlovic at st dot fmph dot uniba dot sk).
+ Added the Slovak keyboard mapping and message translation, stopped the + DOS file selector from listing virtual drives, did the same for the + Windows file selector, improved the support for accented character maps in + the keyboard driver and made aesthetic modifications to the GUI menu + system. + +

+ Peter Puck (zaqhaq at netscape dot net).
+ Helped with the Mingw32 native build. + +

+ Peter Wang (tjaden at users dot sourceforge dot net).
+ Added the mouse_z wheel input support to the Linux code, fixed problems + with the ESD sound driver, wrote the ALSA sound driver, wrote the BeOS + sound driver, added OSS MIDI and sample input support, added banked mode + support to the SVGAlib driver, wrote the X DGA mode switching code, + improved the Linux joystick driver, X11 fullscreen, DGA2 and DGA driver, + added pthread timers under Linux/Unix and did loads of other things too. + +

+ Phil Frisbie, Jr. (pfrisbie at geocities dot com).
+ Wrote the CPU type detection code. + +

+ Phil Shenk (email unknown).
+ Improved the MSVC build instructions. + +

+ Philipp Thomas (pthomas at suse dot de).
+ Fixed all comparisons between signed and unsigned types, fixed compilation + on x86-64, fixed all function prototypes, converted the configure + machinery to autoconf 2.53 or later and added multi-arch support, DESTDIR + support and the German translation to the RPM spec file. + +

+ Przemek Podsiadly (ppodsiad at elka dot pw dot edu dot pl).
+ Added hicolor versions of the 3d polygon code. + +

+ Revin Guillen (revin at phylo dot com).
+ Added the position_dialog() function. + +

+ Richard Davies (richard at debaser dot force9 dot co dot uk).
+ Added support for PSX and N64 joypads. + +

+ Richard Mitton (100740 dot 1271 at compuserve dot com).
+ Added support for 6-button joysticks, and wrote the 12-bit color example + program (ex12bit.c). + +

+ Richard Reeve (r dot e dot reeve at stir dot ac dot uk).
+ Fixed a silly mistake with gcc 3.0.x detection. + +

+ Robert J. Ragno (rjr at mit dot edu).
+ Wrote the Gravis GrIP driver, made some improvements to the Wingman, PSX + and throttle input code. + +

+ Robert J. Ohannessian (voidstar at ifrance dot com).
+ Added MMX optimisation for the 8 and 16-bit clear() functions, fixed bad + clearing of subbitmaps, added SSE detection and optimised some masked + blits with SSE instructions, added some routines to the unified color + convertor and made some of them more robust, fixed the docs for + pivot_scaled_sprite_v_flip(), revamped the retrieval mechanism of CPU + capabilities, separated the CSS file and did plenty of other things too. + +

+ Roberto Alfonso (rpgrca at labint dot frba dot utn dot edu dot ar).
+ Fixed a couple of memory problems in the dat2c utility, added an + srand() call in the demo game, made the MSVC port call `link /lib' + rather than `lib', fixed several warnings with GCC 4 under DJGPP and + fixed a grabber crash when importing a font range in an existing font. + +

+ Robin Burrows (rburrows at bigfoot dot com).
+ Provided a new page flipping code for the DirectDraw subsytem, added a + Windows sound driver using the Allegro mixer and another using waveOut, + fixed two glitches in the DirectDraw code. + +

+ Romano Signorelli (romanos at bigfoot dot com).
+ Added an arc plotting routine. + +

+ Ron Novy
+ Made several improvements to the test program. + +

+ Ronaldo Hideki Yamada (r dot yamada at uol dot com dot br).
+ Contributed the MacOS 9 port of Allegro. + +

+ Ryan Patterson.
+ Some documentation fixes. + +

+ S.Sakamaki (emt at geocities dot co dot jp).
+ Added the VESA 3.0 refresh rate control code. + +

+ S.Suzuki (s-suz at sunfield dot ne dot jp).
+ Wrote the IF-SEGA /PCI, /PCI2, and /ISA joystick interface drivers. + +

+ Salvador Eduardo Tropea (salvador at inti dot edu dot ar).
+ Improved the keyboard routines (better handling of extended scancodes, + keyboard LED support, capslock and numlock, and alt+numpad input), + contributed the 320x100 VGA graphics mode, added support for proper 16 + bit sample mixing, fixed compilation on gcc 3.x and made numerous other + useful suggestions, contributions and bugfixes. + +

+ Sam Hocevar (sam at zoy dot org).
+ Fixed a Bashism in fix.sh that makes Solaris' sh choke, a race + condition in the mixer under Unix w/ threads, Windows, BeOS and MacOS X, + a crash in makedoc, made it possible to put functions from .s sources + in a shared library under Unix and removed deprecated use of several + functions. + +

+ Santeri Saarimaa (gridle at mbnet dot fi).
+ Made the Finnish keyboard mapping. + +

+ Sask Allegro (sask_allegro at iespana dot es).
+ Added support for more than two joysticks in the Windows port. + +

+ Scott Harrison (scotth at calderauk dot com).
+ Added the OpenDOS detection code. + +

+ Sean Gugler (sean at epal dot com).
+ Added the set_leds() function. + +

+ Seunghwan Ji (email unknown).
+ Made makedoc output correct html and rtf files for Korean. + +

+ Serge Semashko (serge at lxnt dot info).
+ Fixed a bug with the letter P in the Russian keyboard configuration + file, added Enter as a fire key to the demo game, fixed some + problems with Allegro working on Nokia 770, and fixed a crash in + _linear_draw_trans_rgba_rle_sprite24. + +

+ Seymour Shlien (seymour at dgbt dot doc dot ca).
+ Contributed the Windows BMP file reader, bezier spline drawer, and + justified text plotting function. + +

+ Shawn Hargreaves (shawn at talula dot demon dot co dot uk).
+ Progenitor. Wrote everything that wasn't written by somebody else. + +

+ Shawn Walker (binarycrusader at gmail dot com).
+ Several fixes to the .spec file, made get_executable_name use getexecname() + under Solaris, fixed a bug in the keyboard driver that caused crashes on + the same system, worked around errors with some versions of GNU AS and fixed + errors in the configure script when not using GCC + +

+ StApostol (stapostol at gmail dot com).
+ Fixed a bug in the exflame example and updated the FAQ to use rest(0) instead + of yield_timeslice(). + +

+ Stefan Eilert (seilert at rz dot Uni-Osnabrueck dot DE).
+ Added support for a second joystick. + +

+ Stefan Schimanski (1Stein at gmx dot de).
+ Wrote the original Windows version pretty much single-handedly. + +

+ Stefan T. Boettner (virtual dot man at t-online dot de).
+ Wrote the Linux SVGAlib driver. + +

+ Stepan Roh (src at srnet dot cz).
+ Added a Czech keyboard mapping and system message translation, the Latin + Extended-A characters in the default font, the codepage support in the + textconv utility, fixed some problems with the ESD sound driver, helped + make Allegro build better on some Unix platforms, fixed const related + problems in C versions of routines and added support for a automake-style + DESTDIR variable in the Unix makefile. + +

+ Stephan Brauss (sbrauss at optronic dot ch).
+ Made a few fixes to let the Linux port compile again on Linux 2.2.x, + corrected a few nits in the Swiss keyboard configuration file and added + new keysyms to the X11-to-BIOS conversion table in order to catch missing + keycodes for the keypad when NumLock is on. + +

+ Stephen Kittelson (stickman2000 at juno dot com).
+ Made bugfixes and tweaks to the keyboard system. + +

+ Stijn Wolters.
+ Clarified the documentation of init_dialog. + +

+ Sveinung Kvilhaugsvik(email unknown).
+ Pointed out that Allegro should respect DESTDIR under MacOS X. + +

+ Sven Sandberg (svens at it dot uu dot se).
+ Fixed a problem with save_bitmap() rounding the image widths, optimised + the create_light_table() function, optimised the fixed point trigonometric + routines, provided the Swedish message translations, improved the file + selector sorting algorithm, optimised the spline routines, added + ustrrchr(), improved the usprintf() handling of floats, changed the + Z-buffer API, and did plenty of other things too. + +

+ TBD/FeR (tbd at usa dot net).
+ Added the 320x600 and 360x600 resolutions to the mode-X driver. + +

+ Teijo Hakala (teijo dot hakala at imnetti dot fi).
+ Added wheel support to the Windows mouse driver. + +

+ Tero Parvinen (Tero dot Parvinen at hut dot fi).
+ Designed most of the new sound API. + +

+ Theuzifan Sumachingun (uzi at simauria dot upv dot es).
+ Improved the cpu detection for Cyrix chips and made the file selector + only list valid drive letters. + +

+ Thomas Fjellstrom (tfjellstrom at home dot com).
+ Wrote the ALSA 0.5.x MIDI driver and added support for ALSA 0.9.x. + +

+ Thomas Harte (email unknown).
+ Helped fix a bug in show_video_bitmap() on MacOS X, helped optimise + fixmul(), helped find many bugs in the MacOS X port, like better support + for user-supplied Nibs, implemented a hardware accelerated stretch_blit + under DirectX, and fixed a bug with draw_sprite and sub-bitmaps. + +

+ Thomas Klausner (wiz at danbala dot ifoer dot tuwien dot ac dot at).
+ Added NetBSD detection and fixed a problem with the allegro.m4 macro and + automake 1.8+. + +

+ Thomas Wolf (two at chello dot at).
+ Corrected some errors in the German keyboard mapping and added the + German translation of the system messages. + +

+ Tim Bird (tbird at caldera dot com).
+ Worked on the Linux console port. + +

+ Tim Gunn (timgunn at eastwind dot com dot au).
+ Wrote the TGA reading/writing routines. + +

+ Timothy Terriberry (sundance at sprintmail dot com).
+ Fixed several bugs in the RGB <-> HSV conversion routines. + +

+ Tobi Vollebregt (email unknown).
+ Spotted a bug in ustrerror(), which was not returning a pointer to + a static buffer, reported a problem with shutdown_dialog() when a + menu was open, helped port the Windows keyboard driver to Windows 98 + and fixed a bug with hardware cursor detection in X11. + +

+ Tobias Dammers.
+ Fixed a problem with the DirectSound input driver. + +

+ Tom Breton (tob at world dot std dot com).
+ Added the functionality selection #ifndefs to allegro.h. + +

+ Tom Novelli (tnovelli at cyber3 dot servtech dot com).
+ Wrote the original version of the digital MIDI driver. + +

+ Tom St Denis (tomstdenis at yahoo dot com).
+ Fixed clipping of transparent objects. + +

+ Tomohiko Sugiura (tmsugi at d4 dot dion dot ne dot jp).
+ Added the KEY_ABNT_C1, KEY_YEN, KEY_KANA, KEY_CONVERT, KEY_NOCONVERT + and other keys to the input handler, organised getting the IF-SEGA + joystick drivers by S.Suzuki merged into my codebase and added a more + aggressive Sidewinder joystick driver. + +

+ Tore Halse (gnolam at gmail dot com).
+ Made Allegro windows always popup centred in Windows and made fixes to the + documentation. + +

+ V Karthik Kumar (karthikkumar at gmail dot com).
+ Added a Tamil language greeting to exunicode, added switches to use + the Intel compiler in Windows and added a password option to the Windows + screensaver example. + +

+ Victor Williams Stafusa da Silva (vwss1984 at yahoo dot com dot br).
+ Changed a few occurences of "256" to PAL_SIZE and made OS type detection + handle Windows 2003 and Windows Vista. + +

+ Ville Skyttä (scop at users dot sourceforge dot net).
+ Fixed a problem with make install libdir= and modules on Unix systems. + +

+ Vincent Penquerc'h (lyrian at kezako dot net).
+ Added the D_DIRTY flag and mouse button press/release events to the GUI + system, optimised the 256 to truecolor blitting code to avoid repeated + conversions of the palette table, added scare_mouse_area(), added the + yield_timeslice() function, added the update selection function to the + grabber, added the XCRP and YCRP properties to datafiles in general, + implemented the big header split and did plenty of other things too. + +

+ Vitaliy Chetverikov (email unknown).
+ Fixed a bug in the GUI where the return value of MSG_IDLE was ignored. + +

+ VolkerOth (VolkerOth at aol dot com).
+ Integrated the concepts of scrolling and edit_proc objects. + + + +


+

Thanks!

+ +

+ First, a big thank you to all the people who help me test and debug this + code. It sometimes gets frustrating to receive hundreds of messages + saying "it doesn't work!", but they are useful all the same... + +

+ Andre Baresel (baresel at informatik dot hu-berlin dot de), + and Craig Jackson (Craig dot Jackson at launchpad dot unc dot edu), + provided a tremendous amount of information about SB hardware. + +

+ Benji York (Benji at cookeville dot com).
+ Provided hardware information for the Gravis GamePad Pro. + +

+ Charles Mac Donald (cgfm2 at hooked dot net).
+ Showed me how to set some cool tweaked VGA and mode-X resolutions. + +

+ Charles Sandmann (sandmann at clio dot rice dot edu), + DJ Delorie (dj at delorie dot com), + Eli Zaretskii (eliz at is dot elta dot co dot il), + and everyone else who has contributed to djgpp. I love it. + +

+ C. Schwerdtfeger (schwerdt at physics dot ubc dot ca), + for his help (and enourmous patience!) in getting the SB Pro-I MIDI + driver to work. + +

+ Finn Thoegersen, Nordbanevej 3 C, DK-7800 Skive, Denmark.
+ Most of my SVGA hardware information came from his VGADOC package. + +

+ Eric Jorgensen (smeagol at rt66 dot com).
+ Varmint's Audio Tools (VAT) gave me many useful ideas about how to play + MIDI files. + +

+ Jamie O'Connell (JamieOConnell at msn dot com).
+ Several of the new Adlib drum patches, and the specifications for the + .IBK file format, came from his SBTimbre package. + +

+ Jean-Paul Mikkers (mikmak at stack dot urc dot tue dot nl).
+ MikMod was the source of a lot of information about programming the SB, + and also gave me the idea of dynamically reprogramming the PIT to get a + really high resolution timer. + +

+ Joel H. Hunter (jhunter at kendaco dot telebyte dot com).
+ His SB library for djgpp is excellent, and helped me a lot. + +

+ John Pollard (74723 dot 1626 at compuserve dot com).
+ The FM instrument definitions are based on his MID-KIT library. + +

+ Kendall Bennett and all the other cool people at SciTech Software.
+ These guys gave the world UniVBE, the VBE/AF API, and a lot of free + information and example code. Plus they very kindly sent me a copy of the + VBE/AF spec when I wanted one. + +

+ Kris Heidenstrom (kheidens at actrix dot gen dot nz).
+ His PC timing FAQ was a big help. + +

+ Mark Feldman.
+ It goes without saying that the PCGPE was an invaluable resource. + +

+ Michael Abrash.
+ You just gotta love that man... + +

+ Paul Fenwick (bg914 at freenet dot carleton dot ca).
+ Various bits of the mode-X code (notably the split screen stuff) came + from his XLIBDJ library. + +

+ powerjaw (powerjaw at dnai dot com).
+ Sent me a Sidewinder gamepad so I could fix some problems with the driver + for it. What a cool thing to do... + +

+ Robert Grubbs (rwgrubbs at vt dot edu).
+ Provided hardware information for the Sidewinder joypad. + +

+ Robert Schmidt (robert at stud dot unit dot no).
+ The register values for the 400x* mode-X resolutions came from his TWEAK + program. + +

+ Sourceforge.net (http://sourceforge.net/).
+ The Allegro community has been using their services (web, mailing lists, + cvs, etc) since 3.9.x WIP versions. + +

+ Tom Grandgent (tgrand at canvaslink dot com).
+ Organised and hosted the original Allegro mailing lists for many years. + Hurrah! + +

+ Vladimir Arnost (xarnos00 at dcse dot fee dot vutbr dot cz).
+ Provided hardware specs for the OPL3 chip. + +

+ Frank Zappa, Mike Keneally, Pink Floyd, the Doors, Tori Amos, and all the + other great musicians who provide me with things to listen to while I am + programming. + +

+ My parents, John and Nancy.
+ I would never have made it through all those late night coding sessions + without the cafetiere they gave me last Christmas :-) + + +


+ By Shawn Hargreaves, Allegro creator. + + + + + diff --git a/lib/allegro/bin/alld42.dll b/lib/allegro/bin/alld42.dll new file mode 100644 index 0000000..79064be Binary files /dev/null and b/lib/allegro/bin/alld42.dll differ diff --git a/lib/allegro/bin/alleg42.dll b/lib/allegro/bin/alleg42.dll new file mode 100644 index 0000000..4237422 Binary files /dev/null and b/lib/allegro/bin/alleg42.dll differ diff --git a/lib/allegro/bin/allp42.dll b/lib/allegro/bin/allp42.dll new file mode 100644 index 0000000..89d5d1c Binary files /dev/null and b/lib/allegro/bin/allp42.dll differ diff --git a/lib/allegro/include/allegro.h b/lib/allegro/include/allegro.h new file mode 100644 index 0000000..8df1804 --- /dev/null +++ b/lib/allegro/include/allegro.h @@ -0,0 +1,82 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Main header file for the entire Allegro library. + * (separate modules can be included from the allegro/ directory) + * + * By Shawn Hargreaves. + * + * Vincent Penquerc'h split the original allegro.h into separate headers. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_H +#define ALLEGRO_H + +#include "allegro/base.h" + +#include "allegro/system.h" +#include "allegro/debug.h" + +#include "allegro/unicode.h" + +#include "allegro/mouse.h" +#include "allegro/timer.h" +#include "allegro/keyboard.h" +#include "allegro/joystick.h" + +#include "allegro/palette.h" +#include "allegro/gfx.h" +#include "allegro/color.h" +#include "allegro/draw.h" +#include "allegro/rle.h" +#include "allegro/compiled.h" +#include "allegro/text.h" +#include "allegro/font.h" + +#include "allegro/fli.h" +#include "allegro/config.h" +#include "allegro/gui.h" + +#include "allegro/sound.h" + +#include "allegro/file.h" +#include "allegro/lzss.h" +#include "allegro/datafile.h" + +#include "allegro/fixed.h" +#include "allegro/fmaths.h" +#include "allegro/matrix.h" +#include "allegro/quat.h" + +#include "allegro/3d.h" +#include "allegro/3dmaths.h" + + +#ifndef ALLEGRO_NO_COMPATIBILITY + #include "allegro/alcompat.h" +#endif + +#ifndef ALLEGRO_NO_FIX_CLASS + #ifdef __cplusplus + #include "allegro/fix.h" + #endif +#endif + + +#ifdef ALLEGRO_EXTRA_HEADER + #include ALLEGRO_EXTRA_HEADER +#endif + +#endif /* ifndef ALLEGRO_H */ + + diff --git a/lib/allegro/include/allegro/3d.h b/lib/allegro/include/allegro/3d.h new file mode 100644 index 0000000..8daed76 --- /dev/null +++ b/lib/allegro/include/allegro/3d.h @@ -0,0 +1,104 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * 3D polygon drawing routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_3D_H +#define ALLEGRO_3D_H + +#include "base.h" +#include "fixed.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct BITMAP; + +typedef struct V3D /* a 3d point (fixed point version) */ +{ + fixed x, y, z; /* position */ + fixed u, v; /* texture map coordinates */ + int c; /* color */ +} V3D; + + +typedef struct V3D_f /* a 3d point (floating point version) */ +{ + float x, y, z; /* position */ + float u, v; /* texture map coordinates */ + int c; /* color */ +} V3D_f; + + +#define POLYTYPE_FLAT 0 +#define POLYTYPE_GCOL 1 +#define POLYTYPE_GRGB 2 +#define POLYTYPE_ATEX 3 +#define POLYTYPE_PTEX 4 +#define POLYTYPE_ATEX_MASK 5 +#define POLYTYPE_PTEX_MASK 6 +#define POLYTYPE_ATEX_LIT 7 +#define POLYTYPE_PTEX_LIT 8 +#define POLYTYPE_ATEX_MASK_LIT 9 +#define POLYTYPE_PTEX_MASK_LIT 10 +#define POLYTYPE_ATEX_TRANS 11 +#define POLYTYPE_PTEX_TRANS 12 +#define POLYTYPE_ATEX_MASK_TRANS 13 +#define POLYTYPE_PTEX_MASK_TRANS 14 +#define POLYTYPE_MAX 15 +#define POLYTYPE_ZBUF 16 + +AL_VAR(float, scene_gap); + +AL_FUNC(void, _soft_polygon3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, V3D *vtx[])); +AL_FUNC(void, _soft_polygon3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, V3D_f *vtx[])); +AL_FUNC(void, _soft_triangle3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D *v1, V3D *v2, V3D *v3)); +AL_FUNC(void, _soft_triangle3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D_f *v1, V3D_f *v2, V3D_f *v3)); +AL_FUNC(void, _soft_quad3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D *v1, V3D *v2, V3D *v3, V3D *v4)); +AL_FUNC(void, _soft_quad3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D_f *v1, V3D_f *v2, V3D_f *v3, V3D_f *v4)); +AL_FUNC(int, clip3d, (int type, fixed min_z, fixed max_z, int vc, AL_CONST V3D *vtx[], V3D *vout[], V3D *vtmp[], int out[])); +AL_FUNC(int, clip3d_f, (int type, float min_z, float max_z, int vc, AL_CONST V3D_f *vtx[], V3D_f *vout[], V3D_f *vtmp[], int out[])); + +AL_FUNC(fixed, polygon_z_normal, (AL_CONST V3D *v1, AL_CONST V3D *v2, AL_CONST V3D *v3)); +AL_FUNC(float, polygon_z_normal_f, (AL_CONST V3D_f *v1, AL_CONST V3D_f *v2, AL_CONST V3D_f *v3)); + +/* Note: You are not supposed to mix ZBUFFER with BITMAP even though it is + * currently possible. This is just the internal representation, and it may + * change in the future. + */ +typedef struct BITMAP ZBUFFER; + +AL_FUNC(ZBUFFER *, create_zbuffer, (struct BITMAP *bmp)); +AL_FUNC(ZBUFFER *, create_sub_zbuffer, (ZBUFFER *parent, int x, int y, int width, int height)); +AL_FUNC(void, set_zbuffer, (ZBUFFER *zbuf)); +AL_FUNC(void, clear_zbuffer, (ZBUFFER *zbuf, float z)); +AL_FUNC(void, destroy_zbuffer, (ZBUFFER *zbuf)); + +AL_FUNC(int, create_scene, (int nedge, int npoly)); +AL_FUNC(void, clear_scene, (struct BITMAP* bmp)); +AL_FUNC(void, destroy_scene, (void)); +AL_FUNC(int, scene_polygon3d, (int type, struct BITMAP *texture, int vx, V3D *vtx[])); +AL_FUNC(int, scene_polygon3d_f, (int type, struct BITMAP *texture, int vx, V3D_f *vtx[])); +AL_FUNC(void, render_scene, (void)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_3D_H */ + + diff --git a/lib/allegro/include/allegro/3dmaths.h b/lib/allegro/include/allegro/3dmaths.h new file mode 100644 index 0000000..3977892 --- /dev/null +++ b/lib/allegro/include/allegro/3dmaths.h @@ -0,0 +1,64 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * 3D oriented math routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_3DMATHS_H +#define ALLEGRO_3DMATHS_H + +#include "base.h" +#include "fixed.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct QUAT; +struct MATRIX_f; + +AL_FUNC(fixed, vector_length, (fixed x, fixed y, fixed z)); +AL_FUNC(float, vector_length_f, (float x, float y, float z)); + +AL_FUNC(void, normalize_vector, (fixed *x, fixed *y, fixed *z)); +AL_FUNC(void, normalize_vector_f, (float *x, float *y, float *z)); + +AL_FUNC(void, cross_product, (fixed x1, fixed y_1, fixed z1, fixed x2, fixed y2, fixed z2, fixed *xout, fixed *yout, fixed *zout)); +AL_FUNC(void, cross_product_f, (float x1, float y_1, float z1, float x2, float y2, float z2, float *xout, float *yout, float *zout)); + +AL_VAR(fixed, _persp_xscale); +AL_VAR(fixed, _persp_yscale); +AL_VAR(fixed, _persp_xoffset); +AL_VAR(fixed, _persp_yoffset); + +AL_VAR(float, _persp_xscale_f); +AL_VAR(float, _persp_yscale_f); +AL_VAR(float, _persp_xoffset_f); +AL_VAR(float, _persp_yoffset_f); + +AL_FUNC(void, set_projection_viewport, (int x, int y, int w, int h)); + +AL_FUNC(void, quat_to_matrix, (AL_CONST struct QUAT *q, struct MATRIX_f *m)); +AL_FUNC(void, matrix_to_quat, (AL_CONST struct MATRIX_f *m, struct QUAT *q)); + +#ifdef __cplusplus + } +#endif + +#include "inline/3dmaths.inl" + +#endif /* ifndef ALLEGRO_3DMATHS_H */ + + diff --git a/lib/allegro/include/allegro/alcompat.h b/lib/allegro/include/allegro/alcompat.h new file mode 100644 index 0000000..e302bfd --- /dev/null +++ b/lib/allegro/include/allegro/alcompat.h @@ -0,0 +1,237 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Backward compatibility stuff. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_COMPAT_H +#define ALLEGRO_COMPAT_H + +#ifdef __cplusplus + extern "C" { +#endif + + +#ifndef ALLEGRO_LIB_BUILD + + #ifndef ALLEGRO_NO_CLEAR_BITMAP_ALIAS + #if (defined ALLEGRO_GCC) + static __attribute__((unused)) __inline__ void clear(BITMAP *bmp) + { + clear_bitmap(bmp); + } + #else + static INLINE void clear(BITMAP *bmp) + { + clear_bitmap(bmp); + } + #endif + #endif + + #ifndef ALLEGRO_NO_FIX_ALIASES + AL_ALIAS(fixed fadd(fixed x, fixed y), fixadd(x, y)) + AL_ALIAS(fixed fsub(fixed x, fixed y), fixsub(x, y)) + AL_ALIAS(fixed fmul(fixed x, fixed y), fixmul(x, y)) + AL_ALIAS(fixed fdiv(fixed x, fixed y), fixdiv(x, y)) + AL_ALIAS(int fceil(fixed x), fixceil(x)) + AL_ALIAS(int ffloor(fixed x), fixfloor(x)) + AL_ALIAS(fixed fcos(fixed x), fixcos(x)) + AL_ALIAS(fixed fsin(fixed x), fixsin(x)) + AL_ALIAS(fixed ftan(fixed x), fixtan(x)) + AL_ALIAS(fixed facos(fixed x), fixacos(x)) + AL_ALIAS(fixed fasin(fixed x), fixasin(x)) + AL_ALIAS(fixed fatan(fixed x), fixatan(x)) + AL_ALIAS(fixed fatan2(fixed y, fixed x), fixatan2(y, x)) + AL_ALIAS(fixed fsqrt(fixed x), fixsqrt(x)) + AL_ALIAS(fixed fhypot(fixed x, fixed y), fixhypot(x, y)) + #endif + +#endif /* !defined ALLEGRO_LIB_BUILD */ + + +#define KB_NORMAL 1 +#define KB_EXTENDED 2 + +#define SEND_MESSAGE object_message + +#define cpu_fpu (cpu_capabilities & CPU_FPU) +#define cpu_mmx (cpu_capabilities & CPU_MMX) +#define cpu_3dnow (cpu_capabilities & CPU_3DNOW) +#define cpu_cpuid (cpu_capabilities & CPU_ID) + +#define joy_x (joy[0].stick[0].axis[0].pos) +#define joy_y (joy[0].stick[0].axis[1].pos) +#define joy_left (joy[0].stick[0].axis[0].d1) +#define joy_right (joy[0].stick[0].axis[0].d2) +#define joy_up (joy[0].stick[0].axis[1].d1) +#define joy_down (joy[0].stick[0].axis[1].d2) +#define joy_b1 (joy[0].button[0].b) +#define joy_b2 (joy[0].button[1].b) +#define joy_b3 (joy[0].button[2].b) +#define joy_b4 (joy[0].button[3].b) +#define joy_b5 (joy[0].button[4].b) +#define joy_b6 (joy[0].button[5].b) +#define joy_b7 (joy[0].button[6].b) +#define joy_b8 (joy[0].button[7].b) + +#define joy2_x (joy[1].stick[0].axis[0].pos) +#define joy2_y (joy[1].stick[0].axis[1].pos) +#define joy2_left (joy[1].stick[0].axis[0].d1) +#define joy2_right (joy[1].stick[0].axis[0].d2) +#define joy2_up (joy[1].stick[0].axis[1].d1) +#define joy2_down (joy[1].stick[0].axis[1].d2) +#define joy2_b1 (joy[1].button[0].b) +#define joy2_b2 (joy[1].button[1].b) + +#define joy_throttle (joy[0].stick[2].axis[0].pos) + +#define joy_hat ((joy[0].stick[1].axis[0].d1) ? 1 : \ + ((joy[0].stick[1].axis[0].d2) ? 3 : \ + ((joy[0].stick[1].axis[1].d1) ? 4 : \ + ((joy[0].stick[1].axis[1].d2) ? 2 : \ + 0)))) + +#define JOY_HAT_CENTRE 0 +#define JOY_HAT_CENTER 0 +#define JOY_HAT_LEFT 1 +#define JOY_HAT_DOWN 2 +#define JOY_HAT_RIGHT 3 +#define JOY_HAT_UP 4 + +AL_FUNC_DEPRECATED(int, initialise_joystick, (void)); + + +/* in case you want to spell 'palette' as 'pallete' */ +#define PALLETE PALETTE +#define black_pallete black_palette +#define desktop_pallete desktop_palette +#define set_pallete set_palette +#define get_pallete get_palette +#define set_pallete_range set_palette_range +#define get_pallete_range get_palette_range +#define fli_pallete fli_palette +#define pallete_color palette_color +#define DAT_PALLETE DAT_PALETTE +#define select_pallete select_palette +#define unselect_pallete unselect_palette +#define generate_332_pallete generate_332_palette +#define generate_optimised_pallete generate_optimised_palette + + +/* a pretty vague name */ +#define fix_filename_path canonicalize_filename + + +/* the good old file selector */ +#define OLD_FILESEL_WIDTH -1 +#define OLD_FILESEL_HEIGHT -1 + +AL_INLINE_DEPRECATED(int, file_select, (AL_CONST char *message, char *path, AL_CONST char *ext), +{ + return file_select_ex(message, path, ext, 1024, OLD_FILESEL_WIDTH, OLD_FILESEL_HEIGHT); +}) + + +/* the old (and broken!) file enumeration function */ +AL_FUNC_DEPRECATED(int, for_each_file, (AL_CONST char *name, int attrib, AL_METHOD(void, callback, (AL_CONST char *filename, int attrib, int param)), int param)); +/* long is 32-bit only on some systems, and we want to list DVDs! */ +AL_FUNC_DEPRECATED(long, file_size, (AL_CONST char *filename)); + + +/* the old state-based textout functions */ +AL_VAR(int, _textmode); +AL_FUNC_DEPRECATED(int, text_mode, (int mode)); + +AL_INLINE_DEPRECATED(void, textout, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color), +{ + textout_ex(bmp, f, str, x, y, color, _textmode); +}) + +AL_INLINE_DEPRECATED(void, textout_centre, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color), +{ + textout_centre_ex(bmp, f, str, x, y, color, _textmode); +}) + +AL_INLINE_DEPRECATED(void, textout_right, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x, int y, int color), +{ + textout_right_ex(bmp, f, str, x, y, color, _textmode); +}) + +AL_INLINE_DEPRECATED(void, textout_justify, (struct BITMAP *bmp, AL_CONST FONT *f, AL_CONST char *str, int x1, int x2, int y, int diff, int color), +{ + textout_justify_ex(bmp, f, str, x1, x2, y, diff, color, _textmode); +}) + +AL_PRINTFUNC_DEPRECATED(void, textprintf, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7); +AL_PRINTFUNC_DEPRECATED(void, textprintf_centre, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7); +AL_PRINTFUNC_DEPRECATED(void, textprintf_right, (struct BITMAP *bmp, AL_CONST FONT *f, int x, int y, int color, AL_CONST char *format, ...), 6, 7); +AL_PRINTFUNC_DEPRECATED(void, textprintf_justify, (struct BITMAP *bmp, AL_CONST FONT *f, int x1, int x2, int y, int diff, int color, AL_CONST char *format, ...), 8, 9); + +AL_INLINE_DEPRECATED(void, draw_character, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color), +{ + draw_character_ex(bmp, sprite, x, y, color, _textmode); +}) + +AL_INLINE_DEPRECATED(int, gui_textout, (struct BITMAP *bmp, AL_CONST char *s, int x, int y, int color, int centre), +{ + return gui_textout_ex(bmp, s, x, y, color, _textmode, centre); +}) + + +/* the old close button functions */ +AL_INLINE_DEPRECATED(int, set_window_close_button, (int enable), +{ + (void)enable; + return 0; +}) + +AL_INLINE_DEPRECATED(void, set_window_close_hook, (void (*proc)(void)), +{ + set_close_button_callback(proc); +}) + + +/* the weird old clipping API */ +AL_FUNC_DEPRECATED(void, set_clip, (BITMAP *bitmap, int x1, int y_1, int x2, int y2)); + + +/* unnecessary, can use rest(0) */ +AL_INLINE_DEPRECATED(void, yield_timeslice, (void), +{ + ASSERT(system_driver); + + if (system_driver->yield_timeslice) + system_driver->yield_timeslice(); +}) + + +/* DOS-ish monitor retrace ideas that don't work elsewhere */ +AL_FUNCPTR(void, retrace_proc, (void)); + +#ifdef ALLEGRO_LIB_BUILD + AL_FUNC(int, timer_can_simulate_retrace, (void)); + AL_FUNC(void, timer_simulate_retrace, (int enable)); +#else + AL_FUNC_DEPRECATED(int, timer_can_simulate_retrace, (void)); + AL_FUNC_DEPRECATED(void, timer_simulate_retrace, (int enable)); +#endif +AL_FUNC_DEPRECATED(int, timer_is_using_retrace, (void)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_COMPAT_H */ + diff --git a/lib/allegro/include/allegro/alinline.h b/lib/allegro/include/allegro/alinline.h new file mode 100644 index 0000000..0efa507 --- /dev/null +++ b/lib/allegro/include/allegro/alinline.h @@ -0,0 +1,34 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#include "inline/system.inl" + +#include "inline/gfx.inl" + +#include "inline/color.inl" + +#include "inline/draw.inl" + +#include "inline/fmaths.inl" + +#include "inline/3dmaths.inl" + +#include "inline/matrix.inl" + +/* alcompat.h includes some inline functions */ +#include "alcompat.h" diff --git a/lib/allegro/include/allegro/base.h b/lib/allegro/include/allegro/base.h new file mode 100644 index 0000000..a436f1d --- /dev/null +++ b/lib/allegro/include/allegro/base.h @@ -0,0 +1,95 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Base header, defines basic stuff needed by pretty much + * everything else. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_BASE_H +#define ALLEGRO_BASE_H + +#ifndef ALLEGRO_NO_STD_HEADERS + #include + #include + #include + #include + #include + #include +#endif + +#if (defined DEBUGMODE) && (defined FORTIFY) + #include +#endif + +#if (defined DEBUGMODE) && (defined DMALLOC) + #include +#endif + +#include "internal/alconfig.h" + +#ifdef __cplusplus + extern "C" { +#endif + +#define ALLEGRO_VERSION 4 +#define ALLEGRO_SUB_VERSION 2 +#define ALLEGRO_WIP_VERSION 1 +#define ALLEGRO_VERSION_STR "4.2.1" +#define ALLEGRO_DATE_STR "2006" +#define ALLEGRO_DATE 20061126 /* yyyymmdd */ + +/*******************************************/ +/************ Some global stuff ************/ +/*******************************************/ + +#ifndef TRUE + #define TRUE -1 + #define FALSE 0 +#endif + +#undef MIN +#undef MAX +#undef MID + +#define MIN(x,y) (((x) < (y)) ? (x) : (y)) +#define MAX(x,y) (((x) > (y)) ? (x) : (y)) +#define MID(x,y,z) MAX((x), MIN((y), (z))) + +#undef ABS +#define ABS(x) (((x) >= 0) ? (x) : (-(x))) + +#undef SGN +#define SGN(x) (((x) >= 0) ? 1 : -1) + +#define AL_PI 3.14159265358979323846 + +#define AL_ID(a,b,c,d) (((a)<<24) | ((b)<<16) | ((c)<<8) | (d)) + +AL_VAR(int *, allegro_errno); + +typedef struct _DRIVER_INFO /* info about a hardware driver */ +{ + int id; /* integer ID */ + void *driver; /* the driver structure */ + int autodetect; /* set to allow autodetection */ +} _DRIVER_INFO; + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_BASE_H */ + + diff --git a/lib/allegro/include/allegro/color.h b/lib/allegro/include/allegro/color.h new file mode 100644 index 0000000..46dbd61 --- /dev/null +++ b/lib/allegro/include/allegro/color.h @@ -0,0 +1,155 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Color manipulation routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_COLOR_H +#define ALLEGRO_COLOR_H + +#include "base.h" +#include "palette.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct BITMAP; + +AL_VAR(PALETTE, black_palette); +AL_VAR(PALETTE, desktop_palette); +AL_VAR(PALETTE, default_palette); + +typedef struct { + unsigned char data[32][32][32]; +} RGB_MAP; + +typedef struct { + unsigned char data[PAL_SIZE][PAL_SIZE]; +} COLOR_MAP; + +AL_VAR(RGB_MAP *, rgb_map); +AL_VAR(COLOR_MAP *, color_map); + +AL_VAR(PALETTE, _current_palette); + +AL_VAR(int, _rgb_r_shift_15); +AL_VAR(int, _rgb_g_shift_15); +AL_VAR(int, _rgb_b_shift_15); +AL_VAR(int, _rgb_r_shift_16); +AL_VAR(int, _rgb_g_shift_16); +AL_VAR(int, _rgb_b_shift_16); +AL_VAR(int, _rgb_r_shift_24); +AL_VAR(int, _rgb_g_shift_24); +AL_VAR(int, _rgb_b_shift_24); +AL_VAR(int, _rgb_r_shift_32); +AL_VAR(int, _rgb_g_shift_32); +AL_VAR(int, _rgb_b_shift_32); +AL_VAR(int, _rgb_a_shift_32); + +AL_ARRAY(int, _rgb_scale_5); +AL_ARRAY(int, _rgb_scale_6); + +#define MASK_COLOR_8 0 +#define MASK_COLOR_15 0x7C1F +#define MASK_COLOR_16 0xF81F +#define MASK_COLOR_24 0xFF00FF +#define MASK_COLOR_32 0xFF00FF + +AL_VAR(int *, palette_color); + +AL_FUNC(void, set_color, (int idx, AL_CONST RGB *p)); +AL_FUNC(void, set_palette, (AL_CONST PALETTE p)); +AL_FUNC(void, set_palette_range, (AL_CONST PALETTE p, int from, int to, int retracesync)); + +AL_FUNC(void, get_color, (int idx, RGB *p)); +AL_FUNC(void, get_palette, (PALETTE p)); +AL_FUNC(void, get_palette_range, (PALETTE p, int from, int to)); + +AL_FUNC(void, fade_interpolate, (AL_CONST PALETTE source, AL_CONST PALETTE dest, PALETTE output, int pos, int from, int to)); +AL_FUNC(void, fade_from_range, (AL_CONST PALETTE source, AL_CONST PALETTE dest, int speed, int from, int to)); +AL_FUNC(void, fade_in_range, (AL_CONST PALETTE p, int speed, int from, int to)); +AL_FUNC(void, fade_out_range, (int speed, int from, int to)); +AL_FUNC(void, fade_from, (AL_CONST PALETTE source, AL_CONST PALETTE dest, int speed)); +AL_FUNC(void, fade_in, (AL_CONST PALETTE p, int speed)); +AL_FUNC(void, fade_out, (int speed)); + +AL_FUNC(void, select_palette, (AL_CONST PALETTE p)); +AL_FUNC(void, unselect_palette, (void)); + +AL_FUNC(void, generate_332_palette, (PALETTE pal)); +AL_FUNC(int, generate_optimized_palette, (struct BITMAP *image, PALETTE pal, AL_CONST signed char rsvdcols[256])); + +AL_FUNC(void, create_rgb_table, (RGB_MAP *table, AL_CONST PALETTE pal, AL_METHOD(void, callback, (int pos)))); +AL_FUNC(void, create_light_table, (COLOR_MAP *table, AL_CONST PALETTE pal, int r, int g, int b, AL_METHOD(void, callback, (int pos)))); +AL_FUNC(void, create_trans_table, (COLOR_MAP *table, AL_CONST PALETTE pal, int r, int g, int b, AL_METHOD(void, callback, (int pos)))); +AL_FUNC(void, create_color_table, (COLOR_MAP *table, AL_CONST PALETTE pal, AL_METHOD(void, blend, (AL_CONST PALETTE pal, int x, int y, RGB *rgb)), AL_METHOD(void, callback, (int pos)))); +AL_FUNC(void, create_blender_table, (COLOR_MAP *table, AL_CONST PALETTE pal, AL_METHOD(void, callback, (int pos)))); + +typedef AL_METHOD(unsigned long, BLENDER_FUNC, (unsigned long x, unsigned long y, unsigned long n)); + +AL_FUNC(void, set_blender_mode, (BLENDER_FUNC b15, BLENDER_FUNC b16, BLENDER_FUNC b24, int r, int g, int b, int a)); +AL_FUNC(void, set_blender_mode_ex, (BLENDER_FUNC b15, BLENDER_FUNC b16, BLENDER_FUNC b24, BLENDER_FUNC b32, BLENDER_FUNC b15x, BLENDER_FUNC b16x, BLENDER_FUNC b24x, int r, int g, int b, int a)); + +AL_FUNC(void, set_alpha_blender, (void)); +AL_FUNC(void, set_write_alpha_blender, (void)); +AL_FUNC(void, set_trans_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_add_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_burn_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_color_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_difference_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_dissolve_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_dodge_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_hue_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_invert_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_luminance_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_multiply_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_saturation_blender, (int r, int g, int b, int a)); +AL_FUNC(void, set_screen_blender, (int r, int g, int b, int a)); + +AL_FUNC(void, hsv_to_rgb, (float h, float s, float v, int *r, int *g, int *b)); +AL_FUNC(void, rgb_to_hsv, (int r, int g, int b, float *h, float *s, float *v)); + +AL_FUNC(int, bestfit_color, (AL_CONST PALETTE pal, int r, int g, int b)); + +AL_FUNC(int, makecol, (int r, int g, int b)); +AL_FUNC(int, makecol8, (int r, int g, int b)); +AL_FUNC(int, makecol_depth, (int color_depth, int r, int g, int b)); + +AL_FUNC(int, makeacol, (int r, int g, int b, int a)); +AL_FUNC(int, makeacol_depth, (int color_depth, int r, int g, int b, int a)); + +AL_FUNC(int, makecol15_dither, (int r, int g, int b, int x, int y)); +AL_FUNC(int, makecol16_dither, (int r, int g, int b, int x, int y)); + +AL_FUNC(int, getr, (int c)); +AL_FUNC(int, getg, (int c)); +AL_FUNC(int, getb, (int c)); +AL_FUNC(int, geta, (int c)); + +AL_FUNC(int, getr_depth, (int color_depth, int c)); +AL_FUNC(int, getg_depth, (int color_depth, int c)); +AL_FUNC(int, getb_depth, (int color_depth, int c)); +AL_FUNC(int, geta_depth, (int color_depth, int c)); + +#ifdef __cplusplus + } +#endif + +#include "inline/color.inl" + +#endif /* ifndef ALLEGRO_COLOR_H */ + + diff --git a/lib/allegro/include/allegro/compiled.h b/lib/allegro/include/allegro/compiled.h new file mode 100644 index 0000000..46d621b --- /dev/null +++ b/lib/allegro/include/allegro/compiled.h @@ -0,0 +1,62 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Compiled sprites. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_COMPILED_H +#define ALLEGRO_COMPILED_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct BITMAP; + +#if (defined ALLEGRO_I386) && (!defined ALLEGRO_NO_ASM) + +/* compiled sprite structure */ +typedef struct COMPILED_SPRITE +{ + short planar; /* set if it's a planar (mode-X) sprite */ + short color_depth; /* color depth of the image */ + short w, h; /* size of the sprite */ + struct { + void *draw; /* routines to draw the image */ + int len; /* length of the drawing functions */ + } proc[4]; +} COMPILED_SPRITE; + +#else + +/* emulate compiled sprites using RLE on other platforms */ +struct RLE_SPRITE; +typedef struct RLE_SPRITE COMPILED_SPRITE; + +#endif + +AL_FUNC(COMPILED_SPRITE *, get_compiled_sprite, (struct BITMAP *bitmap, int planar)); +AL_FUNC(void, destroy_compiled_sprite, (COMPILED_SPRITE *sprite)); +AL_FUNC(void, draw_compiled_sprite, (struct BITMAP *bmp, AL_CONST COMPILED_SPRITE *sprite, int x, int y)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_COMPILED_H */ + + diff --git a/lib/allegro/include/allegro/config.h b/lib/allegro/include/allegro/config.h new file mode 100644 index 0000000..64539a7 --- /dev/null +++ b/lib/allegro/include/allegro/config.h @@ -0,0 +1,65 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration file access routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_CONFIG_H +#define ALLEGRO_CONFIG_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +AL_FUNC(void, set_config_file, (AL_CONST char *filename)); +AL_FUNC(void, set_config_data, (AL_CONST char *data, int length)); +AL_FUNC(void, override_config_file, (AL_CONST char *filename)); +AL_FUNC(void, override_config_data, (AL_CONST char *data, int length)); +AL_FUNC(void, flush_config_file, (void)); +AL_FUNC(void, reload_config_texts, (AL_CONST char *new_language)); + +AL_FUNC(void, push_config_state, (void)); +AL_FUNC(void, pop_config_state, (void)); + +AL_FUNC(void, hook_config_section, (AL_CONST char *section, AL_METHOD(int, intgetter, (AL_CONST char *, int)), AL_METHOD(AL_CONST char *, stringgetter, (AL_CONST char *, AL_CONST char *)), AL_METHOD(void, stringsetter, (AL_CONST char *, AL_CONST char *)))); +AL_FUNC(int, config_is_hooked, (AL_CONST char *section)); + +AL_FUNC(AL_CONST char *, get_config_string, (AL_CONST char *section, AL_CONST char *name, AL_CONST char *def)); +AL_FUNC(int, get_config_int, (AL_CONST char *section, AL_CONST char *name, int def)); +AL_FUNC(int, get_config_hex, (AL_CONST char *section, AL_CONST char *name, int def)); +AL_FUNC(float, get_config_float, (AL_CONST char *section, AL_CONST char *name, float def)); +AL_FUNC(int, get_config_id, (AL_CONST char *section, AL_CONST char *name, int def)); +AL_FUNC(char **, get_config_argv, (AL_CONST char *section, AL_CONST char *name, int *argc)); +AL_FUNC(AL_CONST char *, get_config_text, (AL_CONST char *msg)); + +AL_FUNC(void, set_config_string, (AL_CONST char *section, AL_CONST char *name, AL_CONST char *val)); +AL_FUNC(void, set_config_int, (AL_CONST char *section, AL_CONST char *name, int val)); +AL_FUNC(void, set_config_hex, (AL_CONST char *section, AL_CONST char *name, int val)); +AL_FUNC(void, set_config_float, (AL_CONST char *section, AL_CONST char *name, float val)); +AL_FUNC(void, set_config_id, (AL_CONST char *section, AL_CONST char *name, int val)); + +AL_FUNC(int, list_config_entries, (AL_CONST char *section, AL_CONST char ***names)); +AL_FUNC(int, list_config_sections, (AL_CONST char ***names)); +AL_FUNC(void, free_config_entries, (AL_CONST char ***names)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_CONFIG_H */ + + diff --git a/lib/allegro/include/allegro/datafile.h b/lib/allegro/include/allegro/datafile.h new file mode 100644 index 0000000..d44e9a3 --- /dev/null +++ b/lib/allegro/include/allegro/datafile.h @@ -0,0 +1,114 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Datafile access routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_DATAFILE_H +#define ALLEGRO_DATAFILE_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct BITMAP; +struct PACKFILE; +struct RGB; + +#define DAT_ID(a,b,c,d) AL_ID(a,b,c,d) + +#define DAT_MAGIC DAT_ID('A','L','L','.') +#define DAT_FILE DAT_ID('F','I','L','E') +#define DAT_DATA DAT_ID('D','A','T','A') +#define DAT_FONT DAT_ID('F','O','N','T') +#define DAT_SAMPLE DAT_ID('S','A','M','P') +#define DAT_MIDI DAT_ID('M','I','D','I') +#define DAT_PATCH DAT_ID('P','A','T',' ') +#define DAT_FLI DAT_ID('F','L','I','C') +#define DAT_BITMAP DAT_ID('B','M','P',' ') +#define DAT_RLE_SPRITE DAT_ID('R','L','E',' ') +#define DAT_C_SPRITE DAT_ID('C','M','P',' ') +#define DAT_XC_SPRITE DAT_ID('X','C','M','P') +#define DAT_PALETTE DAT_ID('P','A','L',' ') +#define DAT_PROPERTY DAT_ID('p','r','o','p') +#define DAT_NAME DAT_ID('N','A','M','E') +#define DAT_END -1 + + +typedef struct DATAFILE_PROPERTY +{ + char *dat; /* pointer to the data */ + int type; /* property type */ +} DATAFILE_PROPERTY; + + +typedef struct DATAFILE +{ + void *dat; /* pointer to the data */ + int type; /* object type */ + long size; /* size of the object */ + DATAFILE_PROPERTY *prop; /* object properties */ +} DATAFILE; + + +typedef struct DATAFILE_INDEX +{ + char *filename; /* datafile name (path) */ + long *offset; /* list of offsets */ +} DATAFILE_INDEX; + + +AL_FUNC(DATAFILE *, load_datafile, (AL_CONST char *filename)); +AL_FUNC(DATAFILE *, load_datafile_callback, (AL_CONST char *filename, AL_METHOD(void, callback, (DATAFILE *)))); +AL_FUNC(DATAFILE_INDEX *, create_datafile_index, (AL_CONST char *filename)); +AL_FUNC(void, unload_datafile, (DATAFILE *dat)); +AL_FUNC(void, destroy_datafile_index, (DATAFILE_INDEX *index)); + +AL_FUNC(DATAFILE *, load_datafile_object, (AL_CONST char *filename, AL_CONST char *objectname)); +AL_FUNC(DATAFILE *, load_datafile_object_indexed, (AL_CONST DATAFILE_INDEX *index, int item)); +AL_FUNC(void, unload_datafile_object, (DATAFILE *dat)); + +AL_FUNC(DATAFILE *, find_datafile_object, (AL_CONST DATAFILE *dat, AL_CONST char *objectname)); +AL_FUNC(AL_CONST char *, get_datafile_property, (AL_CONST DATAFILE *dat, int type)); +AL_FUNC(void, register_datafile_object, (int id_, AL_METHOD(void *, load, (struct PACKFILE *f, long size)), AL_METHOD(void, destroy, (void *data)))); + +AL_FUNC(void, fixup_datafile, (DATAFILE *data)); + +AL_FUNC(struct BITMAP *, load_bitmap, (AL_CONST char *filename, struct RGB *pal)); +AL_FUNC(struct BITMAP *, load_bmp, (AL_CONST char *filename, struct RGB *pal)); +AL_FUNC(struct BITMAP *, load_bmp_pf, (PACKFILE *f, struct RGB *pal)); +AL_FUNC(struct BITMAP *, load_lbm, (AL_CONST char *filename, struct RGB *pal)); +AL_FUNC(struct BITMAP *, load_pcx, (AL_CONST char *filename, struct RGB *pal)); +AL_FUNC(struct BITMAP *, load_pcx_pf, (PACKFILE *f, struct RGB *pal)); +AL_FUNC(struct BITMAP *, load_tga, (AL_CONST char *filename, struct RGB *pal)); +AL_FUNC(struct BITMAP *, load_tga_pf, (PACKFILE *f, struct RGB *pal)); + +AL_FUNC(int, save_bitmap, (AL_CONST char *filename, struct BITMAP *bmp, AL_CONST struct RGB *pal)); +AL_FUNC(int, save_bmp, (AL_CONST char *filename, struct BITMAP *bmp, AL_CONST struct RGB *pal)); +AL_FUNC(int, save_bmp_pf, (PACKFILE *f, struct BITMAP *bmp, AL_CONST struct RGB *pal)); +AL_FUNC(int, save_pcx, (AL_CONST char *filename, struct BITMAP *bmp, AL_CONST struct RGB *pal)); +AL_FUNC(int, save_pcx_pf, (PACKFILE *f, struct BITMAP *bmp, AL_CONST struct RGB *pal)); +AL_FUNC(int, save_tga, (AL_CONST char *filename, struct BITMAP *bmp, AL_CONST struct RGB *pal)); +AL_FUNC(int, save_tga_pf, (PACKFILE *f, struct BITMAP *bmp, AL_CONST struct RGB *pal)); + +AL_FUNC(void, register_bitmap_file_type, (AL_CONST char *ext, AL_METHOD(struct BITMAP *, load, (AL_CONST char *filename, struct RGB *pal)), AL_METHOD(int, save, (AL_CONST char *filename, struct BITMAP *bmp, AL_CONST struct RGB *pal)))); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_DATAFILE_H */ diff --git a/lib/allegro/include/allegro/debug.h b/lib/allegro/include/allegro/debug.h new file mode 100644 index 0000000..87c52d4 --- /dev/null +++ b/lib/allegro/include/allegro/debug.h @@ -0,0 +1,49 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Debug facilities. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_DEBUG_H +#define ALLEGRO_DEBUG_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +AL_FUNC(void, al_assert, (AL_CONST char *file, int linenr)); +AL_PRINTFUNC(void, al_trace, (AL_CONST char *msg, ...), 1, 2); + +AL_FUNC(void, register_assert_handler, (AL_METHOD(int, handler, (AL_CONST char *msg)))); +AL_FUNC(void, register_trace_handler, (AL_METHOD(int, handler, (AL_CONST char *msg)))); + + +#ifdef DEBUGMODE + #define ASSERT(condition) { if (!(condition)) al_assert(__FILE__, __LINE__); } + #define TRACE al_trace +#else + #define ASSERT(condition) + #define TRACE 1 ? (void) 0 : al_trace +#endif + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_DEBUG_H */ + + diff --git a/lib/allegro/include/allegro/digi.h b/lib/allegro/include/allegro/digi.h new file mode 100644 index 0000000..5f4868b --- /dev/null +++ b/lib/allegro/include/allegro/digi.h @@ -0,0 +1,219 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Digital sound routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_DIGI_H +#define ALLEGRO_DIGI_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct PACKFILE; + + +#define DIGI_VOICES 64 /* Theoretical maximums: */ + /* actual drivers may not be */ + /* able to handle this many */ + +typedef struct SAMPLE /* a sample */ +{ + int bits; /* 8 or 16 */ + int stereo; /* sample type flag */ + int freq; /* sample frequency */ + int priority; /* 0-255 */ + unsigned long len; /* length (in samples) */ + unsigned long loop_start; /* loop start position */ + unsigned long loop_end; /* loop finish position */ + unsigned long param; /* for internal use by the driver */ + void *data; /* sample data */ +} SAMPLE; + + +#define DIGI_AUTODETECT -1 /* for passing to install_sound() */ +#define DIGI_NONE 0 + +typedef struct DIGI_DRIVER /* driver for playing digital sfx */ +{ + int id; /* driver ID code */ + AL_CONST char *name; /* driver name */ + AL_CONST char *desc; /* description string */ + AL_CONST char *ascii_name; /* ASCII format name string */ + int voices; /* available voices */ + int basevoice; /* voice number offset */ + int max_voices; /* maximum voices we can support */ + int def_voices; /* default number of voices to use */ + + /* setup routines */ + AL_METHOD(int, detect, (int input)); + AL_METHOD(int, init, (int input, int voices)); + AL_METHOD(void, exit, (int input)); + AL_METHOD(int, set_mixer_volume, (int volume)); + AL_METHOD(int, get_mixer_volume, (void)); + + /* for use by the audiostream functions */ + AL_METHOD(void *, lock_voice, (int voice, int start, int end)); + AL_METHOD(void, unlock_voice, (int voice)); + AL_METHOD(int, buffer_size, (void)); + + /* voice control functions */ + AL_METHOD(void, init_voice, (int voice, AL_CONST SAMPLE *sample)); + AL_METHOD(void, release_voice, (int voice)); + AL_METHOD(void, start_voice, (int voice)); + AL_METHOD(void, stop_voice, (int voice)); + AL_METHOD(void, loop_voice, (int voice, int playmode)); + + /* position control functions */ + AL_METHOD(int, get_position, (int voice)); + AL_METHOD(void, set_position, (int voice, int position)); + + /* volume control functions */ + AL_METHOD(int, get_volume, (int voice)); + AL_METHOD(void, set_volume, (int voice, int volume)); + AL_METHOD(void, ramp_volume, (int voice, int tyme, int endvol)); + AL_METHOD(void, stop_volume_ramp, (int voice)); + + /* pitch control functions */ + AL_METHOD(int, get_frequency, (int voice)); + AL_METHOD(void, set_frequency, (int voice, int frequency)); + AL_METHOD(void, sweep_frequency, (int voice, int tyme, int endfreq)); + AL_METHOD(void, stop_frequency_sweep, (int voice)); + + /* pan control functions */ + AL_METHOD(int, get_pan, (int voice)); + AL_METHOD(void, set_pan, (int voice, int pan)); + AL_METHOD(void, sweep_pan, (int voice, int tyme, int endpan)); + AL_METHOD(void, stop_pan_sweep, (int voice)); + + /* effect control functions */ + AL_METHOD(void, set_echo, (int voice, int strength, int delay)); + AL_METHOD(void, set_tremolo, (int voice, int rate, int depth)); + AL_METHOD(void, set_vibrato, (int voice, int rate, int depth)); + + /* input functions */ + int rec_cap_bits; + int rec_cap_stereo; + AL_METHOD(int, rec_cap_rate, (int bits, int stereo)); + AL_METHOD(int, rec_cap_parm, (int rate, int bits, int stereo)); + AL_METHOD(int, rec_source, (int source)); + AL_METHOD(int, rec_start, (int rate, int bits, int stereo)); + AL_METHOD(void, rec_stop, (void)); + AL_METHOD(int, rec_read, (void *buf)); +} DIGI_DRIVER; + +AL_ARRAY(_DRIVER_INFO, _digi_driver_list); + +/* macros for constructing the driver lists */ +#define BEGIN_DIGI_DRIVER_LIST \ + _DRIVER_INFO _digi_driver_list[] = \ + { + +#define END_DIGI_DRIVER_LIST \ + { 0, NULL, 0 } \ + }; + +AL_VAR(DIGI_DRIVER *, digi_driver); + +AL_VAR(DIGI_DRIVER *, digi_input_driver); + +AL_VAR(int, digi_card); + +AL_VAR(int, digi_input_card); + +AL_FUNC(int, detect_digi_driver, (int driver_id)); + + +AL_FUNC(SAMPLE *, load_sample, (AL_CONST char *filename)); +AL_FUNC(SAMPLE *, load_wav, (AL_CONST char *filename)); +AL_FUNC(SAMPLE *, load_wav_pf, (struct PACKFILE *f)); +AL_FUNC(SAMPLE *, load_voc, (AL_CONST char *filename)); +AL_FUNC(SAMPLE *, load_voc_pf, (struct PACKFILE *f)); +AL_FUNC(int, save_sample, (AL_CONST char *filename, SAMPLE *spl)); +AL_FUNC(SAMPLE *, create_sample, (int bits, int stereo, int freq, int len)); +AL_FUNC(void, destroy_sample, (SAMPLE *spl)); + +AL_FUNC(int, play_sample, (AL_CONST SAMPLE *spl, int vol, int pan, int freq, int loop)); +AL_FUNC(void, stop_sample, (AL_CONST SAMPLE *spl)); +AL_FUNC(void, adjust_sample, (AL_CONST SAMPLE *spl, int vol, int pan, int freq, int loop)); + +AL_FUNC(int, allocate_voice, (AL_CONST SAMPLE *spl)); +AL_FUNC(void, deallocate_voice, (int voice)); +AL_FUNC(void, reallocate_voice, (int voice, AL_CONST SAMPLE *spl)); +AL_FUNC(void, release_voice, (int voice)); +AL_FUNC(void, voice_start, (int voice)); +AL_FUNC(void, voice_stop, (int voice)); +AL_FUNC(void, voice_set_priority, (int voice, int priority)); +AL_FUNC(SAMPLE *, voice_check, (int voice)); + +#define PLAYMODE_PLAY 0 +#define PLAYMODE_LOOP 1 +#define PLAYMODE_FORWARD 0 +#define PLAYMODE_BACKWARD 2 +#define PLAYMODE_BIDIR 4 + +AL_FUNC(void, voice_set_playmode, (int voice, int playmode)); + +AL_FUNC(int, voice_get_position, (int voice)); +AL_FUNC(void, voice_set_position, (int voice, int position)); + +AL_FUNC(int, voice_get_volume, (int voice)); +AL_FUNC(void, voice_set_volume, (int voice, int volume)); +AL_FUNC(void, voice_ramp_volume, (int voice, int tyme, int endvol)); +AL_FUNC(void, voice_stop_volumeramp, (int voice)); + +AL_FUNC(int, voice_get_frequency, (int voice)); +AL_FUNC(void, voice_set_frequency, (int voice, int frequency)); +AL_FUNC(void, voice_sweep_frequency, (int voice, int tyme, int endfreq)); +AL_FUNC(void, voice_stop_frequency_sweep, (int voice)); + +AL_FUNC(int, voice_get_pan, (int voice)); +AL_FUNC(void, voice_set_pan, (int voice, int pan)); +AL_FUNC(void, voice_sweep_pan, (int voice, int tyme, int endpan)); +AL_FUNC(void, voice_stop_pan_sweep, (int voice)); + +AL_FUNC(void, voice_set_echo, (int voice, int strength, int delay)); +AL_FUNC(void, voice_set_tremolo, (int voice, int rate, int depth)); +AL_FUNC(void, voice_set_vibrato, (int voice, int rate, int depth)); + +#define SOUND_INPUT_MIC 1 +#define SOUND_INPUT_LINE 2 +#define SOUND_INPUT_CD 3 + +AL_FUNC(int, get_sound_input_cap_bits, (void)); +AL_FUNC(int, get_sound_input_cap_stereo, (void)); +AL_FUNC(int, get_sound_input_cap_rate, (int bits, int stereo)); +AL_FUNC(int, get_sound_input_cap_parm, (int rate, int bits, int stereo)); +AL_FUNC(int, set_sound_input_source, (int source)); +AL_FUNC(int, start_sound_input, (int rate, int bits, int stereo)); +AL_FUNC(void, stop_sound_input, (void)); +AL_FUNC(int, read_sound_input, (void *buffer)); + +AL_FUNCPTR(void, digi_recorder, (void)); + +AL_FUNC(void, lock_sample, (struct SAMPLE *spl)); + +AL_FUNC(void, register_sample_file_type, (AL_CONST char *ext, AL_METHOD(struct SAMPLE *, load, (AL_CONST char *filename)), AL_METHOD(int, save, (AL_CONST char *filename, struct SAMPLE *spl)))); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_DIGI_H */ + + diff --git a/lib/allegro/include/allegro/draw.h b/lib/allegro/include/allegro/draw.h new file mode 100644 index 0000000..b983c0f --- /dev/null +++ b/lib/allegro/include/allegro/draw.h @@ -0,0 +1,70 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Drawing and sprite routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_DRAW_H +#define ALLEGRO_DRAW_H + +#include "base.h" +#include "fixed.h" +#include "gfx.h" + +#ifdef __cplusplus + extern "C" { +#endif + +#define DRAW_MODE_SOLID 0 /* flags for drawing_mode() */ +#define DRAW_MODE_XOR 1 +#define DRAW_MODE_COPY_PATTERN 2 +#define DRAW_MODE_SOLID_PATTERN 3 +#define DRAW_MODE_MASKED_PATTERN 4 +#define DRAW_MODE_TRANS 5 + +AL_FUNC(void, drawing_mode, (int mode, struct BITMAP *pattern, int x_anchor, int y_anchor)); +AL_FUNC(void, xor_mode, (int on)); +AL_FUNC(void, solid_mode, (void)); +AL_FUNC(void, do_line, (struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int d, AL_METHOD(void, proc, (struct BITMAP *, int, int, int)))); +AL_FUNC(void, _soft_triangle, (struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color)); +AL_FUNC(void, _soft_polygon, (struct BITMAP *bmp, int vertices, AL_CONST int *points, int color)); +AL_FUNC(void, _soft_rect, (struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color)); +AL_FUNC(void, do_circle, (struct BITMAP *bmp, int x, int y, int radius, int d, AL_METHOD(void, proc, (struct BITMAP *, int, int, int)))); +AL_FUNC(void, _soft_circle, (struct BITMAP *bmp, int x, int y, int radius, int color)); +AL_FUNC(void, _soft_circlefill, (struct BITMAP *bmp, int x, int y, int radius, int color)); +AL_FUNC(void, do_ellipse, (struct BITMAP *bmp, int x, int y, int rx, int ry, int d, AL_METHOD(void, proc, (struct BITMAP *, int, int, int)))); +AL_FUNC(void, _soft_ellipse, (struct BITMAP *bmp, int x, int y, int rx, int ry, int color)); +AL_FUNC(void, _soft_ellipsefill, (struct BITMAP *bmp, int x, int y, int rx, int ry, int color)); +AL_FUNC(void, do_arc, (struct BITMAP *bmp, int x, int y, fixed ang1, fixed ang2, int r, int d, AL_METHOD(void, proc, (struct BITMAP *, int, int, int)))); +AL_FUNC(void, _soft_arc, (struct BITMAP *bmp, int x, int y, fixed ang1, fixed ang2, int r, int color)); +AL_FUNC(void, calc_spline, (AL_CONST int points[8], int npts, int *x, int *y)); +AL_FUNC(void, _soft_spline, (struct BITMAP *bmp, AL_CONST int points[8], int color)); +AL_FUNC(void, _soft_floodfill, (struct BITMAP *bmp, int x, int y, int color)); +AL_FUNC(void, blit, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, masked_blit, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, stretch_blit, (struct BITMAP *s, struct BITMAP *d, int s_x, int s_y, int s_w, int s_h, int d_x, int d_y, int d_w, int d_h)); +AL_FUNC(void, masked_stretch_blit, (struct BITMAP *s, struct BITMAP *d, int s_x, int s_y, int s_w, int s_h, int d_x, int d_y, int d_w, int d_h)); +AL_FUNC(void, stretch_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int w, int h)); +AL_FUNC(void, _soft_draw_gouraud_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4)); + +#ifdef __cplusplus + } +#endif + +#include "inline/draw.inl" + +#endif /* ifndef ALLEGRO_DRAW_H */ + + diff --git a/lib/allegro/include/allegro/file.h b/lib/allegro/include/allegro/file.h new file mode 100644 index 0000000..3512ff9 --- /dev/null +++ b/lib/allegro/include/allegro/file.h @@ -0,0 +1,180 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * File I/O. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_FILE_H +#define ALLEGRO_FILE_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +AL_FUNC(char *, fix_filename_case, (char *path)); +AL_FUNC(char *, fix_filename_slashes, (char *path)); +AL_FUNC(char *, canonicalize_filename, (char *dest, AL_CONST char *filename, int size)); +AL_FUNC(char *, make_absolute_filename, (char *dest, AL_CONST char *path, AL_CONST char *filename, int size)); +AL_FUNC(char *, make_relative_filename, (char *dest, AL_CONST char *path, AL_CONST char *filename, int size)); +AL_FUNC(int, is_relative_filename, (AL_CONST char *filename)); +AL_FUNC(char *, replace_filename, (char *dest, AL_CONST char *path, AL_CONST char *filename, int size)); +AL_FUNC(char *, replace_extension, (char *dest, AL_CONST char *filename, AL_CONST char *ext, int size)); +AL_FUNC(char *, append_filename, (char *dest, AL_CONST char *path, AL_CONST char *filename, int size)); +AL_FUNC(char *, get_filename, (AL_CONST char *path)); +AL_FUNC(char *, get_extension, (AL_CONST char *filename)); +AL_FUNC(void, put_backslash, (char *filename)); +AL_FUNC(int, file_exists, (AL_CONST char *filename, int attrib, int *aret)); +AL_FUNC(int, exists, (AL_CONST char *filename)); +AL_FUNC(uint64_t, file_size_ex, (AL_CONST char *filename)); +AL_FUNC(time_t, file_time, (AL_CONST char *filename)); +AL_FUNC(int, delete_file, (AL_CONST char *filename)); +AL_FUNC(int, for_each_file_ex, (AL_CONST char *name, int in_attrib, int out_attrib, AL_METHOD(int, callback, (AL_CONST char *filename, int attrib, void *param)), void *param)); +AL_FUNC(int, set_allegro_resource_path, (int priority, AL_CONST char *path)); +AL_FUNC(int, find_allegro_resource, (char *dest, AL_CONST char *resource, AL_CONST char *ext, AL_CONST char *datafile, AL_CONST char *objectname, AL_CONST char *envvar, AL_CONST char *subdir, int size)); + +struct al_ffblk /* file info block for the al_find*() routines */ +{ + int attrib; /* actual attributes of the file found */ + time_t time; /* modification time of file */ + long size; /* size of file */ + char name[512]; /* name of file */ + void *ff_data; /* private hook */ +}; + +AL_FUNC(uint64_t, al_ffblk_get_size, (struct al_ffblk *info)); + +AL_FUNC(int, al_findfirst, (AL_CONST char *pattern, struct al_ffblk *info, int attrib)); +AL_FUNC(int, al_findnext, (struct al_ffblk *info)); +AL_FUNC(void, al_findclose, (struct al_ffblk *info)); + +#ifndef EOF + #define EOF (-1) +#endif + +#define F_READ "r" +#define F_WRITE "w" +#define F_READ_PACKED "rp" +#define F_WRITE_PACKED "wp" +#define F_WRITE_NOPACK "w!" + +#define F_BUF_SIZE 4096 /* 4K buffer for caching data */ +#define F_PACK_MAGIC 0x736C6821L /* magic number for packed files */ +#define F_NOPACK_MAGIC 0x736C682EL /* magic number for autodetect */ +#define F_EXE_MAGIC 0x736C682BL /* magic number for appended data */ + +#define PACKFILE_FLAG_WRITE 1 /* the file is being written */ +#define PACKFILE_FLAG_PACK 2 /* data is compressed */ +#define PACKFILE_FLAG_CHUNK 4 /* file is a sub-chunk */ +#define PACKFILE_FLAG_EOF 8 /* reached the end-of-file */ +#define PACKFILE_FLAG_ERROR 16 /* an error has occurred */ +#define PACKFILE_FLAG_OLD_CRYPT 32 /* backward compatibility mode */ +#define PACKFILE_FLAG_EXEDAT 64 /* reading from our executable */ + + +typedef struct PACKFILE_VTABLE PACKFILE_VTABLE; +typedef struct PACKFILE PACKFILE; + +struct LZSS_PACK_DATA; +struct LZSS_UNPACK_DATA; + + +struct _al_normal_packfile_details +{ + int hndl; /* DOS file handle */ + int flags; /* PACKFILE_FLAG_* constants */ + unsigned char *buf_pos; /* position in buffer */ + int buf_size; /* number of bytes in the buffer */ + long todo; /* number of bytes still on the disk */ + struct PACKFILE *parent; /* nested, parent file */ + struct LZSS_PACK_DATA *pack_data; /* for LZSS compression */ + struct LZSS_UNPACK_DATA *unpack_data; /* for LZSS decompression */ + char *filename; /* name of the file */ + char *passdata; /* encryption key data */ + char *passpos; /* current key position */ + unsigned char buf[F_BUF_SIZE]; /* the actual data buffer */ +}; + + +struct PACKFILE /* our very own FILE structure... */ +{ + AL_CONST PACKFILE_VTABLE *vtable; + void *userdata; + int is_normal_packfile; + + /* The following is only to be used for the "normal" PACKFILE vtable, + * i.e. what is implemented by Allegro itself. If is_normal_packfile is + * false then the following is not even allocated. This must be the last + * member in the structure. + */ + struct _al_normal_packfile_details normal; +}; + + +struct PACKFILE_VTABLE +{ + AL_METHOD(int, pf_fclose, (void *userdata)); + AL_METHOD(int, pf_getc, (void *userdata)); + AL_METHOD(int, pf_ungetc, (int c, void *userdata)); + AL_METHOD(long, pf_fread, (void *p, long n, void *userdata)); + AL_METHOD(int, pf_putc, (int c, void *userdata)); + AL_METHOD(long, pf_fwrite, (AL_CONST void *p, long n, void *userdata)); + AL_METHOD(int, pf_fseek, (void *userdata, int offset)); + AL_METHOD(int, pf_feof, (void *userdata)); + AL_METHOD(int, pf_ferror, (void *userdata)); +}; + + +#define uconvert_tofilename(s, buf) uconvert(s, U_CURRENT, buf, get_file_encoding(), sizeof(buf)) + +AL_FUNC(void, set_file_encoding, (int encoding)); +AL_FUNC(int, get_file_encoding, (void)); + +AL_FUNC(void, packfile_password, (AL_CONST char *password)); +AL_FUNC(PACKFILE *, pack_fopen, (AL_CONST char *filename, AL_CONST char *mode)); +AL_FUNC(PACKFILE *, pack_fopen_vtable, (AL_CONST PACKFILE_VTABLE *vtable, void *userdata)); +AL_FUNC(int, pack_fclose, (PACKFILE *f)); +AL_FUNC(int, pack_fseek, (PACKFILE *f, int offset)); +AL_FUNC(PACKFILE *, pack_fopen_chunk, (PACKFILE *f, int pack)); +AL_FUNC(PACKFILE *, pack_fclose_chunk, (PACKFILE *f)); +AL_FUNC(int, pack_getc, (PACKFILE *f)); +AL_FUNC(int, pack_putc, (int c, PACKFILE *f)); +AL_FUNC(int, pack_feof, (PACKFILE *f)); +AL_FUNC(int, pack_ferror, (PACKFILE *f)); +AL_FUNC(int, pack_igetw, (PACKFILE *f)); +AL_FUNC(long, pack_igetl, (PACKFILE *f)); +AL_FUNC(int, pack_iputw, (int w, PACKFILE *f)); +AL_FUNC(long, pack_iputl, (long l, PACKFILE *f)); +AL_FUNC(int, pack_mgetw, (PACKFILE *f)); +AL_FUNC(long, pack_mgetl, (PACKFILE *f)); +AL_FUNC(int, pack_mputw, (int w, PACKFILE *f)); +AL_FUNC(long, pack_mputl, (long l, PACKFILE *f)); +AL_FUNC(long, pack_fread, (void *p, long n, PACKFILE *f)); +AL_FUNC(long, pack_fwrite, (AL_CONST void *p, long n, PACKFILE *f)); +AL_FUNC(int, pack_ungetc, (int c, PACKFILE *f)); +AL_FUNC(char *, pack_fgets, (char *p, int max, PACKFILE *f)); +AL_FUNC(int, pack_fputs, (AL_CONST char *p, PACKFILE *f)); +AL_FUNC(void *, pack_get_userdata, (PACKFILE *f)); + + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_FILE_H */ + + diff --git a/lib/allegro/include/allegro/fix.h b/lib/allegro/include/allegro/fix.h new file mode 100644 index 0000000..41f3d65 --- /dev/null +++ b/lib/allegro/include/allegro/fix.h @@ -0,0 +1,210 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * C++ wrapper for fixed point math type. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_FIX_H +#define ALLEGRO_FIX_H + +#include "fixed.h" +#include "fmaths.h" + +#ifdef __cplusplus + +class fix /* C++ wrapper for the fixed point routines */ +{ +public: + fixed v; + + fix() : v(0) {} + fix(const fix &x) : v(x.v) {} + explicit fix(const int x) : v(itofix(x)) {} + explicit fix(const long x) : v(itofix(x)) {} + explicit fix(const unsigned int x) : v(itofix(x)) {} + explicit fix(const unsigned long x) : v(itofix(x)) {} + explicit fix(const float x) : v(ftofix(x)) {} + explicit fix(const double x) : v(ftofix(x)) {} + + operator int() const { return fixtoi(v); } + operator long() const { return fixtoi(v); } + operator unsigned int() const { return fixtoi(v); } + operator unsigned long() const { return fixtoi(v); } + operator float() const { return fixtof(v); } + operator double() const { return fixtof(v); } + + fix& operator = (const fix &x) { v = x.v; return *this; } + fix& operator = (const int x) { v = itofix(x); return *this; } + fix& operator = (const long x) { v = itofix(x); return *this; } + fix& operator = (const unsigned int x) { v = itofix(x); return *this; } + fix& operator = (const unsigned long x) { v = itofix(x); return *this; } + fix& operator = (const float x) { v = ftofix(x); return *this; } + fix& operator = (const double x) { v = ftofix(x); return *this; } + + fix& operator += (const fix x) { v += x.v; return *this; } + fix& operator += (const int x) { v += itofix(x); return *this; } + fix& operator += (const long x) { v += itofix(x); return *this; } + fix& operator += (const float x) { v += ftofix(x); return *this; } + fix& operator += (const double x) { v += ftofix(x); return *this; } + + fix& operator -= (const fix x) { v -= x.v; return *this; } + fix& operator -= (const int x) { v -= itofix(x); return *this; } + fix& operator -= (const long x) { v -= itofix(x); return *this; } + fix& operator -= (const float x) { v -= ftofix(x); return *this; } + fix& operator -= (const double x) { v -= ftofix(x); return *this; } + + fix& operator *= (const fix x) { v = fixmul(v, x.v); return *this; } + fix& operator *= (const int x) { v *= x; return *this; } + fix& operator *= (const long x) { v *= x; return *this; } + fix& operator *= (const float x) { v = ftofix(fixtof(v) * x); return *this; } + fix& operator *= (const double x) { v = ftofix(fixtof(v) * x); return *this; } + + fix& operator /= (const fix x) { v = fixdiv(v, x.v); return *this; } + fix& operator /= (const int x) { v /= x; return *this; } + fix& operator /= (const long x) { v /= x; return *this; } + fix& operator /= (const float x) { v = ftofix(fixtof(v) / x); return *this; } + fix& operator /= (const double x) { v = ftofix(fixtof(v) / x); return *this; } + + fix& operator <<= (const int x) { v <<= x; return *this; } + fix& operator >>= (const int x) { v >>= x; return *this; } + + fix& operator ++ () { v += itofix(1); return *this; } + fix& operator -- () { v -= itofix(1); return *this; } + + fix operator ++ (int) { fix t; t.v = v; v += itofix(1); return t; } + fix operator -- (int) { fix t; t.v = v; v -= itofix(1); return t; } + + fix operator - () const { fix t; t.v = -v; return t; } + + inline friend fix operator + (const fix x, const fix y); + inline friend fix operator + (const fix x, const int y); + inline friend fix operator + (const int x, const fix y); + inline friend fix operator + (const fix x, const long y); + inline friend fix operator + (const long x, const fix y); + inline friend fix operator + (const fix x, const float y); + inline friend fix operator + (const float x, const fix y); + inline friend fix operator + (const fix x, const double y); + inline friend fix operator + (const double x, const fix y); + + inline friend fix operator - (const fix x, const fix y); + inline friend fix operator - (const fix x, const int y); + inline friend fix operator - (const int x, const fix y); + inline friend fix operator - (const fix x, const long y); + inline friend fix operator - (const long x, const fix y); + inline friend fix operator - (const fix x, const float y); + inline friend fix operator - (const float x, const fix y); + inline friend fix operator - (const fix x, const double y); + inline friend fix operator - (const double x, const fix y); + + inline friend fix operator * (const fix x, const fix y); + inline friend fix operator * (const fix x, const int y); + inline friend fix operator * (const int x, const fix y); + inline friend fix operator * (const fix x, const long y); + inline friend fix operator * (const long x, const fix y); + inline friend fix operator * (const fix x, const float y); + inline friend fix operator * (const float x, const fix y); + inline friend fix operator * (const fix x, const double y); + inline friend fix operator * (const double x, const fix y); + + inline friend fix operator / (const fix x, const fix y); + inline friend fix operator / (const fix x, const int y); + inline friend fix operator / (const int x, const fix y); + inline friend fix operator / (const fix x, const long y); + inline friend fix operator / (const long x, const fix y); + inline friend fix operator / (const fix x, const float y); + inline friend fix operator / (const float x, const fix y); + inline friend fix operator / (const fix x, const double y); + inline friend fix operator / (const double x, const fix y); + + inline friend fix operator << (const fix x, const int y); + inline friend fix operator >> (const fix x, const int y); + + inline friend int operator == (const fix x, const fix y); + inline friend int operator == (const fix x, const int y); + inline friend int operator == (const int x, const fix y); + inline friend int operator == (const fix x, const long y); + inline friend int operator == (const long x, const fix y); + inline friend int operator == (const fix x, const float y); + inline friend int operator == (const float x, const fix y); + inline friend int operator == (const fix x, const double y); + inline friend int operator == (const double x, const fix y); + + inline friend int operator != (const fix x, const fix y); + inline friend int operator != (const fix x, const int y); + inline friend int operator != (const int x, const fix y); + inline friend int operator != (const fix x, const long y); + inline friend int operator != (const long x, const fix y); + inline friend int operator != (const fix x, const float y); + inline friend int operator != (const float x, const fix y); + inline friend int operator != (const fix x, const double y); + inline friend int operator != (const double x, const fix y); + + inline friend int operator < (const fix x, const fix y); + inline friend int operator < (const fix x, const int y); + inline friend int operator < (const int x, const fix y); + inline friend int operator < (const fix x, const long y); + inline friend int operator < (const long x, const fix y); + inline friend int operator < (const fix x, const float y); + inline friend int operator < (const float x, const fix y); + inline friend int operator < (const fix x, const double y); + inline friend int operator < (const double x, const fix y); + + inline friend int operator > (const fix x, const fix y); + inline friend int operator > (const fix x, const int y); + inline friend int operator > (const int x, const fix y); + inline friend int operator > (const fix x, const long y); + inline friend int operator > (const long x, const fix y); + inline friend int operator > (const fix x, const float y); + inline friend int operator > (const float x, const fix y); + inline friend int operator > (const fix x, const double y); + inline friend int operator > (const double x, const fix y); + + inline friend int operator <= (const fix x, const fix y); + inline friend int operator <= (const fix x, const int y); + inline friend int operator <= (const int x, const fix y); + inline friend int operator <= (const fix x, const long y); + inline friend int operator <= (const long x, const fix y); + inline friend int operator <= (const fix x, const float y); + inline friend int operator <= (const float x, const fix y); + inline friend int operator <= (const fix x, const double y); + inline friend int operator <= (const double x, const fix y); + + inline friend int operator >= (const fix x, const fix y); + inline friend int operator >= (const fix x, const int y); + inline friend int operator >= (const int x, const fix y); + inline friend int operator >= (const fix x, const long y); + inline friend int operator >= (const long x, const fix y); + inline friend int operator >= (const fix x, const float y); + inline friend int operator >= (const float x, const fix y); + inline friend int operator >= (const fix x, const double y); + inline friend int operator >= (const double x, const fix y); + + inline friend fix sqrt(fix x); + inline friend fix cos(fix x); + inline friend fix sin(fix x); + inline friend fix tan(fix x); + inline friend fix acos(fix x); + inline friend fix asin(fix x); + inline friend fix atan(fix x); + inline friend fix atan2(fix x, fix y); +}; + +#endif /* ifdef __cplusplus */ + +#include "inline/fix.inl" + +#endif /* ifndef ALLEGRO_FIX_H */ + + diff --git a/lib/allegro/include/allegro/fixed.h b/lib/allegro/include/allegro/fixed.h new file mode 100644 index 0000000..1b8b500 --- /dev/null +++ b/lib/allegro/include/allegro/fixed.h @@ -0,0 +1,39 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Fixed point type. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_FIXED_H +#define ALLEGRO_FIXED_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +typedef int32_t fixed; + +AL_VAR(AL_CONST fixed, fixtorad_r); +AL_VAR(AL_CONST fixed, radtofix_r); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_FIXED_H */ + + diff --git a/lib/allegro/include/allegro/fli.h b/lib/allegro/include/allegro/fli.h new file mode 100644 index 0000000..fb70c1a --- /dev/null +++ b/lib/allegro/include/allegro/fli.h @@ -0,0 +1,63 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * FLI/FLC routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_FLI_H +#define ALLEGRO_FLI_H + +#include "base.h" +#include "palette.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct BITMAP; + +#define FLI_OK 0 /* FLI player return values */ +#define FLI_EOF -1 +#define FLI_ERROR -2 +#define FLI_NOT_OPEN -3 + +AL_FUNC(int, play_fli, (AL_CONST char *filename, struct BITMAP *bmp, int loop, AL_METHOD(int, callback, (void)))); +AL_FUNC(int, play_memory_fli, (void *fli_data, struct BITMAP *bmp, int loop, AL_METHOD(int, callback, (void)))); + +AL_FUNC(int, open_fli, (AL_CONST char *filename)); +AL_FUNC(int, open_memory_fli, (void *fli_data)); +AL_FUNC(void, close_fli, (void)); +AL_FUNC(int, next_fli_frame, (int loop)); +AL_FUNC(void, reset_fli_variables, (void)); + +AL_VAR(struct BITMAP *, fli_bitmap); /* current frame of the FLI */ +AL_VAR(PALETTE, fli_palette); /* current FLI palette */ + +AL_VAR(int, fli_bmp_dirty_from); /* what part of fli_bitmap is dirty */ +AL_VAR(int, fli_bmp_dirty_to); +AL_VAR(int, fli_pal_dirty_from); /* what part of fli_palette is dirty */ +AL_VAR(int, fli_pal_dirty_to); + +AL_VAR(int, fli_frame); /* current frame number */ + +AL_VAR(volatile int, fli_timer); /* for timing FLI playback */ + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_FLI_H */ + + diff --git a/lib/allegro/include/allegro/fmaths.h b/lib/allegro/include/allegro/fmaths.h new file mode 100644 index 0000000..4a72d89 --- /dev/null +++ b/lib/allegro/include/allegro/fmaths.h @@ -0,0 +1,46 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Fixed point math routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_FMATH_H +#define ALLEGRO_FMATH_H + +#include "base.h" +#include "fixed.h" + +#ifdef __cplusplus + extern "C" { +#endif + +AL_FUNC(fixed, fixsqrt, (fixed x)); +AL_FUNC(fixed, fixhypot, (fixed x, fixed y)); +AL_FUNC(fixed, fixatan, (fixed x)); +AL_FUNC(fixed, fixatan2, (fixed y, fixed x)); + +AL_ARRAY(fixed, _cos_tbl); +AL_ARRAY(fixed, _tan_tbl); +AL_ARRAY(fixed, _acos_tbl); + +#ifdef __cplusplus + } +#endif + +#include "inline/fmaths.inl" + +#endif /* ifndef ALLEGRO_FMATH_H */ + + diff --git a/lib/allegro/include/allegro/font.h b/lib/allegro/include/allegro/font.h new file mode 100644 index 0000000..4b1ba52 --- /dev/null +++ b/lib/allegro/include/allegro/font.h @@ -0,0 +1,74 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Font loading routines. + * + * By Evert Glebbeek. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_FONT_H +#define ALLEGRO_FONT_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct FONT_GLYPH /* a single monochrome font character */ +{ + short w, h; + ZERO_SIZE_ARRAY(unsigned char, dat); +} FONT_GLYPH; + + +struct FONT_VTABLE; + +typedef struct FONT +{ + void *data; + int height; + struct FONT_VTABLE *vtable; +} FONT; + +AL_FUNC(void, make_trans_font, (FONT *f)); + +AL_FUNC(int, is_color_font, (FONT *f)); +AL_FUNC(int, is_mono_font, (FONT *f)); +AL_FUNC(int, is_compatible_font, (FONT *f1, FONT *f2)); + +AL_FUNC(void, register_font_file_type, (AL_CONST char *ext, FONT *(*load)(AL_CONST char *filename, RGB *pal, void *param))); +AL_FUNC(FONT *, load_font, (AL_CONST char *filename, RGB *pal, void *param)); + +AL_FUNC(FONT *, load_dat_font, (AL_CONST char *filename, RGB *pal, void *param)); +AL_FUNC(FONT *, load_bios_font, (AL_CONST char *filename, RGB *pal, void *param)); +AL_FUNC(FONT *, load_grx_font, (AL_CONST char *filename, RGB *pal, void *param)); +AL_FUNC(FONT *, load_grx_or_bios_font, (AL_CONST char *filename, RGB *pal, void *param)); +AL_FUNC(FONT *, load_bitmap_font, (AL_CONST char *fname, RGB *pal, void *param)); +AL_FUNC(FONT *, load_txt_font, (AL_CONST char *fname, RGB *pal, void *param)); + +AL_FUNC(FONT *, grab_font_from_bitmap, (BITMAP *bmp)); + +AL_FUNC(int, get_font_ranges, (FONT *f)); +AL_FUNC(int, get_font_range_begin, (FONT *f, int range)); +AL_FUNC(int, get_font_range_end, (FONT *f, int range)); +AL_FUNC(FONT *, extract_font_range, (FONT *f, int begin, int end)); +AL_FUNC(FONT *, merge_fonts, (FONT *f1, FONT *f2)); +AL_FUNC(int, transpose_font, (FONT *f, int drange)); +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_FONT_H */ + + diff --git a/lib/allegro/include/allegro/gfx.h b/lib/allegro/include/allegro/gfx.h new file mode 100644 index 0000000..d46a4d6 --- /dev/null +++ b/lib/allegro/include/allegro/gfx.h @@ -0,0 +1,443 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Basic graphics support routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_GFX_H +#define ALLEGRO_GFX_H + +#include "3d.h" +#include "base.h" +#include "fixed.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct RLE_SPRITE; +struct FONT_GLYPH; +struct RGB; + +#define GFX_TEXT -1 +#define GFX_AUTODETECT 0 +#define GFX_AUTODETECT_FULLSCREEN 1 +#define GFX_AUTODETECT_WINDOWED 2 +#define GFX_SAFE AL_ID('S','A','F','E') + + +/* Blender mode defines, for the gfx_driver->set_blender_mode() function */ +#define blender_mode_none 0 +#define blender_mode_trans 1 +#define blender_mode_add 2 +#define blender_mode_burn 3 +#define blender_mode_color 4 +#define blender_mode_difference 5 +#define blender_mode_dissolve 6 +#define blender_mode_dodge 7 +#define blender_mode_hue 8 +#define blender_mode_invert 9 +#define blender_mode_luminance 10 +#define blender_mode_multiply 11 +#define blender_mode_saturation 12 +#define blender_mode_screen 13 +#define blender_mode_alpha 14 + +typedef struct GFX_MODE +{ + int width, height, bpp; +} GFX_MODE; + +typedef struct GFX_MODE_LIST +{ + int num_modes; /* number of gfx modes */ + GFX_MODE *mode; /* pointer to the actual mode list array */ +} GFX_MODE_LIST; + +typedef struct GFX_DRIVER /* creates and manages the screen bitmap */ +{ + int id; + AL_CONST char *name; + AL_CONST char *desc; + AL_CONST char *ascii_name; + AL_METHOD(struct BITMAP *, init, (int w, int h, int v_w, int v_h, int color_depth)); + AL_METHOD(void, exit, (struct BITMAP *b)); + AL_METHOD(int, scroll, (int x, int y)); + AL_METHOD(void, vsync, (void)); + AL_METHOD(void, set_palette, (AL_CONST struct RGB *p, int from, int to, int retracesync)); + AL_METHOD(int, request_scroll, (int x, int y)); + AL_METHOD(int, poll_scroll, (void)); + AL_METHOD(void, enable_triple_buffer, (void)); + AL_METHOD(struct BITMAP *, create_video_bitmap, (int width, int height)); + AL_METHOD(void, destroy_video_bitmap, (struct BITMAP *bitmap)); + AL_METHOD(int, show_video_bitmap, (struct BITMAP *bitmap)); + AL_METHOD(int, request_video_bitmap, (struct BITMAP *bitmap)); + AL_METHOD(struct BITMAP *, create_system_bitmap, (int width, int height)); + AL_METHOD(void, destroy_system_bitmap, (struct BITMAP *bitmap)); + AL_METHOD(int, set_mouse_sprite, (struct BITMAP *sprite, int xfocus, int yfocus)); + AL_METHOD(int, show_mouse, (struct BITMAP *bmp, int x, int y)); + AL_METHOD(void, hide_mouse, (void)); + AL_METHOD(void, move_mouse, (int x, int y)); + AL_METHOD(void, drawing_mode, (void)); + AL_METHOD(void, save_video_state, (void)); + AL_METHOD(void, restore_video_state, (void)); + AL_METHOD(void, set_blender_mode, (int mode, int r, int g, int b, int a)); + AL_METHOD(GFX_MODE_LIST *, fetch_mode_list, (void)); + int w, h; /* physical (not virtual!) screen size */ + int linear; /* true if video memory is linear */ + long bank_size; /* bank size, in bytes */ + long bank_gran; /* bank granularity, in bytes */ + long vid_mem; /* video memory size, in bytes */ + long vid_phys_base; /* physical address of video memory */ + int windowed; /* true if driver runs windowed */ +} GFX_DRIVER; + + +AL_VAR(GFX_DRIVER *, gfx_driver); +AL_ARRAY(_DRIVER_INFO, _gfx_driver_list); + + +/* macros for constructing the driver list */ +#define BEGIN_GFX_DRIVER_LIST \ + _DRIVER_INFO _gfx_driver_list[] = \ + { + +#define END_GFX_DRIVER_LIST \ + { 0, NULL, 0 } \ + }; + + +#define GFX_CAN_SCROLL 0x00000001 +#define GFX_CAN_TRIPLE_BUFFER 0x00000002 +#define GFX_HW_CURSOR 0x00000004 +#define GFX_HW_HLINE 0x00000008 +#define GFX_HW_HLINE_XOR 0x00000010 +#define GFX_HW_HLINE_SOLID_PATTERN 0x00000020 +#define GFX_HW_HLINE_COPY_PATTERN 0x00000040 +#define GFX_HW_FILL 0x00000080 +#define GFX_HW_FILL_XOR 0x00000100 +#define GFX_HW_FILL_SOLID_PATTERN 0x00000200 +#define GFX_HW_FILL_COPY_PATTERN 0x00000400 +#define GFX_HW_LINE 0x00000800 +#define GFX_HW_LINE_XOR 0x00001000 +#define GFX_HW_TRIANGLE 0x00002000 +#define GFX_HW_TRIANGLE_XOR 0x00004000 +#define GFX_HW_GLYPH 0x00008000 +#define GFX_HW_VRAM_BLIT 0x00010000 +#define GFX_HW_VRAM_BLIT_MASKED 0x00020000 +#define GFX_HW_MEM_BLIT 0x00040000 +#define GFX_HW_MEM_BLIT_MASKED 0x00080000 +#define GFX_HW_SYS_TO_VRAM_BLIT 0x00100000 +#define GFX_HW_SYS_TO_VRAM_BLIT_MASKED 0x00200000 +#define GFX_SYSTEM_CURSOR 0x00400000 +#define GFX_HW_VRAM_STRETCH_BLIT 0x00800000 +#define GFX_HW_VRAM_STRETCH_BLIT_MASKED 0x01000000 +#define GFX_HW_SYS_STRETCH_BLIT 0x02000000 +#define GFX_HW_SYS_STRETCH_BLIT_MASKED 0x04000000 + + +AL_VAR(int, gfx_capabilities); /* current driver capabilities */ + + +typedef struct GFX_VTABLE /* functions for drawing onto bitmaps */ +{ + int color_depth; + int mask_color; + void *unwrite_bank; /* C function on some machines, asm on i386 */ + AL_METHOD(void, set_clip, (struct BITMAP *bmp)); + AL_METHOD(void, acquire, (struct BITMAP *bmp)); + AL_METHOD(void, release, (struct BITMAP *bmp)); + AL_METHOD(struct BITMAP *, create_sub_bitmap, (struct BITMAP *parent, int x, int y, int width, int height)); + AL_METHOD(void, created_sub_bitmap, (struct BITMAP *bmp, struct BITMAP *parent)); + AL_METHOD(int, getpixel, (struct BITMAP *bmp, int x, int y)); + AL_METHOD(void, putpixel, (struct BITMAP *bmp, int x, int y, int color)); + AL_METHOD(void, vline, (struct BITMAP *bmp, int x, int y_1, int y2, int color)); + AL_METHOD(void, hline, (struct BITMAP *bmp, int x1, int y, int x2, int color)); + AL_METHOD(void, hfill, (struct BITMAP *bmp, int x1, int y, int x2, int color)); + AL_METHOD(void, line, (struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color)); + AL_METHOD(void, fastline, (struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color)); + AL_METHOD(void, rectfill, (struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color)); + AL_METHOD(void, triangle, (struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color)); + AL_METHOD(void, draw_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y)); + AL_METHOD(void, draw_256_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y)); + AL_METHOD(void, draw_sprite_v_flip, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y)); + AL_METHOD(void, draw_sprite_h_flip, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y)); + AL_METHOD(void, draw_sprite_vh_flip, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y)); + AL_METHOD(void, draw_trans_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y)); + AL_METHOD(void, draw_trans_rgba_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y)); + AL_METHOD(void, draw_lit_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color)); + AL_METHOD(void, draw_rle_sprite, (struct BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); + AL_METHOD(void, draw_trans_rle_sprite, (struct BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); + AL_METHOD(void, draw_trans_rgba_rle_sprite, (struct BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); + AL_METHOD(void, draw_lit_rle_sprite, (struct BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y, int color)); + AL_METHOD(void, draw_character, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color, int bg)); + AL_METHOD(void, draw_glyph, (struct BITMAP *bmp, AL_CONST struct FONT_GLYPH *glyph, int x, int y, int color, int bg)); + AL_METHOD(void, blit_from_memory, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, blit_to_memory, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, blit_from_system, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, blit_to_system, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, blit_to_self, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, blit_to_self_forward, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, blit_to_self_backward, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, blit_between_formats, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, masked_blit, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); + AL_METHOD(void, clear_to_color, (struct BITMAP *bitmap, int color)); + AL_METHOD(void, pivot_scaled_sprite_flip, (struct BITMAP *bmp, struct BITMAP *sprite, fixed x, fixed y, fixed cx, fixed cy, fixed angle, fixed scale, int v_flip)); + AL_METHOD(void, do_stretch_blit, (struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int dest_width, int dest_height, int masked)); + AL_METHOD(void, draw_gouraud_sprite, (struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4)); + AL_METHOD(void, draw_sprite_end, (void)); + AL_METHOD(void, blit_end, (void)); + AL_METHOD(void, polygon, (struct BITMAP *bmp, int vertices, AL_CONST int *points, int color)); + AL_METHOD(void, rect, (struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color)); + AL_METHOD(void, circle, (struct BITMAP *bmp, int x, int y, int radius, int color)); + AL_METHOD(void, circlefill, (struct BITMAP *bmp, int x, int y, int radius, int color)); + AL_METHOD(void, ellipse, (struct BITMAP *bmp, int x, int y, int rx, int ry, int color)); + AL_METHOD(void, ellipsefill, (struct BITMAP *bmp, int x, int y, int rx, int ry, int color)); + AL_METHOD(void, arc, (struct BITMAP *bmp, int x, int y, fixed ang1, fixed ang2, int r, int color)); + AL_METHOD(void, spline, (struct BITMAP *bmp, AL_CONST int points[8], int color)); + AL_METHOD(void, floodfill, (struct BITMAP *bmp, int x, int y, int color)); + AL_METHOD(void, polygon3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, V3D *vtx[])); + AL_METHOD(void, polygon3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, V3D_f *vtx[])); + AL_METHOD(void, triangle3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D *v1, V3D *v2, V3D *v3)); + AL_METHOD(void, triangle3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D_f *v1, V3D_f *v2, V3D_f *v3)); + AL_METHOD(void, quad3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D *v1, V3D *v2, V3D *v3, V3D *v4)); + AL_METHOD(void, quad3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D_f *v1, V3D_f *v2, V3D_f *v3, V3D_f *v4)); +} GFX_VTABLE; + + +AL_VAR(GFX_VTABLE, __linear_vtable8); +AL_VAR(GFX_VTABLE, __linear_vtable15); +AL_VAR(GFX_VTABLE, __linear_vtable16); +AL_VAR(GFX_VTABLE, __linear_vtable24); +AL_VAR(GFX_VTABLE, __linear_vtable32); + + +typedef struct _VTABLE_INFO +{ + int color_depth; + GFX_VTABLE *vtable; +} _VTABLE_INFO; + +AL_ARRAY(_VTABLE_INFO, _vtable_list); + + +/* macros for constructing the vtable list */ +#define BEGIN_COLOR_DEPTH_LIST \ + _VTABLE_INFO _vtable_list[] = \ + { + +#define END_COLOR_DEPTH_LIST \ + { 0, NULL } \ + }; + +#define COLOR_DEPTH_8 \ + { 8, &__linear_vtable8 }, + +#define COLOR_DEPTH_15 \ + { 15, &__linear_vtable15 }, + +#define COLOR_DEPTH_16 \ + { 16, &__linear_vtable16 }, + +#define COLOR_DEPTH_24 \ + { 24, &__linear_vtable24 }, + +#define COLOR_DEPTH_32 \ + { 32, &__linear_vtable32 }, + + +typedef struct BITMAP /* a bitmap structure */ +{ + int w, h; /* width and height in pixels */ + int clip; /* flag if clipping is turned on */ + int cl, cr, ct, cb; /* clip left, right, top and bottom values */ + GFX_VTABLE *vtable; /* drawing functions */ + void *write_bank; /* C func on some machines, asm on i386 */ + void *read_bank; /* C func on some machines, asm on i386 */ + void *dat; /* the memory we allocated for the bitmap */ + unsigned long id; /* for identifying sub-bitmaps */ + void *extra; /* points to a structure with more info */ + int x_ofs; /* horizontal offset (for sub-bitmaps) */ + int y_ofs; /* vertical offset (for sub-bitmaps) */ + int seg; /* bitmap segment */ + ZERO_SIZE_ARRAY(unsigned char *, line); +} BITMAP; + + +#define BMP_ID_VIDEO 0x80000000 +#define BMP_ID_SYSTEM 0x40000000 +#define BMP_ID_SUB 0x20000000 +#define BMP_ID_PLANAR 0x10000000 +#define BMP_ID_NOBLIT 0x08000000 +#define BMP_ID_LOCKED 0x04000000 +#define BMP_ID_AUTOLOCK 0x02000000 +#define BMP_ID_MASK 0x01FFFFFF + + +AL_VAR(BITMAP *, screen); + +#define SCREEN_W (gfx_driver ? gfx_driver->w : 0) +#define SCREEN_H (gfx_driver ? gfx_driver->h : 0) + +#define VIRTUAL_W (screen ? screen->w : 0) +#define VIRTUAL_H (screen ? screen->h : 0) + +#define COLORCONV_NONE 0 + +#define COLORCONV_8_TO_15 1 +#define COLORCONV_8_TO_16 2 +#define COLORCONV_8_TO_24 4 +#define COLORCONV_8_TO_32 8 + +#define COLORCONV_15_TO_8 0x10 +#define COLORCONV_15_TO_16 0x20 +#define COLORCONV_15_TO_24 0x40 +#define COLORCONV_15_TO_32 0x80 + +#define COLORCONV_16_TO_8 0x100 +#define COLORCONV_16_TO_15 0x200 +#define COLORCONV_16_TO_24 0x400 +#define COLORCONV_16_TO_32 0x800 + +#define COLORCONV_24_TO_8 0x1000 +#define COLORCONV_24_TO_15 0x2000 +#define COLORCONV_24_TO_16 0x4000 +#define COLORCONV_24_TO_32 0x8000 + +#define COLORCONV_32_TO_8 0x10000 +#define COLORCONV_32_TO_15 0x20000 +#define COLORCONV_32_TO_16 0x40000 +#define COLORCONV_32_TO_24 0x80000 + +#define COLORCONV_32A_TO_8 0x100000 +#define COLORCONV_32A_TO_15 0x200000 +#define COLORCONV_32A_TO_16 0x400000 +#define COLORCONV_32A_TO_24 0x800000 + +#define COLORCONV_DITHER_PAL 0x1000000 +#define COLORCONV_DITHER_HI 0x2000000 +#define COLORCONV_KEEP_TRANS 0x4000000 + +#define COLORCONV_DITHER (COLORCONV_DITHER_PAL | \ + COLORCONV_DITHER_HI) + +#define COLORCONV_EXPAND_256 (COLORCONV_8_TO_15 | \ + COLORCONV_8_TO_16 | \ + COLORCONV_8_TO_24 | \ + COLORCONV_8_TO_32) + +#define COLORCONV_REDUCE_TO_256 (COLORCONV_15_TO_8 | \ + COLORCONV_16_TO_8 | \ + COLORCONV_24_TO_8 | \ + COLORCONV_32_TO_8 | \ + COLORCONV_32A_TO_8) + +#define COLORCONV_EXPAND_15_TO_16 COLORCONV_15_TO_16 + +#define COLORCONV_REDUCE_16_TO_15 COLORCONV_16_TO_15 + +#define COLORCONV_EXPAND_HI_TO_TRUE (COLORCONV_15_TO_24 | \ + COLORCONV_15_TO_32 | \ + COLORCONV_16_TO_24 | \ + COLORCONV_16_TO_32) + +#define COLORCONV_REDUCE_TRUE_TO_HI (COLORCONV_24_TO_15 | \ + COLORCONV_24_TO_16 | \ + COLORCONV_32_TO_15 | \ + COLORCONV_32_TO_16) + +#define COLORCONV_24_EQUALS_32 (COLORCONV_24_TO_32 | \ + COLORCONV_32_TO_24) + +#define COLORCONV_TOTAL (COLORCONV_EXPAND_256 | \ + COLORCONV_REDUCE_TO_256 | \ + COLORCONV_EXPAND_15_TO_16 | \ + COLORCONV_REDUCE_16_TO_15 | \ + COLORCONV_EXPAND_HI_TO_TRUE | \ + COLORCONV_REDUCE_TRUE_TO_HI | \ + COLORCONV_24_EQUALS_32 | \ + COLORCONV_32A_TO_15 | \ + COLORCONV_32A_TO_16 | \ + COLORCONV_32A_TO_24) + +#define COLORCONV_PARTIAL (COLORCONV_EXPAND_15_TO_16 | \ + COLORCONV_REDUCE_16_TO_15 | \ + COLORCONV_24_EQUALS_32) + +#define COLORCONV_MOST (COLORCONV_EXPAND_15_TO_16 | \ + COLORCONV_REDUCE_16_TO_15 | \ + COLORCONV_EXPAND_HI_TO_TRUE | \ + COLORCONV_REDUCE_TRUE_TO_HI | \ + COLORCONV_24_EQUALS_32) + +#define COLORCONV_KEEP_ALPHA (COLORCONV_TOTAL \ + & ~(COLORCONV_32A_TO_8 | \ + COLORCONV_32A_TO_15 | \ + COLORCONV_32A_TO_16 | \ + COLORCONV_32A_TO_24)) + +AL_FUNC(GFX_MODE_LIST *, get_gfx_mode_list, (int card)); +AL_FUNC(void, destroy_gfx_mode_list, (GFX_MODE_LIST *gfx_mode_list)); +AL_FUNC(void, set_color_depth, (int depth)); +AL_FUNC(int, get_color_depth, (void)); +AL_FUNC(void, set_color_conversion, (int mode)); +AL_FUNC(int, get_color_conversion, (void)); +AL_FUNC(void, request_refresh_rate, (int rate)); +AL_FUNC(int, get_refresh_rate, (void)); +AL_FUNC(int, set_gfx_mode, (int card, int w, int h, int v_w, int v_h)); +AL_FUNC(int, scroll_screen, (int x, int y)); +AL_FUNC(int, request_scroll, (int x, int y)); +AL_FUNC(int, poll_scroll, (void)); +AL_FUNC(int, show_video_bitmap, (BITMAP *bitmap)); +AL_FUNC(int, request_video_bitmap, (BITMAP *bitmap)); +AL_FUNC(int, enable_triple_buffer, (void)); +AL_FUNC(BITMAP *, create_bitmap, (int width, int height)); +AL_FUNC(BITMAP *, create_bitmap_ex, (int color_depth, int width, int height)); +AL_FUNC(BITMAP *, create_sub_bitmap, (BITMAP *parent, int x, int y, int width, int height)); +AL_FUNC(BITMAP *, create_video_bitmap, (int width, int height)); +AL_FUNC(BITMAP *, create_system_bitmap, (int width, int height)); +AL_FUNC(void, destroy_bitmap, (BITMAP *bitmap)); +AL_FUNC(void, set_clip_rect, (BITMAP *bitmap, int x1, int y_1, int x2, int y2)); +AL_FUNC(void, add_clip_rect, (BITMAP *bitmap, int x1, int y_1, int x2, int y2)); +AL_FUNC(void, clear_bitmap, (BITMAP *bitmap)); +AL_FUNC(void, vsync, (void)); + + + +#define SWITCH_NONE 0 +#define SWITCH_PAUSE 1 +#define SWITCH_AMNESIA 2 +#define SWITCH_BACKGROUND 3 +#define SWITCH_BACKAMNESIA 4 + +#define SWITCH_IN 0 +#define SWITCH_OUT 1 + +AL_FUNC(int, set_display_switch_mode, (int mode)); +AL_FUNC(int, get_display_switch_mode, (void)); +AL_FUNC(int, set_display_switch_callback, (int dir, AL_METHOD(void, cb, (void)))); +AL_FUNC(void, remove_display_switch_callback, (AL_METHOD(void, cb, (void)))); + +AL_FUNC(void, lock_bitmap, (struct BITMAP *bmp)); + +#ifdef __cplusplus + } +#endif + +#include "inline/gfx.inl" + +#endif /* ifndef ALLEGRO_GFX_H */ + + diff --git a/lib/allegro/include/allegro/graphics.h b/lib/allegro/include/allegro/graphics.h new file mode 100644 index 0000000..f92c2a2 --- /dev/null +++ b/lib/allegro/include/allegro/graphics.h @@ -0,0 +1,33 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Container for all graphics related routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_GRAPHICS_H +#define ALLEGRO_GRAPHICS_H + +#include "base.h" +#include "gfx.h" +#include "text.h" +#include "3d.h" +#include "draw.h" +#include "color.h" +#include "palette.h" +#include "rle.h" +#include "compiled.h" + +#endif /* ifndef ALLEGRO_GRAPHICS_H */ + diff --git a/lib/allegro/include/allegro/gui.h b/lib/allegro/include/allegro/gui.h new file mode 100644 index 0000000..896faf1 --- /dev/null +++ b/lib/allegro/include/allegro/gui.h @@ -0,0 +1,231 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * GUI routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_GUI_H +#define ALLEGRO_GUI_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct BITMAP; +struct DIALOG; + +typedef AL_METHOD(int, DIALOG_PROC, (int msg, struct DIALOG *d, int c)); + +typedef struct DIALOG +{ + DIALOG_PROC proc; + int x, y, w, h; /* position and size of the object */ + int fg, bg; /* foreground and background colors */ + int key; /* keyboard shortcut (ASCII code) */ + int flags; /* flags about the object state */ + int d1, d2; /* any data the object might require */ + void *dp, *dp2, *dp3; /* pointers to more object data */ +} DIALOG; + + +/* a popup menu */ +typedef struct MENU +{ + char *text; /* menu item text */ + AL_METHOD(int, proc, (void)); /* callback function */ + struct MENU *child; /* to allow nested menus */ + int flags; /* flags about the menu state */ + void *dp; /* any data the menu might require */ +} MENU; + + +/* stored information about the state of an active GUI dialog */ +typedef struct DIALOG_PLAYER +{ + int obj; + int res; + int mouse_obj; + int focus_obj; + int joy_on; + int click_wait; + int mouse_ox, mouse_oy; + int mouse_oz; + int mouse_b; + DIALOG *dialog; +} DIALOG_PLAYER; + + +/* stored information about the state of an active GUI menu */ +typedef struct MENU_PLAYER +{ + MENU *menu; /* the menu itself */ + int bar; /* set if it is a top level menu bar */ + int size; /* number of items in the menu */ + int sel; /* selected item */ + int x, y, w, h; /* screen position of the menu */ + int (*proc)(void); /* callback function */ + BITMAP *saved; /* saved what was underneath it */ + + int mouse_button_was_pressed; /* set if mouse button pressed on last iteration */ + int back_from_child; /* set if a child was activated on last iteration */ + int timestamp; /* timestamp for gui_timer events */ + int mouse_sel; /* item the mouse is currently over */ + int redraw; /* set if redrawing is required */ + int auto_open; /* set if menu auto-opening is activated */ + int ret; /* return value */ + + DIALOG *dialog; /* d_menu_proc() parent dialog (if any) */ + + struct MENU_PLAYER *parent; /* the parent menu, or NULL for root */ + struct MENU_PLAYER *child; /* the child menu, or NULL for none */ +} MENU_PLAYER; + + +/* bits for the flags field */ +#define D_EXIT 1 /* object makes the dialog exit */ +#define D_SELECTED 2 /* object is selected */ +#define D_GOTFOCUS 4 /* object has the input focus */ +#define D_GOTMOUSE 8 /* mouse is on top of object */ +#define D_HIDDEN 16 /* object is not visible */ +#define D_DISABLED 32 /* object is visible but inactive */ +#define D_DIRTY 64 /* object needs to be redrawn */ +#define D_INTERNAL 128 /* reserved for internal use */ +#define D_USER 256 /* from here on is free for your own use */ + + +/* return values for the dialog procedures */ +#define D_O_K 0 /* normal exit status */ +#define D_CLOSE 1 /* request to close the dialog */ +#define D_REDRAW 2 /* request to redraw the dialog */ +#define D_REDRAWME 4 /* request to redraw this object */ +#define D_WANTFOCUS 8 /* this object wants the input focus */ +#define D_USED_CHAR 16 /* object has used the keypress */ +#define D_REDRAW_ALL 32 /* request to redraw all active dialogs */ +#define D_DONTWANTMOUSE 64 /* this object does not want mouse focus */ + + +/* messages for the dialog procedures */ +#define MSG_START 1 /* start the dialog, initialise */ +#define MSG_END 2 /* dialog is finished - cleanup */ +#define MSG_DRAW 3 /* draw the object */ +#define MSG_CLICK 4 /* mouse click on the object */ +#define MSG_DCLICK 5 /* double click on the object */ +#define MSG_KEY 6 /* keyboard shortcut */ +#define MSG_CHAR 7 /* other keyboard input */ +#define MSG_UCHAR 8 /* unicode keyboard input */ +#define MSG_XCHAR 9 /* broadcast character to all objects */ +#define MSG_WANTFOCUS 10 /* does object want the input focus? */ +#define MSG_GOTFOCUS 11 /* got the input focus */ +#define MSG_LOSTFOCUS 12 /* lost the input focus */ +#define MSG_GOTMOUSE 13 /* mouse on top of object */ +#define MSG_LOSTMOUSE 14 /* mouse moved away from object */ +#define MSG_IDLE 15 /* update any background stuff */ +#define MSG_RADIO 16 /* clear radio buttons */ +#define MSG_WHEEL 17 /* mouse wheel moved */ +#define MSG_LPRESS 18 /* mouse left button pressed */ +#define MSG_LRELEASE 19 /* mouse left button released */ +#define MSG_MPRESS 20 /* mouse middle button pressed */ +#define MSG_MRELEASE 21 /* mouse middle button released */ +#define MSG_RPRESS 22 /* mouse right button pressed */ +#define MSG_RRELEASE 23 /* mouse right button released */ +#define MSG_WANTMOUSE 24 /* does object want the mouse? */ +#define MSG_USER 25 /* from here on are free... */ + + +/* some dialog procedures */ +AL_FUNC(int, d_yield_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_clear_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_box_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_shadow_box_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_bitmap_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_text_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_ctext_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_rtext_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_button_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_check_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_radio_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_icon_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_keyboard_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_edit_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_list_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_text_list_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_textbox_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_slider_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, d_menu_proc, (int msg, DIALOG *d, int c)); + +AL_VAR(DIALOG_PROC, gui_shadow_box_proc); +AL_VAR(DIALOG_PROC, gui_ctext_proc); +AL_VAR(DIALOG_PROC, gui_button_proc); +AL_VAR(DIALOG_PROC, gui_edit_proc); +AL_VAR(DIALOG_PROC, gui_list_proc); +AL_VAR(DIALOG_PROC, gui_text_list_proc); + +AL_FUNCPTR(void, gui_menu_draw_menu, (int x, int y, int w, int h)); +AL_FUNCPTR(void, gui_menu_draw_menu_item, (MENU *m, int x, int y, int w, int h, int bar, int sel)); + +AL_VAR(DIALOG *, active_dialog); +AL_VAR(MENU *, active_menu); + +AL_VAR(int, gui_mouse_focus); + +AL_VAR(int, gui_fg_color); +AL_VAR(int, gui_mg_color); +AL_VAR(int, gui_bg_color); + +AL_VAR(int, gui_font_baseline); + +AL_FUNCPTR(int, gui_mouse_x, (void)); +AL_FUNCPTR(int, gui_mouse_y, (void)); +AL_FUNCPTR(int, gui_mouse_z, (void)); +AL_FUNCPTR(int, gui_mouse_b, (void)); + +AL_FUNC(void, gui_set_screen, (BITMAP *bmp)); +AL_FUNC(BITMAP *, gui_get_screen, (void)); +AL_FUNC(int, gui_textout_ex, (struct BITMAP *bmp, AL_CONST char *s, int x, int y, int color, int bg, int centre)); +AL_FUNC(int, gui_strlen, (AL_CONST char *s)); +AL_FUNC(void, position_dialog, (DIALOG *dialog, int x, int y)); +AL_FUNC(void, centre_dialog, (DIALOG *dialog)); +AL_FUNC(void, set_dialog_color, (DIALOG *dialog, int fg, int bg)); +AL_FUNC(int, find_dialog_focus, (DIALOG *dialog)); +AL_FUNC(int, offer_focus, (DIALOG *dialog, int obj, int *focus_obj, int force)); +AL_FUNC(int, object_message, (DIALOG *dialog, int msg, int c)); +AL_FUNC(int, dialog_message, (DIALOG *dialog, int msg, int c, int *obj)); +AL_FUNC(int, broadcast_dialog_message, (int msg, int c)); +AL_FUNC(int, do_dialog, (DIALOG *dialog, int focus_obj)); +AL_FUNC(int, popup_dialog, (DIALOG *dialog, int focus_obj)); +AL_FUNC(DIALOG_PLAYER *, init_dialog, (DIALOG *dialog, int focus_obj)); +AL_FUNC(int, update_dialog, (DIALOG_PLAYER *player)); +AL_FUNC(int, shutdown_dialog, (DIALOG_PLAYER *player)); +AL_FUNC(int, do_menu, (MENU *menu, int x, int y)); +AL_FUNC(MENU_PLAYER *, init_menu, (MENU *menu, int x, int y)); +AL_FUNC(int, update_menu, (MENU_PLAYER *player)); +AL_FUNC(int, shutdown_menu, (MENU_PLAYER *player)); +AL_FUNC(int, alert, (AL_CONST char *s1, AL_CONST char *s2, AL_CONST char *s3, AL_CONST char *b1, AL_CONST char *b2, int c1, int c2)); +AL_FUNC(int, alert3, (AL_CONST char *s1, AL_CONST char *s2, AL_CONST char *s3, AL_CONST char *b1, AL_CONST char *b2, AL_CONST char *b3, int c1, int c2, int c3)); +AL_FUNC(int, file_select_ex, (AL_CONST char *message, char *path, AL_CONST char *ext, int size, int w, int h)); + +AL_FUNC(int, gfx_mode_select, (int *card, int *w, int *h)); +AL_FUNC(int, gfx_mode_select_ex, (int *card, int *w, int *h, int *color_depth)); +AL_FUNC(int, gfx_mode_select_filter, (int *card, int *w, int *h, int *color_depth, int (*filter)(int, int, int, int))); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_GUI_H */ + + diff --git a/lib/allegro/include/allegro/inline/3dmaths.inl b/lib/allegro/include/allegro/inline/3dmaths.inl new file mode 100644 index 0000000..614f269 --- /dev/null +++ b/lib/allegro/include/allegro/inline/3dmaths.inl @@ -0,0 +1,60 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * 3D maths inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_3DMATHS_INL +#define ALLEGRO_3DMATHS_INL + +#ifdef __cplusplus + extern "C" { +#endif + + +AL_INLINE(fixed, dot_product, (fixed x1, fixed y_1, fixed z1, fixed x2, fixed y2, fixed z2), +{ + return fixmul(x1, x2) + fixmul(y_1, y2) + fixmul(z1, z2); +}) + + +AL_INLINE(float, dot_product_f, (float x1, float y_1, float z1, float x2, float y2, float z2), +{ + return (x1 * x2) + (y_1 * y2) + (z1 * z2); +}) + + +AL_INLINE(void, persp_project, (fixed x, fixed y, fixed z, fixed *xout, fixed *yout), +{ + *xout = fixmul(fixdiv(x, z), _persp_xscale) + _persp_xoffset; + *yout = fixmul(fixdiv(y, z), _persp_yscale) + _persp_yoffset; +}) + + +AL_INLINE(void, persp_project_f, (float x, float y, float z, float *xout, float *yout), +{ + float z1 = 1.0f / z; + *xout = ((x * z1) * _persp_xscale_f) + _persp_xoffset_f; + *yout = ((y * z1) * _persp_yscale_f) + _persp_yoffset_f; +}) + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_3DMATHS_INL */ + + diff --git a/lib/allegro/include/allegro/inline/asm.inl b/lib/allegro/include/allegro/inline/asm.inl new file mode 100644 index 0000000..4177da1 --- /dev/null +++ b/lib/allegro/include/allegro/inline/asm.inl @@ -0,0 +1,59 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Imports asm definitions of various inline functions. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + +#ifdef __cplusplus + extern "C" { +#endif + + +#ifndef ALLEGRO_NO_ASM + +#if (defined ALLEGRO_GCC) && (defined ALLEGRO_I386) + + /* use i386 asm, GCC syntax */ + #include "allegro/platform/al386gcc.h" + +#elif (defined ALLEGRO_MSVC) && (defined ALLEGRO_I386) + + /* use i386 asm, MSVC syntax */ + #include "allegro/platform/al386vc.h" + +#elif (defined ALLEGRO_WATCOM) && (defined ALLEGRO_I386) + + /* use i386 asm, Watcom syntax */ + #include "allegro/platform/al386wat.h" + +#else + + /* asm not supported */ + #define ALLEGRO_NO_ASM + +#endif + +#endif + +/* Define ALLEGRO_USE_C for backwards compatibility. It should not be used + * anywhere else in the sources for now. + */ +#ifdef ALLEGRO_NO_ASM +#define ALLEGRO_USE_C +#endif + +#ifdef __cplusplus + } +#endif + diff --git a/lib/allegro/include/allegro/inline/color.inl b/lib/allegro/include/allegro/inline/color.inl new file mode 100644 index 0000000..6bd4406 --- /dev/null +++ b/lib/allegro/include/allegro/inline/color.inl @@ -0,0 +1,179 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Color inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_COLOR_INL +#define ALLEGRO_COLOR_INL + +#ifdef __cplusplus + extern "C" { +#endif + +AL_INLINE(int, makecol15, (int r, int g, int b), +{ + return (((r >> 3) << _rgb_r_shift_15) | + ((g >> 3) << _rgb_g_shift_15) | + ((b >> 3) << _rgb_b_shift_15)); +}) + + +AL_INLINE(int, makecol16, (int r, int g, int b), +{ + return (((r >> 3) << _rgb_r_shift_16) | + ((g >> 2) << _rgb_g_shift_16) | + ((b >> 3) << _rgb_b_shift_16)); +}) + + +AL_INLINE(int, makecol24, (int r, int g, int b), +{ + return ((r << _rgb_r_shift_24) | + (g << _rgb_g_shift_24) | + (b << _rgb_b_shift_24)); +}) + + +AL_INLINE(int, makecol32, (int r, int g, int b), +{ + return ((r << _rgb_r_shift_32) | + (g << _rgb_g_shift_32) | + (b << _rgb_b_shift_32)); +}) + + +AL_INLINE(int, makeacol32, (int r, int g, int b, int a), +{ + return ((r << _rgb_r_shift_32) | + (g << _rgb_g_shift_32) | + (b << _rgb_b_shift_32) | + (a << _rgb_a_shift_32)); +}) + + +AL_INLINE(int, getr8, (int c), +{ + return _rgb_scale_6[(int)_current_palette[c].r]; +}) + + +AL_INLINE(int, getg8, (int c), +{ + return _rgb_scale_6[(int)_current_palette[c].g]; +}) + + +AL_INLINE(int, getb8, (int c), +{ + return _rgb_scale_6[(int)_current_palette[c].b]; +}) + + +AL_INLINE(int, getr15, (int c), +{ + return _rgb_scale_5[(c >> _rgb_r_shift_15) & 0x1F]; +}) + + +AL_INLINE(int, getg15, (int c), +{ + return _rgb_scale_5[(c >> _rgb_g_shift_15) & 0x1F]; +}) + + +AL_INLINE(int, getb15, (int c), +{ + return _rgb_scale_5[(c >> _rgb_b_shift_15) & 0x1F]; +}) + + +AL_INLINE(int, getr16, (int c), +{ + return _rgb_scale_5[(c >> _rgb_r_shift_16) & 0x1F]; +}) + + +AL_INLINE(int, getg16, (int c), +{ + return _rgb_scale_6[(c >> _rgb_g_shift_16) & 0x3F]; +}) + + +AL_INLINE(int, getb16, (int c), +{ + return _rgb_scale_5[(c >> _rgb_b_shift_16) & 0x1F]; +}) + + +AL_INLINE(int, getr24, (int c), +{ + return ((c >> _rgb_r_shift_24) & 0xFF); +}) + + +AL_INLINE(int, getg24, (int c), +{ + return ((c >> _rgb_g_shift_24) & 0xFF); +}) + + +AL_INLINE(int, getb24, (int c), +{ + return ((c >> _rgb_b_shift_24) & 0xFF); +}) + + +AL_INLINE(int, getr32, (int c), +{ + return ((c >> _rgb_r_shift_32) & 0xFF); +}) + + +AL_INLINE(int, getg32, (int c), +{ + return ((c >> _rgb_g_shift_32) & 0xFF); +}) + + +AL_INLINE(int, getb32, (int c), +{ + return ((c >> _rgb_b_shift_32) & 0xFF); +}) + + +AL_INLINE(int, geta32, (int c), +{ + return ((c >> _rgb_a_shift_32) & 0xFF); +}) + + +#ifndef ALLEGRO_DOS + +AL_INLINE(void, _set_color, (int idx, AL_CONST RGB *p), +{ + set_color(idx, p); +}) + +#endif + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_COLOR_INL */ + + diff --git a/lib/allegro/include/allegro/inline/draw.inl b/lib/allegro/include/allegro/inline/draw.inl new file mode 100644 index 0000000..504eb22 --- /dev/null +++ b/lib/allegro/include/allegro/inline/draw.inl @@ -0,0 +1,543 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Draw inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_DRAW_INL +#define ALLEGRO_DRAW_INL + +#include "allegro/debug.h" +#include "allegro/3d.h" +#include "gfx.inl" + +#ifdef __cplusplus + extern "C" { +#endif + +AL_INLINE(int, getpixel, (BITMAP *bmp, int x, int y), +{ + ASSERT(bmp); + + return bmp->vtable->getpixel(bmp, x, y); +}) + + +AL_INLINE(void, putpixel, (BITMAP *bmp, int x, int y, int color), +{ + ASSERT(bmp); + + bmp->vtable->putpixel(bmp, x, y, color); +}) + + +AL_INLINE(void, _allegro_vline, (BITMAP *bmp, int x, int y_1, int y2, int color), +{ + ASSERT(bmp); + + bmp->vtable->vline(bmp, x, y_1, y2, color); +}) + + +AL_INLINE(void, _allegro_hline, (BITMAP *bmp, int x1, int y, int x2, int color), +{ + ASSERT(bmp); + + bmp->vtable->hline(bmp, x1, y, x2, color); +}) + + +/* The curses API also contains functions called vline and hline so we have + * called our functions _allegro_vline and _allegro_hline. User programs + * should use the vline/hline aliases as they are the official names. + */ +#ifndef ALLEGRO_NO_VHLINE_ALIAS + AL_ALIAS_VOID_RET(vline(BITMAP *bmp, int x, int y_1, int y2, int color), _allegro_vline(bmp, x, y_1, y2, color)) + AL_ALIAS_VOID_RET(hline(BITMAP *bmp, int x1, int y, int x2, int color), _allegro_hline(bmp, x1, y, x2, color)) +#endif + + +AL_INLINE(void, line, (BITMAP *bmp, int x1, int y_1, int x2, int y2, int color), +{ + ASSERT(bmp); + + bmp->vtable->line(bmp, x1, y_1, x2, y2, color); +}) + + +AL_INLINE(void, fastline, (BITMAP *bmp, int x1, int y_1, int x2, int y2, int color), +{ + ASSERT(bmp); + + bmp->vtable->fastline(bmp, x1, y_1, x2, y2, color); +}) + + +AL_INLINE(void, rectfill, (BITMAP *bmp, int x1, int y_1, int x2, int y2, int color), +{ + ASSERT(bmp); + + bmp->vtable->rectfill(bmp, x1, y_1, x2, y2, color); +}) + + +AL_INLINE(void, triangle, (BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color), +{ + ASSERT(bmp); + + bmp->vtable->triangle(bmp, x1, y_1, x2, y2, x3, y3, color); +}) + + +AL_INLINE(void, polygon, (BITMAP *bmp, int vertices, AL_CONST int *points, int color), +{ + ASSERT(bmp); + + bmp->vtable->polygon(bmp, vertices, points, color); +}) + + +AL_INLINE(void, rect, (BITMAP *bmp, int x1, int y_1, int x2, int y2, int color), +{ + ASSERT(bmp); + + bmp->vtable->rect(bmp, x1, y_1, x2, y2, color); +}) + + +AL_INLINE(void, circle, (BITMAP *bmp, int x, int y, int radius, int color), +{ + ASSERT(bmp); + + bmp->vtable->circle(bmp, x, y, radius, color); +}) + + +AL_INLINE(void, circlefill, (BITMAP *bmp, int x, int y, int radius, int color), +{ + ASSERT(bmp); + + bmp->vtable->circlefill(bmp, x, y, radius, color); +}) + + + +AL_INLINE(void, ellipse, (BITMAP *bmp, int x, int y, int rx, int ry, int color), +{ + ASSERT(bmp); + + bmp->vtable->ellipse(bmp, x, y, rx, ry, color); +}) + + + +AL_INLINE(void, ellipsefill, (BITMAP *bmp, int x, int y, int rx, int ry, int color), +{ + ASSERT(bmp); + + bmp->vtable->ellipsefill(bmp, x, y, rx, ry, color); +}) + + + +AL_INLINE(void, arc, (BITMAP *bmp, int x, int y, fixed ang1, fixed ang2, int r, int color), +{ + ASSERT(bmp); + + bmp->vtable->arc(bmp, x, y, ang1, ang2, r, color); +}) + + + +AL_INLINE(void, spline, (BITMAP *bmp, AL_CONST int points[8], int color), +{ + ASSERT(bmp); + + bmp->vtable->spline(bmp, points, color); +}) + + + +AL_INLINE(void, floodfill, (BITMAP *bmp, int x, int y, int color), +{ + ASSERT(bmp); + + bmp->vtable->floodfill(bmp, x, y, color); +}) + + + +AL_INLINE(void, polygon3d, (BITMAP *bmp, int type, BITMAP *texture, int vc, V3D *vtx[]), +{ + ASSERT(bmp); + + bmp->vtable->polygon3d(bmp, type, texture, vc, vtx); +}) + + + +AL_INLINE(void, polygon3d_f, (BITMAP *bmp, int type, BITMAP *texture, int vc, V3D_f *vtx[]), +{ + ASSERT(bmp); + + bmp->vtable->polygon3d_f(bmp, type, texture, vc, vtx); +}) + + + +AL_INLINE(void, triangle3d, (BITMAP *bmp, int type, BITMAP *texture, V3D *v1, V3D *v2, V3D *v3), +{ + ASSERT(bmp); + + bmp->vtable->triangle3d(bmp, type, texture, v1, v2, v3); +}) + + + +AL_INLINE(void, triangle3d_f, (BITMAP *bmp, int type, BITMAP *texture, V3D_f *v1, V3D_f *v2, V3D_f *v3), +{ + ASSERT(bmp); + + bmp->vtable->triangle3d_f(bmp, type, texture, v1, v2, v3); +}) + + + +AL_INLINE(void, quad3d, (BITMAP *bmp, int type, BITMAP *texture, V3D *v1, V3D *v2, V3D *v3, V3D *v4), +{ + ASSERT(bmp); + + bmp->vtable->quad3d(bmp, type, texture, v1, v2, v3, v4); +}) + + + +AL_INLINE(void, quad3d_f, (BITMAP *bmp, int type, BITMAP *texture, V3D_f *v1, V3D_f *v2, V3D_f *v3, V3D_f *v4), +{ + ASSERT(bmp); + + bmp->vtable->quad3d_f(bmp, type, texture, v1, v2, v3, v4); +}) + + + + + +AL_INLINE(void, draw_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y), +{ + ASSERT(bmp); + ASSERT(sprite); + + if (sprite->vtable->color_depth == 8) { + bmp->vtable->draw_256_sprite(bmp, sprite, x, y); + } + else { + ASSERT(bmp->vtable->color_depth == sprite->vtable->color_depth); + bmp->vtable->draw_sprite(bmp, sprite, x, y); + } +}) + + +AL_INLINE(void, draw_sprite_v_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y),{ + ASSERT(bmp); + ASSERT(sprite); + ASSERT(bmp->vtable->color_depth == sprite->vtable->color_depth); + + bmp->vtable->draw_sprite_v_flip(bmp, sprite, x, y); +}) + + +AL_INLINE(void, draw_sprite_h_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y),{ + ASSERT(bmp); + ASSERT(sprite); + ASSERT(bmp->vtable->color_depth == sprite->vtable->color_depth); + + bmp->vtable->draw_sprite_h_flip(bmp, sprite, x, y); +}) + + +AL_INLINE(void, draw_sprite_vh_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y), +{ + ASSERT(bmp); + ASSERT(sprite); + ASSERT(bmp->vtable->color_depth == sprite->vtable->color_depth); + + bmp->vtable->draw_sprite_vh_flip(bmp, sprite, x, y); +}) + + +AL_INLINE(void, draw_trans_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y), +{ + ASSERT(bmp); + ASSERT(sprite); + + if (sprite->vtable->color_depth == 32) { + ASSERT(bmp->vtable->draw_trans_rgba_sprite); + bmp->vtable->draw_trans_rgba_sprite(bmp, sprite, x, y); + } + else { + ASSERT((bmp->vtable->color_depth == sprite->vtable->color_depth) || + ((bmp->vtable->color_depth == 32) && + (sprite->vtable->color_depth == 8))); + bmp->vtable->draw_trans_sprite(bmp, sprite, x, y); + } +}) + + +AL_INLINE(void, draw_lit_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color), +{ + ASSERT(bmp); + ASSERT(sprite); + ASSERT(bmp->vtable->color_depth == sprite->vtable->color_depth); + + bmp->vtable->draw_lit_sprite(bmp, sprite, x, y, color); +}) + + +AL_INLINE(void, draw_gouraud_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4), +{ + ASSERT(bmp); + ASSERT(sprite); + ASSERT(bmp->vtable->color_depth == sprite->vtable->color_depth); + + bmp->vtable->draw_gouraud_sprite(bmp, sprite, x, y, c1, c2, c3, c4); +}) + + +AL_INLINE(void, draw_character_ex, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color, int bg), +{ + ASSERT(bmp); + ASSERT(sprite); + ASSERT(sprite->vtable->color_depth == 8); + + bmp->vtable->draw_character(bmp, sprite, x, y, color, bg); +}) + + +AL_INLINE(void, rotate_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle), +{ + ASSERT(bmp); + ASSERT(sprite); + + bmp->vtable->pivot_scaled_sprite_flip(bmp, sprite, (x<<16) + (sprite->w * 0x10000) / 2, + (y<<16) + (sprite->h * 0x10000) / 2, + sprite->w << 15, sprite->h << 15, + angle, 0x10000, FALSE); +}) + + +AL_INLINE(void, rotate_sprite_v_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle), +{ + ASSERT(bmp); + ASSERT(sprite); + + bmp->vtable->pivot_scaled_sprite_flip(bmp, sprite, (x<<16) + (sprite->w * 0x10000) / 2, + (y<<16) + (sprite->h * 0x10000) / 2, + sprite->w << 15, sprite->h << 15, + angle, 0x10000, TRUE); +}) + + +AL_INLINE(void, rotate_scaled_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle, fixed scale), +{ + ASSERT(bmp); + ASSERT(sprite); + + bmp->vtable->pivot_scaled_sprite_flip(bmp, sprite, (x<<16) + (sprite->w * scale) / 2, + (y<<16) + (sprite->h * scale) / 2, + sprite->w << 15, sprite->h << 15, + angle, scale, FALSE); +}) + + +AL_INLINE(void, rotate_scaled_sprite_v_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle, fixed scale), +{ + ASSERT(bmp); + ASSERT(sprite); + + bmp->vtable->pivot_scaled_sprite_flip(bmp, sprite, (x<<16) + (sprite->w * scale) / 2, + (y<<16) + (sprite->h * scale) / 2, + sprite->w << 15, sprite->h << 15, + angle, scale, TRUE); +}) + + +AL_INLINE(void, pivot_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle), +{ + ASSERT(bmp); + ASSERT(sprite); + + bmp->vtable->pivot_scaled_sprite_flip(bmp, sprite, x<<16, y<<16, cx<<16, cy<<16, angle, 0x10000, FALSE); +}) + + +AL_INLINE(void, pivot_sprite_v_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle), +{ + ASSERT(bmp); + ASSERT(sprite); + + bmp->vtable->pivot_scaled_sprite_flip(bmp, sprite, x<<16, y<<16, cx<<16, cy<<16, angle, 0x10000, TRUE); +}) + + +AL_INLINE(void, pivot_scaled_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle, fixed scale), +{ + ASSERT(bmp); + ASSERT(sprite); + + bmp->vtable->pivot_scaled_sprite_flip(bmp, sprite, x<<16, y<<16, cx<<16, cy<<16, angle, scale, FALSE); +}) + + +AL_INLINE(void, pivot_scaled_sprite_v_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle, fixed scale), +{ + ASSERT(bmp); + ASSERT(sprite); + + bmp->vtable->pivot_scaled_sprite_flip(bmp, sprite, x<<16, y<<16, cx<<16, cy<<16, angle, scale, TRUE); +}) + + +AL_INLINE(void, _putpixel, (BITMAP *bmp, int x, int y, int color), +{ + uintptr_t addr; + + bmp_select(bmp); + addr = bmp_write_line(bmp, y); + bmp_write8(addr+x, color); + bmp_unwrite_line(bmp); +}) + + +AL_INLINE(int, _getpixel, (BITMAP *bmp, int x, int y), +{ + uintptr_t addr; + int c; + + bmp_select(bmp); + addr = bmp_read_line(bmp, y); + c = bmp_read8(addr+x); + bmp_unwrite_line(bmp); + + return c; +}) + + +AL_INLINE(void, _putpixel15, (BITMAP *bmp, int x, int y, int color), +{ + uintptr_t addr; + + bmp_select(bmp); + addr = bmp_write_line(bmp, y); + bmp_write15(addr+x*sizeof(short), color); + bmp_unwrite_line(bmp); +}) + + +AL_INLINE(int, _getpixel15, (BITMAP *bmp, int x, int y), +{ + uintptr_t addr; + int c; + + bmp_select(bmp); + addr = bmp_read_line(bmp, y); + c = bmp_read15(addr+x*sizeof(short)); + bmp_unwrite_line(bmp); + + return c; +}) + + +AL_INLINE(void, _putpixel16, (BITMAP *bmp, int x, int y, int color), +{ + uintptr_t addr; + + bmp_select(bmp); + addr = bmp_write_line(bmp, y); + bmp_write16(addr+x*sizeof(short), color); + bmp_unwrite_line(bmp); +}) + + +AL_INLINE(int, _getpixel16, (BITMAP *bmp, int x, int y), +{ + uintptr_t addr; + int c; + + bmp_select(bmp); + addr = bmp_read_line(bmp, y); + c = bmp_read16(addr+x*sizeof(short)); + bmp_unwrite_line(bmp); + + return c; +}) + + +AL_INLINE(void, _putpixel24, (BITMAP *bmp, int x, int y, int color), +{ + uintptr_t addr; + + bmp_select(bmp); + addr = bmp_write_line(bmp, y); + bmp_write24(addr+x*3, color); + bmp_unwrite_line(bmp); +}) + + +AL_INLINE(int, _getpixel24, (BITMAP *bmp, int x, int y), +{ + uintptr_t addr; + int c; + + bmp_select(bmp); + addr = bmp_read_line(bmp, y); + c = bmp_read24(addr+x*3); + bmp_unwrite_line(bmp); + + return c; +}) + + +AL_INLINE(void, _putpixel32, (BITMAP *bmp, int x, int y, int color), +{ + uintptr_t addr; + + bmp_select(bmp); + addr = bmp_write_line(bmp, y); + bmp_write32(addr+x*sizeof(int32_t), color); + bmp_unwrite_line(bmp); +}) + + +AL_INLINE(int, _getpixel32, (BITMAP *bmp, int x, int y), +{ + uintptr_t addr; + int c; + + bmp_select(bmp); + addr = bmp_read_line(bmp, y); + c = bmp_read32(addr+x*sizeof(int32_t)); + bmp_unwrite_line(bmp); + + return c; +}) + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_DRAW_INL */ + + diff --git a/lib/allegro/include/allegro/inline/file.inl b/lib/allegro/include/allegro/inline/file.inl new file mode 100644 index 0000000..a1c8779 --- /dev/null +++ b/lib/allegro/include/allegro/inline/file.inl @@ -0,0 +1,6 @@ +#ifndef ALLEGRO_FILE_INL +#define ALLEGRO_FILE_INL + +#warning file.inl should no longer be referenced. + +#endif /* ifndef ALLEGRO_FILE_INL */ diff --git a/lib/allegro/include/allegro/inline/fix.inl b/lib/allegro/include/allegro/inline/fix.inl new file mode 100644 index 0000000..7f10581 --- /dev/null +++ b/lib/allegro/include/allegro/inline/fix.inl @@ -0,0 +1,254 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Fix class inline functions. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_FIX_INL +#define ALLEGRO_FIX_INL + +#ifdef __cplusplus + + +inline fix operator + (const fix x, const fix y) { fix t; t.v = x.v + y.v; return t; } +inline fix operator + (const fix x, const int y) { fix t; t.v = x.v + itofix(y); return t; } +inline fix operator + (const int x, const fix y) { fix t; t.v = itofix(x) + y.v; return t; } +inline fix operator + (const fix x, const long y) { fix t; t.v = x.v + itofix(y); return t; } +inline fix operator + (const long x, const fix y) { fix t; t.v = itofix(x) + y.v; return t; } +inline fix operator + (const fix x, const float y) { fix t; t.v = x.v + ftofix(y); return t; } +inline fix operator + (const float x, const fix y) { fix t; t.v = ftofix(x) + y.v; return t; } +inline fix operator + (const fix x, const double y) { fix t; t.v = x.v + ftofix(y); return t; } +inline fix operator + (const double x, const fix y) { fix t; t.v = ftofix(x) + y.v; return t; } + +inline fix operator - (const fix x, const fix y) { fix t; t.v = x.v - y.v; return t; } +inline fix operator - (const fix x, const int y) { fix t; t.v = x.v - itofix(y); return t; } +inline fix operator - (const int x, const fix y) { fix t; t.v = itofix(x) - y.v; return t; } +inline fix operator - (const fix x, const long y) { fix t; t.v = x.v - itofix(y); return t; } +inline fix operator - (const long x, const fix y) { fix t; t.v = itofix(x) - y.v; return t; } +inline fix operator - (const fix x, const float y) { fix t; t.v = x.v - ftofix(y); return t; } +inline fix operator - (const float x, const fix y) { fix t; t.v = ftofix(x) - y.v; return t; } +inline fix operator - (const fix x, const double y) { fix t; t.v = x.v - ftofix(y); return t; } +inline fix operator - (const double x, const fix y) { fix t; t.v = ftofix(x) - y.v; return t; } + +inline fix operator * (const fix x, const fix y) { fix t; t.v = fixmul(x.v, y.v); return t; } +inline fix operator * (const fix x, const int y) { fix t; t.v = x.v * y; return t; } +inline fix operator * (const int x, const fix y) { fix t; t.v = x * y.v; return t; } +inline fix operator * (const fix x, const long y) { fix t; t.v = x.v * y; return t; } +inline fix operator * (const long x, const fix y) { fix t; t.v = x * y.v; return t; } +inline fix operator * (const fix x, const float y) { fix t; t.v = ftofix(fixtof(x.v) * y); return t; } +inline fix operator * (const float x, const fix y) { fix t; t.v = ftofix(x * fixtof(y.v)); return t; } +inline fix operator * (const fix x, const double y) { fix t; t.v = ftofix(fixtof(x.v) * y); return t; } +inline fix operator * (const double x, const fix y) { fix t; t.v = ftofix(x * fixtof(y.v)); return t; } + +inline fix operator / (const fix x, const fix y) { fix t; t.v = fixdiv(x.v, y.v); return t; } +inline fix operator / (const fix x, const int y) { fix t; t.v = x.v / y; return t; } +inline fix operator / (const int x, const fix y) { fix t; t.v = fixdiv(itofix(x), y.v); return t; } +inline fix operator / (const fix x, const long y) { fix t; t.v = x.v / y; return t; } +inline fix operator / (const long x, const fix y) { fix t; t.v = fixdiv(itofix(x), y.v); return t; } +inline fix operator / (const fix x, const float y) { fix t; t.v = ftofix(fixtof(x.v) / y); return t; } +inline fix operator / (const float x, const fix y) { fix t; t.v = ftofix(x / fixtof(y.v)); return t; } +inline fix operator / (const fix x, const double y) { fix t; t.v = ftofix(fixtof(x.v) / y); return t; } +inline fix operator / (const double x, const fix y) { fix t; t.v = ftofix(x / fixtof(y.v)); return t; } + +inline fix operator << (const fix x, const int y) { fix t; t.v = x.v << y; return t; } +inline fix operator >> (const fix x, const int y) { fix t; t.v = x.v >> y; return t; } + +inline int operator == (const fix x, const fix y) { return (x.v == y.v); } +inline int operator == (const fix x, const int y) { return (x.v == itofix(y)); } +inline int operator == (const int x, const fix y) { return (itofix(x) == y.v); } +inline int operator == (const fix x, const long y) { return (x.v == itofix(y)); } +inline int operator == (const long x, const fix y) { return (itofix(x) == y.v); } +inline int operator == (const fix x, const float y) { return (x.v == ftofix(y)); } +inline int operator == (const float x, const fix y) { return (ftofix(x) == y.v); } +inline int operator == (const fix x, const double y) { return (x.v == ftofix(y)); } +inline int operator == (const double x, const fix y) { return (ftofix(x) == y.v); } + +inline int operator != (const fix x, const fix y) { return (x.v != y.v); } +inline int operator != (const fix x, const int y) { return (x.v != itofix(y)); } +inline int operator != (const int x, const fix y) { return (itofix(x) != y.v); } +inline int operator != (const fix x, const long y) { return (x.v != itofix(y)); } +inline int operator != (const long x, const fix y) { return (itofix(x) != y.v); } +inline int operator != (const fix x, const float y) { return (x.v != ftofix(y)); } +inline int operator != (const float x, const fix y) { return (ftofix(x) != y.v); } +inline int operator != (const fix x, const double y) { return (x.v != ftofix(y)); } +inline int operator != (const double x, const fix y) { return (ftofix(x) != y.v); } + +inline int operator < (const fix x, const fix y) { return (x.v < y.v); } +inline int operator < (const fix x, const int y) { return (x.v < itofix(y)); } +inline int operator < (const int x, const fix y) { return (itofix(x) < y.v); } +inline int operator < (const fix x, const long y) { return (x.v < itofix(y)); } +inline int operator < (const long x, const fix y) { return (itofix(x) < y.v); } +inline int operator < (const fix x, const float y) { return (x.v < ftofix(y)); } +inline int operator < (const float x, const fix y) { return (ftofix(x) < y.v); } +inline int operator < (const fix x, const double y) { return (x.v < ftofix(y)); } +inline int operator < (const double x, const fix y) { return (ftofix(x) < y.v); } + +inline int operator > (const fix x, const fix y) { return (x.v > y.v); } +inline int operator > (const fix x, const int y) { return (x.v > itofix(y)); } +inline int operator > (const int x, const fix y) { return (itofix(x) > y.v); } +inline int operator > (const fix x, const long y) { return (x.v > itofix(y)); } +inline int operator > (const long x, const fix y) { return (itofix(x) > y.v); } +inline int operator > (const fix x, const float y) { return (x.v > ftofix(y)); } +inline int operator > (const float x, const fix y) { return (ftofix(x) > y.v); } +inline int operator > (const fix x, const double y) { return (x.v > ftofix(y)); } +inline int operator > (const double x, const fix y) { return (ftofix(x) > y.v); } + +inline int operator <= (const fix x, const fix y) { return (x.v <= y.v); } +inline int operator <= (const fix x, const int y) { return (x.v <= itofix(y)); } +inline int operator <= (const int x, const fix y) { return (itofix(x) <= y.v); } +inline int operator <= (const fix x, const long y) { return (x.v <= itofix(y)); } +inline int operator <= (const long x, const fix y) { return (itofix(x) <= y.v); } +inline int operator <= (const fix x, const float y) { return (x.v <= ftofix(y)); } +inline int operator <= (const float x, const fix y) { return (ftofix(x) <= y.v); } +inline int operator <= (const fix x, const double y) { return (x.v <= ftofix(y)); } +inline int operator <= (const double x, const fix y) { return (ftofix(x) <= y.v); } + +inline int operator >= (const fix x, const fix y) { return (x.v >= y.v); } +inline int operator >= (const fix x, const int y) { return (x.v >= itofix(y)); } +inline int operator >= (const int x, const fix y) { return (itofix(x) >= y.v); } +inline int operator >= (const fix x, const long y) { return (x.v >= itofix(y)); } +inline int operator >= (const long x, const fix y) { return (itofix(x) >= y.v); } +inline int operator >= (const fix x, const float y) { return (x.v >= ftofix(y)); } +inline int operator >= (const float x, const fix y) { return (ftofix(x) >= y.v); } +inline int operator >= (const fix x, const double y) { return (x.v >= ftofix(y)); } +inline int operator >= (const double x, const fix y) { return (ftofix(x) >= y.v); } + +inline fix sqrt(fix x) { fix t; t.v = fixsqrt(x.v); return t; } +inline fix cos(fix x) { fix t; t.v = fixcos(x.v); return t; } +inline fix sin(fix x) { fix t; t.v = fixsin(x.v); return t; } +inline fix tan(fix x) { fix t; t.v = fixtan(x.v); return t; } +inline fix acos(fix x) { fix t; t.v = fixacos(x.v); return t; } +inline fix asin(fix x) { fix t; t.v = fixasin(x.v); return t; } +inline fix atan(fix x) { fix t; t.v = fixatan(x.v); return t; } +inline fix atan2(fix x, fix y) { fix t; t.v = fixatan2(x.v, y.v); return t; } + + +inline void get_translation_matrix(MATRIX *m, fix x, fix y, fix z) +{ + get_translation_matrix(m, x.v, y.v, z.v); +} + + +inline void get_scaling_matrix(MATRIX *m, fix x, fix y, fix z) +{ + get_scaling_matrix(m, x.v, y.v, z.v); +} + + +inline void get_x_rotate_matrix(MATRIX *m, fix r) +{ + get_x_rotate_matrix(m, r.v); +} + + +inline void get_y_rotate_matrix(MATRIX *m, fix r) +{ + get_y_rotate_matrix(m, r.v); +} + + +inline void get_z_rotate_matrix(MATRIX *m, fix r) +{ + get_z_rotate_matrix(m, r.v); +} + + +inline void get_rotation_matrix(MATRIX *m, fix x, fix y, fix z) +{ + get_rotation_matrix(m, x.v, y.v, z.v); +} + + +inline void get_align_matrix(MATRIX *m, fix xfront, fix yfront, fix zfront, fix xup, fix yup, fix zup) +{ + get_align_matrix(m, xfront.v, yfront.v, zfront.v, xup.v, yup.v, zup.v); +} + + +inline void get_vector_rotation_matrix(MATRIX *m, fix x, fix y, fix z, fix a) +{ + get_vector_rotation_matrix(m, x.v, y.v, z.v, a.v); +} + + +inline void get_transformation_matrix(MATRIX *m, fix scale, fix xrot, fix yrot, fix zrot, fix x, fix y, fix z) +{ + get_transformation_matrix(m, scale.v, xrot.v, yrot.v, zrot.v, x.v, y.v, z.v); +} + + +inline void get_camera_matrix(MATRIX *m, fix x, fix y, fix z, fix xfront, fix yfront, fix zfront, fix xup, fix yup, fix zup, fix fov, fix aspect) +{ + get_camera_matrix(m, x.v, y.v, z.v, xfront.v, yfront.v, zfront.v, xup.v, yup.v, zup.v, fov.v, aspect.v); +} + + +inline void qtranslate_matrix(MATRIX *m, fix x, fix y, fix z) +{ + qtranslate_matrix(m, x.v, y.v, z.v); +} + + +inline void qscale_matrix(MATRIX *m, fix scale) +{ + qscale_matrix(m, scale.v); +} + + +inline fix vector_length(fix x, fix y, fix z) +{ + fix t; + t.v = vector_length(x.v, y.v, z.v); + return t; +} + + +inline void normalize_vector(fix *x, fix *y, fix *z) +{ + normalize_vector(&x->v, &y->v, &z->v); +} + + +inline void cross_product(fix x1, fix y_1, fix z1, fix x2, fix y2, fix z2, fix *xout, fix *yout, fix *zout) +{ + cross_product(x1.v, y_1.v, z1.v, x2.v, y2.v, z2.v, &xout->v, &yout->v, &zout->v); +} + + +inline fix dot_product(fix x1, fix y_1, fix z1, fix x2, fix y2, fix z2) +{ + fix t; + t.v = dot_product(x1.v, y_1.v, z1.v, x2.v, y2.v, z2.v); + return t; +} + + +inline void apply_matrix(MATRIX *m, fix x, fix y, fix z, fix *xout, fix *yout, fix *zout) +{ + apply_matrix(m, x.v, y.v, z.v, &xout->v, &yout->v, &zout->v); +} + + +inline void persp_project(fix x, fix y, fix z, fix *xout, fix *yout) +{ + persp_project(x.v, y.v, z.v, &xout->v, &yout->v); +} + + +#endif /* ifdef __cplusplus */ + +#endif /* ifndef ALLEGRO_FIX_INL */ + + diff --git a/lib/allegro/include/allegro/inline/fmaths.inl b/lib/allegro/include/allegro/inline/fmaths.inl new file mode 100644 index 0000000..cf67960 --- /dev/null +++ b/lib/allegro/include/allegro/inline/fmaths.inl @@ -0,0 +1,238 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Fixed point math inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_FMATHS_INL +#define ALLEGRO_FMATHS_INL + +#define ALLEGRO_IMPORT_MATH_ASM +#include "asm.inl" +#undef ALLEGRO_IMPORT_MATH_ASM + +#ifdef __cplusplus + extern "C" { +#endif + + +/* ftofix and fixtof are used in generic C versions of fixmul and fixdiv */ +AL_INLINE(fixed, ftofix, (double x), +{ + if (x > 32767.0) { + *allegro_errno = ERANGE; + return 0x7FFFFFFF; + } + + if (x < -32767.0) { + *allegro_errno = ERANGE; + return -0x7FFFFFFF; + } + + return (fixed)(x * 65536.0 + (x < 0 ? -0.5 : 0.5)); +}) + + +AL_INLINE(double, fixtof, (fixed x), +{ + return (double)x / 65536.0; +}) + + +#ifdef ALLEGRO_NO_ASM + +/* use generic C versions */ + +AL_INLINE(fixed, fixadd, (fixed x, fixed y), +{ + fixed result = x + y; + + if (result >= 0) { + if ((x < 0) && (y < 0)) { + *allegro_errno = ERANGE; + return -0x7FFFFFFF; + } + else + return result; + } + else { + if ((x > 0) && (y > 0)) { + *allegro_errno = ERANGE; + return 0x7FFFFFFF; + } + else + return result; + } +}) + + +AL_INLINE(fixed, fixsub, (fixed x, fixed y), +{ + fixed result = x - y; + + if (result >= 0) { + if ((x < 0) && (y > 0)) { + *allegro_errno = ERANGE; + return -0x7FFFFFFF; + } + else + return result; + } + else { + if ((x > 0) && (y < 0)) { + *allegro_errno = ERANGE; + return 0x7FFFFFFF; + } + else + return result; + } +}) + + +/* In benchmarks conducted circa May 2005 we found that, in the main: + * - IA32 machines performed faster with one implementation; + * - AMD64 and G4 machines performed faster with another implementation. + * + * Benchmarks were mainly done with differing versions of gcc. + * Results varied with other compilers, optimisation levels, etc. + * so this is not optimal, though a tenable compromise. + * + * Note that the following implementation are NOT what were benchmarked. + * We had forgotten to put in overflow detection in those versions. + * If you don't need overflow detection then previous versions in the + * CVS tree might be worth looking at. + * + * PS. Don't move the #ifs inside the AL_INLINE; BCC doesn't like it. + */ +#if (defined ALLEGRO_I386) || (!defined LONG_LONG) + AL_INLINE(fixed, fixmul, (fixed x, fixed y), + { + return ftofix(fixtof(x) * fixtof(y)); + }) +#else + AL_INLINE(fixed, fixmul, (fixed x, fixed y), + { + LONG_LONG lx = x; + LONG_LONG ly = y; + LONG_LONG lres = (lx*ly); + + if (lres > 0x7FFFFFFF0000LL) { + *allegro_errno = ERANGE; + return 0x7FFFFFFF; + } + else if (lres < -0x7FFFFFFF0000LL) { + *allegro_errno = ERANGE; + return 0x80000000; + } + else { + int res = lres >> 16; + return res; + } + }) +#endif /* fixmul() C implementations */ + + +AL_INLINE(fixed, fixdiv, (fixed x, fixed y), +{ + if (y == 0) { + *allegro_errno = ERANGE; + return (x < 0) ? -0x7FFFFFFF : 0x7FFFFFFF; + } + else + return ftofix(fixtof(x) / fixtof(y)); +}) + + +AL_INLINE(int, fixfloor, (fixed x), +{ + /* (x >> 16) is not portable */ + if (x >= 0) + return (x >> 16); + else + return ~((~x) >> 16); +}) + + +AL_INLINE(int, fixceil, (fixed x), +{ + if (x > 0x7FFF0000) { + *allegro_errno = ERANGE; + return 0x7FFF; + } + + return fixfloor(x + 0xFFFF); +}) + +#endif /* C vs. inline asm */ + + +AL_INLINE(fixed, itofix, (int x), +{ + return x << 16; +}) + + +AL_INLINE(int, fixtoi, (fixed x), +{ + return fixfloor(x) + ((x & 0x8000) >> 15); +}) + + +AL_INLINE(fixed, fixcos, (fixed x), +{ + return _cos_tbl[((x + 0x4000) >> 15) & 0x1FF]; +}) + + +AL_INLINE(fixed, fixsin, (fixed x), +{ + return _cos_tbl[((x - 0x400000 + 0x4000) >> 15) & 0x1FF]; +}) + + +AL_INLINE(fixed, fixtan, (fixed x), +{ + return _tan_tbl[((x + 0x4000) >> 15) & 0xFF]; +}) + + +AL_INLINE(fixed, fixacos, (fixed x), +{ + if ((x < -65536) || (x > 65536)) { + *allegro_errno = EDOM; + return 0; + } + + return _acos_tbl[(x+65536+127)>>8]; +}) + + +AL_INLINE(fixed, fixasin, (fixed x), +{ + if ((x < -65536) || (x > 65536)) { + *allegro_errno = EDOM; + return 0; + } + + return 0x00400000 - _acos_tbl[(x+65536+127)>>8]; +}) + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_FMATHS_INL */ + + diff --git a/lib/allegro/include/allegro/inline/gfx.inl b/lib/allegro/include/allegro/inline/gfx.inl new file mode 100644 index 0000000..5fefbc4 --- /dev/null +++ b/lib/allegro/include/allegro/inline/gfx.inl @@ -0,0 +1,284 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Graphics inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_GFX_INL +#define ALLEGRO_GFX_INL + +#include "allegro/debug.h" + +#define ALLEGRO_IMPORT_GFX_ASM +#include "asm.inl" +#undef ALLEGRO_IMPORT_GFX_ASM + +#ifdef __cplusplus + extern "C" { +#endif + + +#ifdef ALLEGRO_NO_ASM + + /* use generic C versions */ + +AL_INLINE(int, _default_ds, (void), +{ + return 0; +}) + +#ifdef ALLEGRO_BCC32 + + /* BCC32 is a somewhat unusual platform because it mixes a MSVC/MinGW generated DLL + * (for which ALLEGRO_NO_ASM is not defined) with Borland C++ compiled programs for + * which ALLEGRO_NO_ASM is defined. As a result, Borland C++ compiled programs can't + * use the inlined version of bmp_write_line(), bmp_read_line() and bmp_unwrite_line() + * because the write_bank() and read_bank() methods of the BITMAP class don't expect + * the same calling convention on both sides. + */ + +AL_FUNC(uintptr_t, bmp_write_line, (BITMAP *bmp, int lyne)); +AL_FUNC(uintptr_t, bmp_read_line, (BITMAP *bmp, int lyne)); +AL_FUNC(void, bmp_unwrite_line, (BITMAP *bmp)); + +#else + +typedef AL_METHOD(uintptr_t, _BMP_BANK_SWITCHER, (BITMAP *bmp, int lyne)); +typedef AL_METHOD(void, _BMP_UNBANK_SWITCHER, (BITMAP *bmp)); + + +AL_INLINE(uintptr_t, bmp_write_line, (BITMAP *bmp, int lyne), +{ + _BMP_BANK_SWITCHER switcher = (_BMP_BANK_SWITCHER)bmp->write_bank; + return switcher(bmp, lyne); +}) + + +AL_INLINE(uintptr_t, bmp_read_line, (BITMAP *bmp, int lyne), +{ + _BMP_BANK_SWITCHER switcher = (_BMP_BANK_SWITCHER)bmp->read_bank; + return switcher(bmp, lyne); +}) + + +AL_INLINE(void, bmp_unwrite_line, (BITMAP *bmp), +{ + _BMP_UNBANK_SWITCHER switcher = (_BMP_UNBANK_SWITCHER)bmp->vtable->unwrite_bank; + switcher(bmp); +}) + +#endif /* defined ALLEGRO_BCC32 */ + +#endif /* C vs. inline asm */ + + +AL_INLINE(int, is_windowed_mode, (void), +{ + ASSERT (gfx_driver); + + return gfx_driver->windowed; +}) + + + +AL_INLINE(void, clear_to_color, (BITMAP *bitmap, int color), +{ + ASSERT(bitmap); + + bitmap->vtable->clear_to_color(bitmap, color); +}) + + +AL_INLINE(int, bitmap_color_depth, (BITMAP *bmp), +{ + ASSERT(bmp); + + return bmp->vtable->color_depth; +}) + + +AL_INLINE(int, bitmap_mask_color, (BITMAP *bmp), +{ + ASSERT(bmp); + + return bmp->vtable->mask_color; +}) + + +AL_INLINE(int, is_same_bitmap, (BITMAP *bmp1, BITMAP *bmp2), +{ + unsigned long m1; + unsigned long m2; + + if ((!bmp1) || (!bmp2)) + return FALSE; + + if (bmp1 == bmp2) + return TRUE; + + m1 = bmp1->id & BMP_ID_MASK; + m2 = bmp2->id & BMP_ID_MASK; + + return ((m1) && (m1 == m2)); +}) + + +AL_INLINE(int, is_linear_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + return (bmp->id & BMP_ID_PLANAR) == 0; +}) + + +AL_INLINE(int, is_planar_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + return (bmp->id & BMP_ID_PLANAR) != 0; +}) + + +AL_INLINE(int, is_memory_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + return (bmp->id & (BMP_ID_VIDEO | BMP_ID_SYSTEM)) == 0; +}) + + +AL_INLINE(int, is_screen_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + return is_same_bitmap(bmp, screen); +}) + + +AL_INLINE(int, is_video_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + return (bmp->id & BMP_ID_VIDEO) != 0; +}) + + +AL_INLINE(int, is_system_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + return (bmp->id & BMP_ID_SYSTEM) != 0; +}) + + +AL_INLINE(int, is_sub_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + return (bmp->id & BMP_ID_SUB) != 0; +}) + + +#ifdef ALLEGRO_MPW + + #define acquire_bitmap(bmp) + #define release_bitmap(bmp) + #define acquire_screen() + #define release_screen() + +#else + +AL_INLINE(void, acquire_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + if (bmp->vtable->acquire) + bmp->vtable->acquire(bmp); +}) + + +AL_INLINE(void, release_bitmap, (BITMAP *bmp), +{ + ASSERT(bmp); + + if (bmp->vtable->release) + bmp->vtable->release(bmp); +}) + + +AL_INLINE(void, acquire_screen, (void), +{ + acquire_bitmap(screen); +}) + + +AL_INLINE(void, release_screen, (void), +{ + release_bitmap(screen); +}) + +#endif + + +AL_INLINE(int, is_inside_bitmap, (BITMAP *bmp, int x, int y, int clip), +{ + ASSERT(bmp); + + if (clip) { + if (bmp->clip) + /* internal clipping is inclusive-exclusive */ + return (x >= bmp->cl) && (y >= bmp->ct) && (x < bmp->cr) && (y < bmp->cb); + else + return TRUE; + } + else + /* bitmap dimensions are always non-negative */ + return (unsigned int)x < (unsigned int)bmp->w && (unsigned int)y < (unsigned int)bmp->h; +}) + + +AL_INLINE(void, get_clip_rect, (BITMAP *bitmap, int *x1, int *y_1, int *x2, int *y2), +{ + ASSERT(bitmap); + + /* internal clipping is inclusive-exclusive */ + *x1 = bitmap->cl; + *y_1 = bitmap->ct; + *x2 = bitmap->cr-1; + *y2 = bitmap->cb-1; +}) + +AL_INLINE(void, set_clip_state, (BITMAP *bitmap, int state), +{ + ASSERT(bitmap); + + bitmap->clip = state; +}) + +AL_INLINE(int, get_clip_state, (BITMAP *bitmap), +{ + ASSERT(bitmap); + + return bitmap->clip; +}) + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_GFX_INL */ + + diff --git a/lib/allegro/include/allegro/inline/matrix.inl b/lib/allegro/include/allegro/inline/matrix.inl new file mode 100644 index 0000000..3dbdecf --- /dev/null +++ b/lib/allegro/include/allegro/inline/matrix.inl @@ -0,0 +1,48 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Matrix math inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_MATRIX_INL +#define ALLEGRO_MATRIX_INL + +#ifdef __cplusplus + extern "C" { +#endif + + +#define CALC_ROW(n) (fixmul(x, m->v[n][0]) + \ + fixmul(y, m->v[n][1]) + \ + fixmul(z, m->v[n][2]) + \ + m->t[n]) + +AL_INLINE(void, apply_matrix, (MATRIX *m, fixed x, fixed y, fixed z, fixed *xout, fixed *yout, fixed *zout), +{ + *xout = CALC_ROW(0); + *yout = CALC_ROW(1); + *zout = CALC_ROW(2); +}) + +#undef CALC_ROW + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_MATRIX_INL */ + + diff --git a/lib/allegro/include/allegro/inline/rle.inl b/lib/allegro/include/allegro/inline/rle.inl new file mode 100644 index 0000000..52730db --- /dev/null +++ b/lib/allegro/include/allegro/inline/rle.inl @@ -0,0 +1,70 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * RLE sprite inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_RLE_INL +#define ALLEGRO_RLE_INL + +#include "allegro/debug.h" + +#ifdef __cplusplus + extern "C" { +#endif + + +AL_INLINE(void, draw_rle_sprite, (struct BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y), +{ + ASSERT(bmp); + ASSERT(sprite); + ASSERT(bmp->vtable->color_depth == sprite->color_depth); + + bmp->vtable->draw_rle_sprite(bmp, sprite, x, y); +}) + + +AL_INLINE(void, draw_trans_rle_sprite, (struct BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y), +{ + ASSERT(bmp); + ASSERT(sprite); + + if (sprite->color_depth == 32) { + ASSERT(bmp->vtable->draw_trans_rgba_rle_sprite); + bmp->vtable->draw_trans_rgba_rle_sprite(bmp, sprite, x, y); + } + else { + ASSERT(bmp->vtable->color_depth == sprite->color_depth); + bmp->vtable->draw_trans_rle_sprite(bmp, sprite, x, y); + } +}) + + +AL_INLINE(void, draw_lit_rle_sprite, (struct BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y, int color), +{ + ASSERT(bmp); + ASSERT(sprite); + ASSERT(bmp->vtable->color_depth == sprite->color_depth); + + bmp->vtable->draw_lit_rle_sprite(bmp, sprite, x, y, color); +}) + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_RLE_INL */ + + diff --git a/lib/allegro/include/allegro/inline/system.inl b/lib/allegro/include/allegro/inline/system.inl new file mode 100644 index 0000000..0fa7a79 --- /dev/null +++ b/lib/allegro/include/allegro/inline/system.inl @@ -0,0 +1,67 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * System inline functions (generic C). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_SYSTEM_INL +#define ALLEGRO_SYSTEM_INL + +#include "allegro/debug.h" + +#ifdef __cplusplus + extern "C" { +#endif + + +AL_INLINE(void, set_window_title, (AL_CONST char *name), +{ + ASSERT(system_driver); + + if (system_driver->set_window_title) + system_driver->set_window_title(name); +}) + + +AL_INLINE(int, desktop_color_depth, (void), +{ + ASSERT(system_driver); + + if (system_driver->desktop_color_depth) + return system_driver->desktop_color_depth(); + else + return 0; +}) + + +AL_INLINE(int, get_desktop_resolution, (int *width, int *height), +{ + ASSERT(system_driver); + + if (system_driver->get_desktop_resolution) + return system_driver->get_desktop_resolution(width, height); + else + return -1; +}) + + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_SYSTEM_INL */ + + diff --git a/lib/allegro/include/allegro/internal/aintern.h b/lib/allegro/include/allegro/internal/aintern.h new file mode 100644 index 0000000..ad07d8a --- /dev/null +++ b/lib/allegro/include/allegro/internal/aintern.h @@ -0,0 +1,1258 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Some definitions for internal use by the library code. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef AINTERN_H +#define AINTERN_H + +#ifndef ALLEGRO_H + #error must include allegro.h first +#endif + +#ifdef __cplusplus + extern "C" { +#endif + + +/* length in bytes of the cpu_vendor string */ +#define _AL_CPU_VENDOR_SIZE 32 + + +/* flag for how many times we have been initialised */ +AL_VAR(int, _allegro_count); + + +/* flag to know whether we are being called by the exit mechanism */ +AL_VAR(int, _allegro_in_exit); + + +/* These functions are referenced by 4.2.0 binaries, but should no longer be + * used by newer versions directly. + * _get_allegro_version would be marked deprecated except that misc/fixdll.* + * would complain about it being missing. + */ +AL_FUNC(int, _get_allegro_version, (void)); +AL_FUNC(int, _install_allegro, (int system_id, int *errno_ptr, AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void)))))); + + +/* flag to decide whether to disable the screensaver */ +enum { + NEVER_DISABLED, + FULLSCREEN_DISABLED, + ALWAYS_DISABLED +}; + +AL_VAR(int, _screensaver_policy); + + +/* malloc wrappers */ +/* The 4.3 branch uses the following macro names to allow the user to customise + * the memory management routines. We don't have that feature in 4.2, but we + * use the same macros names in order to reduce divergence of the codebases. + */ +#define _AL_MALLOC(SIZE) (_al_malloc(SIZE)) +#define _AL_MALLOC_ATOMIC(SIZE) (_al_malloc(SIZE)) +#define _AL_FREE(PTR) (_al_free(PTR)) +#define _AL_REALLOC(PTR, SIZE) (_al_realloc(PTR, SIZE)) + +AL_FUNC(void *, _al_malloc, (int size)); +AL_FUNC(void, _al_free, (void *mem)); +AL_FUNC(void *, _al_realloc, (void *mem, int size)); + + + +/* some Allegro functions need a block of scratch memory */ +AL_VAR(void *, _scratch_mem); +AL_VAR(int, _scratch_mem_size); + + +AL_INLINE(void, _grow_scratch_mem, (int size), +{ + if (size > _scratch_mem_size) { + size = (size+1023) & 0xFFFFFC00; + _scratch_mem = _AL_REALLOC(_scratch_mem, size); + _scratch_mem_size = size; + } +}) + + +/* list of functions to call at program cleanup */ +AL_FUNC(void, _add_exit_func, (AL_METHOD(void, func, (void)), AL_CONST char *desc)); +AL_FUNC(void, _remove_exit_func, (AL_METHOD(void, func, (void)))); + + +/* helper structure for talking to Unicode strings */ +typedef struct UTYPE_INFO +{ + int id; + AL_METHOD(int, u_getc, (AL_CONST char *s)); + AL_METHOD(int, u_getx, (char **s)); + AL_METHOD(int, u_setc, (char *s, int c)); + AL_METHOD(int, u_width, (AL_CONST char *s)); + AL_METHOD(int, u_cwidth, (int c)); + AL_METHOD(int, u_isok, (int c)); + int u_width_max; +} UTYPE_INFO; + +AL_FUNC(UTYPE_INFO *, _find_utype, (int type)); + + +/* message stuff */ +#define ALLEGRO_MESSAGE_SIZE 4096 + + +/* wrappers for implementing disk I/O on different platforms */ +AL_FUNC(int, _al_file_isok, (AL_CONST char *filename)); +AL_FUNC(uint64_t, _al_file_size_ex, (AL_CONST char *filename)); +AL_FUNC(time_t, _al_file_time, (AL_CONST char *filename)); +AL_FUNC(int, _al_drive_exists, (int drive)); +AL_FUNC(int, _al_getdrive, (void)); +AL_FUNC(void, _al_getdcwd, (int drive, char *buf, int size)); + +/* obsolete; only exists for binary compatibility with 4.2.0 */ +AL_FUNC(long, _al_file_size, (AL_CONST char *filename)); + + +/* packfile stuff */ +AL_VAR(int, _packfile_filesize); +AL_VAR(int, _packfile_datasize); +AL_VAR(int, _packfile_type); +AL_FUNC(PACKFILE *, _pack_fdopen, (int fd, AL_CONST char *mode)); + +AL_FUNC(int, _al_lzss_incomplete_state, (AL_CONST LZSS_UNPACK_DATA *dat)); + + +/* config stuff */ +void _reload_config(void); + + +/* various bits of mouse stuff */ +AL_FUNC(void, _handle_mouse_input, (void)); + +AL_VAR(int, _mouse_x); +AL_VAR(int, _mouse_y); +AL_VAR(int, _mouse_z); +AL_VAR(int, _mouse_b); +AL_VAR(int, _mouse_on); + +AL_VAR(int, _mouse_installed); + +AL_VAR(int, _mouse_type); +AL_VAR(BITMAP *, _mouse_screen); +AL_VAR(BITMAP *, _mouse_pointer); + + +/* various bits of timer stuff */ +AL_FUNC(long, _handle_timer_tick, (int interval)); + +#define MAX_TIMERS 16 + +/* list of active timer handlers */ +typedef struct TIMER_QUEUE +{ + AL_METHOD(void, proc, (void)); /* timer handler functions */ + AL_METHOD(void, param_proc, (void *param)); + void *param; /* param for param_proc if used */ + long speed; /* timer speed */ + long counter; /* counts down to zero=blastoff */ +} TIMER_QUEUE; + +AL_ARRAY(TIMER_QUEUE, _timer_queue); + +AL_VAR(int, _timer_installed); + +AL_VAR(int, _timer_use_retrace); +AL_VAR(volatile int, _retrace_hpp_value); + +AL_VAR(long, _vsync_speed); + + +/* various bits of keyboard stuff */ +AL_FUNC(void, _handle_key_press, (int keycode, int scancode)); +AL_FUNC(void, _handle_key_release, (int scancode)); + +AL_VAR(int, _keyboard_installed); +AL_ARRAY(AL_CONST char *, _keyboard_common_names); +AL_ARRAY(volatile char, _key); +AL_VAR(volatile int, _key_shifts); + + +#if (defined ALLEGRO_DOS) || (defined ALLEGRO_DJGPP) || (defined ALLEGRO_WATCOM) || \ + (defined ALLEGRO_QNX) || (defined ALLEGRO_BEOS) + +AL_ARRAY(char *, _pckeys_names); + +AL_FUNC(void, _pckeys_init, (void)); +AL_FUNC(void, _handle_pckey, (int code)); +AL_FUNC(int, _pckey_scancode_to_ascii, (int scancode)); +AL_FUNC(AL_CONST char *, _pckey_scancode_to_name, (int scancode)); + +AL_VAR(unsigned short *, _key_ascii_table); +AL_VAR(unsigned short *, _key_capslock_table); +AL_VAR(unsigned short *, _key_shift_table); +AL_VAR(unsigned short *, _key_control_table); +AL_VAR(unsigned short *, _key_altgr_lower_table); +AL_VAR(unsigned short *, _key_altgr_upper_table); +AL_VAR(unsigned short *, _key_accent1_lower_table); +AL_VAR(unsigned short *, _key_accent1_upper_table); +AL_VAR(unsigned short *, _key_accent2_lower_table); +AL_VAR(unsigned short *, _key_accent2_upper_table); +AL_VAR(unsigned short *, _key_accent3_lower_table); +AL_VAR(unsigned short *, _key_accent3_upper_table); +AL_VAR(unsigned short *, _key_accent4_lower_table); +AL_VAR(unsigned short *, _key_accent4_upper_table); + +AL_VAR(int, _key_accent1); +AL_VAR(int, _key_accent2); +AL_VAR(int, _key_accent3); +AL_VAR(int, _key_accent4); +AL_VAR(int, _key_accent1_flag); +AL_VAR(int, _key_accent2_flag); +AL_VAR(int, _key_accent3_flag); +AL_VAR(int, _key_accent4_flag); + +AL_VAR(int, _key_standard_kb); + +AL_VAR(char *, _keyboard_layout); + +#endif + +#if (defined ALLEGRO_WINDOWS) + +AL_FUNC(int, _alwin_open, (const char*, int, int)); +AL_FUNC(int, _alwin_unlink, (const char*)); + + #define IS_OLD_WINDOWS (os_type==OSTYPE_WIN3 || os_type==OSTYPE_WIN95 || \ + os_type==OSTYPE_WIN98 || os_type==OSTYPE_WINME || \ + os_type==OSTYPE_UNKNOWN) + #define _al_open _alwin_open + #define _al_unlink _alwin_unlink + +#else + + #define _al_open open + #define _al_unlink unlink + +#endif + + +/* various bits of joystick stuff */ +AL_VAR(int, _joy_type); + +AL_VAR(int, _joystick_installed); + + +/* some GUI innards that other people need to use */ +AL_FUNC(int, _gui_shadow_box_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, _gui_ctext_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, _gui_button_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, _gui_edit_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, _gui_list_proc, (int msg, DIALOG *d, int c)); +AL_FUNC(int, _gui_text_list_proc, (int msg, DIALOG *d, int c)); + +AL_FUNC(void, _handle_scrollable_scroll_click, (DIALOG *d, int listsize, int *offset, int height)); +AL_FUNC(void, _handle_scrollable_scroll, (DIALOG *d, int listsize, int *idx, int *offset)); +AL_FUNC(void, _handle_listbox_click, (DIALOG *d)); +AL_FUNC(void, _draw_scrollable_frame, (DIALOG *d, int listsize, int offset, int height, int fg_color, int bg)); +AL_FUNC(void, _draw_listbox, (DIALOG *d)); +AL_FUNC(void, _draw_textbox, (char *thetext, int *listsize, int draw, int offset, int wword, int tabsize, int x, int y, int w, int h, int disabled, int fore, int deselect, int disable)); + + +/* text- and font-related stuff */ +typedef struct FONT_VTABLE +{ + AL_METHOD(int, font_height, (AL_CONST FONT *f)); + AL_METHOD(int, char_length, (AL_CONST FONT *f, int ch)); + AL_METHOD(int, text_length, (AL_CONST FONT *f, AL_CONST char *text)); + AL_METHOD(int, render_char, (AL_CONST FONT *f, int ch, int fg, int bg, BITMAP *bmp, int x, int y)); + AL_METHOD(void, render, (AL_CONST FONT *f, AL_CONST char *text, int fg, int bg, BITMAP *bmp, int x, int y)); + AL_METHOD(void, destroy, (FONT *f)); + + AL_METHOD(int, get_font_ranges, (FONT *f)); + AL_METHOD(int, get_font_range_begin, (FONT *f, int range)); + AL_METHOD(int, get_font_range_end, (FONT *f, int range)); + AL_METHOD(FONT *, extract_font_range, (FONT *f, int begin, int end)); + AL_METHOD(FONT *, merge_fonts, (FONT *f1, FONT *f2)); + AL_METHOD(int, transpose_font, (FONT *f, int drange)); +} FONT_VTABLE; + +AL_VAR(FONT_VTABLE, _font_vtable_mono); +AL_VAR(FONT_VTABLE *, font_vtable_mono); +AL_VAR(FONT_VTABLE, _font_vtable_color); +AL_VAR(FONT_VTABLE *, font_vtable_color); +AL_VAR(FONT_VTABLE, _font_vtable_trans); +AL_VAR(FONT_VTABLE *, font_vtable_trans); + +AL_FUNC(FONT_GLYPH *, _mono_find_glyph, (AL_CONST FONT *f, int ch)); +AL_FUNC(BITMAP *, _color_find_glyph, (AL_CONST FONT *f, int ch)); + +typedef struct FONT_MONO_DATA +{ + int begin, end; /* first char and one-past-the-end char */ + FONT_GLYPH **glyphs; /* our glyphs */ + struct FONT_MONO_DATA *next; /* linked list structure */ +} FONT_MONO_DATA; + +typedef struct FONT_COLOR_DATA +{ + int begin, end; /* first char and one-past-the-end char */ + BITMAP **bitmaps; /* our glyphs */ + struct FONT_COLOR_DATA *next; /* linked list structure */ +} FONT_COLOR_DATA; + + +/* caches and tables for svga bank switching */ +AL_VAR(int, _last_bank_1); +AL_VAR(int, _last_bank_2); + +AL_VAR(int *, _gfx_bank); + +/* bank switching routines (these use a non-C calling convention on i386!) */ +AL_FUNC(uintptr_t, _stub_bank_switch, (BITMAP *bmp, int lyne)); +AL_FUNC(void, _stub_unbank_switch, (BITMAP *bmp)); +AL_FUNC(void, _stub_bank_switch_end, (void)); + +#ifdef GFX_HAS_VGA + +AL_FUNC(uintptr_t, _x_bank_switch, (BITMAP *bmp, int lyne)); +AL_FUNC(void, _x_unbank_switch, (BITMAP *bmp)); +AL_FUNC(void, _x_bank_switch_end, (void)); + +#endif + +#ifdef GFX_HAS_VBEAF + +AL_FUNC(void, _accel_bank_stub, (void)); +AL_FUNC(void, _accel_bank_stub_end, (void)); +AL_FUNC(void, _accel_bank_switch, (void)); +AL_FUNC(void, _accel_bank_switch_end, (void)); + +AL_VAR(void *, _accel_driver); + +AL_VAR(int, _accel_active); + +AL_VAR(void *, _accel_set_bank); +AL_VAR(void *, _accel_idle); + +AL_FUNC(void, _fill_vbeaf_libc_exports, (void *ptr)); +AL_FUNC(void, _fill_vbeaf_pmode_exports, (void *ptr)); + +#endif + + +/* stuff for setting up bitmaps */ +AL_FUNC(BITMAP *, _make_bitmap, (int w, int h, uintptr_t addr, GFX_DRIVER *driver, int color_depth, int bpl)); +AL_FUNC(void, _sort_out_virtual_width, (int *width, GFX_DRIVER *driver)); + +AL_FUNC(GFX_VTABLE *, _get_vtable, (int color_depth)); + +AL_VAR(GFX_VTABLE, _screen_vtable); + +AL_VAR(int, _gfx_mode_set_count); + +AL_VAR(int, _refresh_rate_request); +AL_FUNC(void, _set_current_refresh_rate, (int rate)); + +AL_VAR(int, _wait_for_vsync); + +AL_VAR(int, _sub_bitmap_id_count); + +AL_VAR(int, _screen_split_position); + +AL_VAR(int, _safe_gfx_mode_change); + +#ifdef ALLEGRO_I386 + #define BYTES_PER_PIXEL(bpp) (((int)(bpp) + 7) / 8) +#else + #ifdef ALLEGRO_MPW + /* in Mac 24 bit is a unsigned long */ + #define BYTES_PER_PIXEL(bpp) (((bpp) <= 8) ? 1 \ + : (((bpp) <= 16) ? 2 \ + : 4)) + #else + #define BYTES_PER_PIXEL(bpp) (((bpp) <= 8) ? 1 \ + : (((bpp) <= 16) ? 2 \ + : (((bpp) <= 24) ? 3 : 4))) + #endif +#endif + +AL_FUNC(int, _color_load_depth, (int depth, int hasalpha)); + +AL_VAR(int, _color_conv); + +AL_FUNC(BITMAP *, _fixup_loaded_bitmap, (BITMAP *bmp, PALETTE pal, int bpp)); + +AL_FUNC(int, _bitmap_has_alpha, (BITMAP *bmp)); + +/* default truecolor pixel format */ +#define DEFAULT_RGB_R_SHIFT_15 0 +#define DEFAULT_RGB_G_SHIFT_15 5 +#define DEFAULT_RGB_B_SHIFT_15 10 +#define DEFAULT_RGB_R_SHIFT_16 0 +#define DEFAULT_RGB_G_SHIFT_16 5 +#define DEFAULT_RGB_B_SHIFT_16 11 +#define DEFAULT_RGB_R_SHIFT_24 0 +#define DEFAULT_RGB_G_SHIFT_24 8 +#define DEFAULT_RGB_B_SHIFT_24 16 +#define DEFAULT_RGB_R_SHIFT_32 0 +#define DEFAULT_RGB_G_SHIFT_32 8 +#define DEFAULT_RGB_B_SHIFT_32 16 +#define DEFAULT_RGB_A_SHIFT_32 24 + + +/* display switching support */ +AL_FUNC(void, _switch_in, (void)); +AL_FUNC(void, _switch_out, (void)); + +AL_FUNC(void, _register_switch_bitmap, (BITMAP *bmp, BITMAP *parent)); +AL_FUNC(void, _unregister_switch_bitmap, (BITMAP *bmp)); +AL_FUNC(void, _save_switch_state, (int switch_mode)); +AL_FUNC(void, _restore_switch_state, (void)); + +AL_VAR(int, _dispsw_status); + + +/* current drawing mode */ +AL_VAR(int, _drawing_mode); +AL_VAR(BITMAP *, _drawing_pattern); +AL_VAR(int, _drawing_x_anchor); +AL_VAR(int, _drawing_y_anchor); +AL_VAR(unsigned int, _drawing_x_mask); +AL_VAR(unsigned int, _drawing_y_mask); + +AL_FUNCPTR(int *, _palette_expansion_table, (int bpp)); + +AL_VAR(int, _color_depth); + +AL_VAR(int, _current_palette_changed); +AL_VAR(PALETTE, _prev_current_palette); +AL_VAR(int, _got_prev_current_palette); + +AL_ARRAY(int, _palette_color8); +AL_ARRAY(int, _palette_color15); +AL_ARRAY(int, _palette_color16); +AL_ARRAY(int, _palette_color24); +AL_ARRAY(int, _palette_color32); + +/* truecolor blending functions */ +AL_VAR(BLENDER_FUNC, _blender_func15); +AL_VAR(BLENDER_FUNC, _blender_func16); +AL_VAR(BLENDER_FUNC, _blender_func24); +AL_VAR(BLENDER_FUNC, _blender_func32); + +AL_VAR(BLENDER_FUNC, _blender_func15x); +AL_VAR(BLENDER_FUNC, _blender_func16x); +AL_VAR(BLENDER_FUNC, _blender_func24x); + +AL_VAR(int, _blender_col_15); +AL_VAR(int, _blender_col_16); +AL_VAR(int, _blender_col_24); +AL_VAR(int, _blender_col_32); + +AL_VAR(int, _blender_alpha); + +AL_FUNC(unsigned long, _blender_black, (unsigned long x, unsigned long y, unsigned long n)); + +#ifdef ALLEGRO_COLOR16 + +AL_FUNC(unsigned long, _blender_trans15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_add15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_burn15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_color15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_difference15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_dissolve15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_dodge15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_hue15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_invert15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_luminance15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_multiply15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_saturation15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_screen15, (unsigned long x, unsigned long y, unsigned long n)); + +AL_FUNC(unsigned long, _blender_trans16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_add16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_burn16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_color16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_difference16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_dissolve16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_dodge16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_hue16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_invert16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_luminance16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_multiply16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_saturation16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_screen16, (unsigned long x, unsigned long y, unsigned long n)); + +#endif + +#if (defined ALLEGRO_COLOR24) || (defined ALLEGRO_COLOR32) + +AL_FUNC(unsigned long, _blender_trans24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_add24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_burn24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_color24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_difference24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_dissolve24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_dodge24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_hue24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_invert24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_luminance24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_multiply24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_saturation24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_screen24, (unsigned long x, unsigned long y, unsigned long n)); + +#endif + +AL_FUNC(unsigned long, _blender_alpha15, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_alpha16, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_alpha24, (unsigned long x, unsigned long y, unsigned long n)); +AL_FUNC(unsigned long, _blender_alpha32, (unsigned long x, unsigned long y, unsigned long n)); + +AL_FUNC(unsigned long, _blender_write_alpha, (unsigned long x, unsigned long y, unsigned long n)); + + +/* graphics drawing routines */ +AL_FUNC(void, _normal_line, (BITMAP *bmp, int x1, int y_1, int x2, int y2, int color)); +AL_FUNC(void, _fast_line, (BITMAP *bmp, int x1, int y_1, int x2, int y2, int color)); +AL_FUNC(void, _normal_rectfill, (BITMAP *bmp, int x1, int y_1, int x2, int y2, int color)); + +#ifdef ALLEGRO_COLOR8 + +AL_FUNC(int, _linear_getpixel8, (BITMAP *bmp, int x, int y)); +AL_FUNC(void, _linear_putpixel8, (BITMAP *bmp, int x, int y, int color)); +AL_FUNC(void, _linear_vline8, (BITMAP *bmp, int x, int y_1, int y2, int color)); +AL_FUNC(void, _linear_hline8, (BITMAP *bmp, int x1, int y, int x2, int color)); +AL_FUNC(void, _linear_draw_sprite8, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_v_flip8, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_h_flip8, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_vh_flip8, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_sprite8, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_sprite8, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_rle_sprite8, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rle_sprite8, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_rle_sprite8, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_character8, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color, int bg)); +AL_FUNC(void, _linear_draw_glyph8, (BITMAP *bmp, AL_CONST FONT_GLYPH *glyph, int x, int y, int color, int bg)); +AL_FUNC(void, _linear_blit8, (BITMAP *source,BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_blit_backward8, (BITMAP *source,BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_masked_blit8, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_clear_to_color8, (BITMAP *bitmap, int color)); + +#endif + +#ifdef ALLEGRO_COLOR16 + +AL_FUNC(void, _linear_putpixel15, (BITMAP *bmp, int x, int y, int color)); +AL_FUNC(void, _linear_vline15, (BITMAP *bmp, int x, int y_1, int y2, int color)); +AL_FUNC(void, _linear_hline15, (BITMAP *bmp, int x1, int y, int x2, int color)); +AL_FUNC(void, _linear_draw_trans_sprite15, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rgba_sprite15, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_sprite15, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_rle_sprite15, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rle_sprite15, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rgba_rle_sprite15, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_rle_sprite15, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y, int color)); + +AL_FUNC(int, _linear_getpixel16, (BITMAP *bmp, int x, int y)); +AL_FUNC(void, _linear_putpixel16, (BITMAP *bmp, int x, int y, int color)); +AL_FUNC(void, _linear_vline16, (BITMAP *bmp, int x, int y_1, int y2, int color)); +AL_FUNC(void, _linear_hline16, (BITMAP *bmp, int x1, int y, int x2, int color)); +AL_FUNC(void, _linear_draw_sprite16, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_256_sprite16, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_v_flip16, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_h_flip16, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_vh_flip16, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_sprite16, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rgba_sprite16, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_sprite16, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_rle_sprite16, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rle_sprite16, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rgba_rle_sprite16, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_rle_sprite16, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_character16, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color, int bg)); +AL_FUNC(void, _linear_draw_glyph16, (BITMAP *bmp, AL_CONST FONT_GLYPH *glyph, int x, int y, int color, int bg)); +AL_FUNC(void, _linear_blit16, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_blit_backward16, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_masked_blit16, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_clear_to_color16, (BITMAP *bitmap, int color)); + +#endif + +#ifdef ALLEGRO_COLOR24 + +AL_FUNC(int, _linear_getpixel24, (BITMAP *bmp, int x, int y)); +AL_FUNC(void, _linear_putpixel24, (BITMAP *bmp, int x, int y, int color)); +AL_FUNC(void, _linear_vline24, (BITMAP *bmp, int x, int y_1, int y2, int color)); +AL_FUNC(void, _linear_hline24, (BITMAP *bmp, int x1, int y, int x2, int color)); +AL_FUNC(void, _linear_draw_sprite24, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_256_sprite24, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_v_flip24, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_h_flip24, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_vh_flip24, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_sprite24, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rgba_sprite24, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_sprite24, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_rle_sprite24, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rle_sprite24, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rgba_rle_sprite24, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_rle_sprite24, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_character24, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color, int bg)); +AL_FUNC(void, _linear_draw_glyph24, (BITMAP *bmp, AL_CONST FONT_GLYPH *glyph, int x, int y, int color, int bg)); +AL_FUNC(void, _linear_blit24, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_blit_backward24, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_masked_blit24, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_clear_to_color24, (BITMAP *bitmap, int color)); + +#endif + +#ifdef ALLEGRO_COLOR32 + +AL_FUNC(int, _linear_getpixel32, (BITMAP *bmp, int x, int y)); +AL_FUNC(void, _linear_putpixel32, (BITMAP *bmp, int x, int y, int color)); +AL_FUNC(void, _linear_vline32, (BITMAP *bmp, int x, int y_1, int y2, int color)); +AL_FUNC(void, _linear_hline32, (BITMAP *bmp, int x1, int y, int x2, int color)); +AL_FUNC(void, _linear_draw_sprite32, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_256_sprite32, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_v_flip32, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_h_flip32, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_sprite_vh_flip32, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_sprite32, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_sprite32, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_rle_sprite32, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_trans_rle_sprite32, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _linear_draw_lit_rle_sprite32, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y, int color)); +AL_FUNC(void, _linear_draw_character32, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color, int bg)); +AL_FUNC(void, _linear_draw_glyph32, (BITMAP *bmp, AL_CONST FONT_GLYPH *glyph, int x, int y, int color, int bg)); +AL_FUNC(void, _linear_blit32, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_blit_backward32, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_masked_blit32, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _linear_clear_to_color32, (BITMAP *bitmap, int color)); + +#endif + +#ifdef GFX_HAS_VGA + +AL_FUNC(int, _x_getpixel, (BITMAP *bmp, int x, int y)); +AL_FUNC(void, _x_putpixel, (BITMAP *bmp, int x, int y, int color)); +AL_FUNC(void, _x_vline, (BITMAP *bmp, int x, int y_1, int y2, int color)); +AL_FUNC(void, _x_hline, (BITMAP *bmp, int x1, int y, int x2, int color)); +AL_FUNC(void, _x_draw_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _x_draw_sprite_v_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _x_draw_sprite_h_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _x_draw_sprite_vh_flip, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _x_draw_trans_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y)); +AL_FUNC(void, _x_draw_lit_sprite, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color)); +AL_FUNC(void, _x_draw_rle_sprite, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _x_draw_trans_rle_sprite, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y)); +AL_FUNC(void, _x_draw_lit_rle_sprite, (BITMAP *bmp, AL_CONST struct RLE_SPRITE *sprite, int x, int y, int color)); +AL_FUNC(void, _x_draw_character, (BITMAP *bmp, BITMAP *sprite, int x, int y, int color, int bg)); +AL_FUNC(void, _x_draw_glyph, (BITMAP *bmp, AL_CONST FONT_GLYPH *glyph, int x, int y, int color, int bg)); +AL_FUNC(void, _x_blit_from_memory, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _x_blit_to_memory, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _x_blit, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _x_blit_forward, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _x_blit_backward, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _x_masked_blit, (BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)); +AL_FUNC(void, _x_clear_to_color, (BITMAP *bitmap, int color)); + +#endif + + +/* color conversion routines */ +typedef struct GRAPHICS_RECT { + int width; + int height; + int pitch; + void *data; +} GRAPHICS_RECT; + +typedef void (COLORCONV_BLITTER_FUNC)(GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect); + +AL_FUNC(COLORCONV_BLITTER_FUNC *, _get_colorconv_blitter, (int from_depth, int to_depth)); +AL_FUNC(void, _release_colorconv_blitter, (COLORCONV_BLITTER_FUNC *blitter)); +AL_FUNC(void, _set_colorconv_palette, (AL_CONST struct RGB *p, int from, int to)); +AL_FUNC(unsigned char *, _get_colorconv_map, (void)); + +#ifdef ALLEGRO_COLOR8 + +AL_FUNC(void, _colorconv_blit_8_to_8, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_8_to_15, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_8_to_16, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_8_to_24, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_8_to_32, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); + +#endif + +#ifdef ALLEGRO_COLOR16 + +AL_FUNC(void, _colorconv_blit_15_to_8, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_15_to_16, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_15_to_24, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_15_to_32, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); + +AL_FUNC(void, _colorconv_blit_16_to_8, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_16_to_15, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_16_to_24, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_16_to_32, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); + +#endif + +#ifdef ALLEGRO_COLOR24 + +AL_FUNC(void, _colorconv_blit_24_to_8, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_24_to_15, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_24_to_16, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_24_to_32, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); + +#endif + +#ifdef ALLEGRO_COLOR32 + +AL_FUNC(void, _colorconv_blit_32_to_8, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_32_to_15, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_32_to_16, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorconv_blit_32_to_24, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); + +#endif + + +/* color copy routines */ +#ifndef ALLEGRO_NO_COLORCOPY + +#ifdef ALLEGRO_COLOR16 +AL_FUNC(void, _colorcopy_blit_15_to_15, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +AL_FUNC(void, _colorcopy_blit_16_to_16, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +#endif + +#ifdef ALLEGRO_COLOR24 +AL_FUNC(void, _colorcopy_blit_24_to_24, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +#endif + +#ifdef ALLEGRO_COLOR32 +AL_FUNC(void, _colorcopy_blit_32_to_32, (GRAPHICS_RECT *src_rect, GRAPHICS_RECT *dest_rect)); +#endif + +#endif + + +/* generic color conversion blitter */ +AL_FUNC(void, _blit_between_formats, (BITMAP *src, BITMAP *dest, int s_x, int s_y, int d_x, int d_y, int w, int h)); + + +/* asm helper for stretch_blit() */ +#ifndef SCAN_EXPORT +AL_FUNC(void, _do_stretch, (BITMAP *source, BITMAP *dest, void *drawer, int sx, fixed sy, fixed syd, int dx, int dy, int dh, int color_depth)); +#endif + + +/* lower level functions for rotation */ +AL_FUNC(void, _parallelogram_map, (BITMAP *bmp, BITMAP *spr, fixed xs[4], fixed ys[4], void (*draw_scanline)(BITMAP *bmp, BITMAP *spr, fixed l_bmp_x, int bmp_y, fixed r_bmp_x, fixed l_spr_x, fixed l_spr_y, fixed spr_dx, fixed spr_dy), int sub_pixel_accuracy)); +AL_FUNC(void, _parallelogram_map_standard, (BITMAP *bmp, BITMAP *sprite, fixed xs[4], fixed ys[4])); +AL_FUNC(void, _rotate_scale_flip_coordinates, (fixed w, fixed h, fixed x, fixed y, fixed cx, fixed cy, fixed angle, fixed scale_x, fixed scale_y, int h_flip, int v_flip, fixed xs[4], fixed ys[4])); +AL_FUNC(void, _pivot_scaled_sprite_flip, (struct BITMAP *bmp, struct BITMAP *sprite, fixed x, fixed y, fixed cx, fixed cy, fixed angle, fixed scale, int v_flip)); + + +/* number of fractional bits used by the polygon rasteriser */ +#define POLYGON_FIX_SHIFT 18 + + +/* bitfield specifying which polygon attributes need interpolating */ +#define INTERP_FLAT 1 /* no interpolation */ +#define INTERP_1COL 2 /* gcol or alpha */ +#define INTERP_3COL 4 /* grgb */ +#define INTERP_FIX_UV 8 /* atex */ +#define INTERP_Z 16 /* always in scene3d */ +#define INTERP_FLOAT_UV 32 /* ptex */ +#define OPT_FLOAT_UV_TO_FIX 64 /* translate ptex to atex */ +#define COLOR_TO_RGB 128 /* grgb to gcol for truecolor */ +#define INTERP_ZBUF 256 /* z-buffered */ +#define INTERP_THRU 512 /* any kind of transparent */ +#define INTERP_NOSOLID 1024 /* non-solid modes for 8-bit flat */ +#define INTERP_BLEND 2048 /* lit for truecolor */ +#define INTERP_TRANS 4096 /* trans for truecolor */ + + +/* information for polygon scanline fillers */ +typedef struct POLYGON_SEGMENT +{ + fixed u, v, du, dv; /* fixed point u/v coordinates */ + fixed c, dc; /* single color gouraud shade values */ + fixed r, g, b, dr, dg, db; /* RGB gouraud shade values */ + float z, dz; /* polygon depth (1/z) */ + float fu, fv, dfu, dfv; /* floating point u/v coordinates */ + unsigned char *texture; /* the texture map */ + int umask, vmask, vshift; /* texture map size information */ + int seg; /* destination bitmap selector */ + uintptr_t zbuf_addr; /* Z-buffer address */ + uintptr_t read_addr; /* reading address for transparency modes */ +} POLYGON_SEGMENT; + + +/* prototype for the scanline filler functions */ +typedef AL_METHOD(void, SCANLINE_FILLER, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + + +/* an active polygon edge */ +typedef struct POLYGON_EDGE +{ + int top; /* top y position */ + int bottom; /* bottom y position */ + fixed x, dx; /* fixed point x position and gradient */ + fixed w; /* width of line segment */ + POLYGON_SEGMENT dat; /* texture/gouraud information */ + struct POLYGON_EDGE *prev; /* doubly linked list */ + struct POLYGON_EDGE *next; + struct POLYGON_INFO *poly; /* father polygon */ +} POLYGON_EDGE; + + +typedef struct POLYGON_INFO /* a polygon waiting rendering */ +{ + struct POLYGON_INFO *next, *prev;/* double linked list */ + int inside; /* flag for "scanlining" */ + int flags; /* INTERP_* flags */ + int color; /* vtx[0]->c */ + float a, b, c; /* plane's coefficients -a/d, -b/d, -c/d */ + int dmode; /* drawing mode */ + BITMAP *dpat; /* drawing pattern */ + int xanchor, yanchor; /* for dpat */ + int alpha; /* blender alpha */ + int b15, b16, b24, b32; /* blender colors */ + COLOR_MAP *cmap; /* trans color map */ + SCANLINE_FILLER drawer; /* scanline drawing functions */ + SCANLINE_FILLER alt_drawer; + POLYGON_EDGE *left_edge; /* true edges used in interpolation */ + POLYGON_EDGE *right_edge; + POLYGON_SEGMENT info; /* base information for scanline functions */ +} POLYGON_INFO; + + +/* global variable for z-buffer */ +AL_VAR(BITMAP *, _zbuffer); + + +/* polygon helper functions */ +AL_VAR(SCANLINE_FILLER, _optim_alternative_drawer); +AL_FUNC(POLYGON_EDGE *, _add_edge, (POLYGON_EDGE *list, POLYGON_EDGE *edge, int sort_by_x)); +AL_FUNC(POLYGON_EDGE *, _remove_edge, (POLYGON_EDGE *list, POLYGON_EDGE *edge)); +AL_FUNC(int, _fill_3d_edge_structure, (POLYGON_EDGE *edge, AL_CONST V3D *v1, AL_CONST V3D *v2, int flags, BITMAP *bmp)); +AL_FUNC(int, _fill_3d_edge_structure_f, (POLYGON_EDGE *edge, AL_CONST V3D_f *v1, AL_CONST V3D_f *v2, int flags, BITMAP *bmp)); +AL_FUNC(SCANLINE_FILLER, _get_scanline_filler, (int type, int *flags, POLYGON_SEGMENT *info, BITMAP *texture, BITMAP *bmp)); +AL_FUNC(void, _clip_polygon_segment, (POLYGON_SEGMENT *info, fixed gap, int flags)); +AL_FUNC(void, _clip_polygon_segment_f, (POLYGON_SEGMENT *info, int gap, int flags)); + + +/* polygon scanline filler functions */ +AL_FUNC(void, _poly_scanline_dummy, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#ifdef ALLEGRO_COLOR8 + +AL_FUNC(void, _poly_scanline_gcol8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_grgb8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_trans8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_trans8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_trans8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_trans8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#ifndef SCAN_EXPORT +AL_FUNC(void, _poly_scanline_grgb8x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +#endif + +AL_FUNC(void, _poly_zbuf_flat8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_gcol8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_grgb8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_lit8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_lit8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_lit8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_lit8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_trans8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_trans8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_trans8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_trans8, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#endif + +#ifdef ALLEGRO_COLOR16 + +AL_FUNC(void, _poly_scanline_grgb15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_trans15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_trans15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_trans15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_trans15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#ifndef SCAN_EXPORT +AL_FUNC(void, _poly_scanline_grgb15x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit15x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit15x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit15x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit15x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +AL_FUNC(void, _poly_scanline_ptex_lit15d, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit15d, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +#endif + +AL_FUNC(void, _poly_zbuf_grgb15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_lit15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_lit15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_lit15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_lit15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_trans15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_trans15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_trans15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_trans15, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +AL_FUNC(void, _poly_scanline_grgb16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_trans16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_trans16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_trans16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_trans16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#ifndef SCAN_EXPORT +AL_FUNC(void, _poly_scanline_grgb16x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit16x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit16x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit16x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit16x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +AL_FUNC(void, _poly_scanline_ptex_lit16d, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit16d, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +#endif + +AL_FUNC(void, _poly_zbuf_flat16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_grgb16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_lit16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_lit16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_lit16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_lit16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_trans16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_trans16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_trans16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_trans16, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#endif + +#ifdef ALLEGRO_COLOR24 + +AL_FUNC(void, _poly_scanline_grgb24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_trans24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_trans24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_trans24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_trans24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#ifndef SCAN_EXPORT +AL_FUNC(void, _poly_scanline_grgb24x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit24x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit24x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit24x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit24x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +AL_FUNC(void, _poly_scanline_ptex_lit24d, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit24d, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +#endif + +AL_FUNC(void, _poly_zbuf_flat24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_grgb24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_lit24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_lit24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_lit24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_lit24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_trans24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_trans24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_trans24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_trans24, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#endif + +#ifdef ALLEGRO_COLOR32 + +AL_FUNC(void, _poly_scanline_grgb32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_trans32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_trans32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_trans32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_trans32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#ifndef SCAN_EXPORT +AL_FUNC(void, _poly_scanline_grgb32x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_lit32x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_lit32x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_atex_mask_lit32x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit32x, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +AL_FUNC(void, _poly_scanline_ptex_lit32d, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_scanline_ptex_mask_lit32d, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +#endif + +AL_FUNC(void, _poly_zbuf_flat32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_grgb32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_lit32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_lit32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_lit32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_lit32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_trans32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_trans32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_atex_mask_trans32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); +AL_FUNC(void, _poly_zbuf_ptex_mask_trans32, (uintptr_t addr, int w, POLYGON_SEGMENT *info)); + +#endif + + +/* sound lib stuff */ +AL_VAR(MIDI_DRIVER, _midi_none); +AL_VAR(int, _digi_volume); +AL_VAR(int, _midi_volume); +AL_VAR(int, _sound_flip_pan); +AL_VAR(int, _sound_hq); +AL_VAR(int, _sound_stereo); +AL_VAR(int, _sound_bits); +AL_VAR(int, _sound_freq); +AL_VAR(int, _sound_port); +AL_VAR(int, _sound_dma); +AL_VAR(int, _sound_irq); + +AL_VAR(int, _sound_installed); +AL_VAR(int, _sound_input_installed); + +AL_FUNC(int, _midi_allocate_voice, (int min, int max)); + +AL_VAR(volatile long, _midi_tick); + +AL_FUNC(int, _digmid_find_patches, (char *dir, int dir_size, char *file, int size_of_file)); + +#define VIRTUAL_VOICES 256 + + +typedef struct /* a virtual (as seen by the user) soundcard voice */ +{ + AL_CONST SAMPLE *sample; /* which sample are we playing? (NULL = free) */ + int num; /* physical voice number (-1 = been killed off) */ + int autokill; /* set to free the voice when the sample finishes */ + long time; /* when we were started (for voice allocation) */ + int priority; /* how important are we? */ +} VOICE; + + +typedef struct /* a physical (as used by hardware) soundcard voice */ +{ + int num; /* the virtual voice currently using me (-1 = free) */ + int playmode; /* are we looping? */ + int vol; /* current volume (fixed point .12) */ + int dvol; /* volume delta, for ramping */ + int target_vol; /* target volume, for ramping */ + int pan; /* current pan (fixed point .12) */ + int dpan; /* pan delta, for sweeps */ + int target_pan; /* target pan, for sweeps */ + int freq; /* current frequency (fixed point .12) */ + int dfreq; /* frequency delta, for sweeps */ + int target_freq; /* target frequency, for sweeps */ +} PHYS_VOICE; + +AL_ARRAY(PHYS_VOICE, _phys_voice); + + +#define MIXER_DEF_SFX 8 +#define MIXER_MAX_SFX 64 + +AL_FUNC(int, _mixer_init, (int bufsize, int freq, int stereo, int is16bit, int *voices)); +AL_FUNC(void, _mixer_exit, (void)); +AL_FUNC(void, _mix_some_samples, (uintptr_t buf, unsigned short seg, int issigned)); +AL_FUNC(void, _mixer_init_voice, (int voice, AL_CONST SAMPLE *sample)); +AL_FUNC(void, _mixer_release_voice, (int voice)); +AL_FUNC(void, _mixer_start_voice, (int voice)); +AL_FUNC(void, _mixer_stop_voice, (int voice)); +AL_FUNC(void, _mixer_loop_voice, (int voice, int loopmode)); +AL_FUNC(int, _mixer_get_position, (int voice)); +AL_FUNC(void, _mixer_set_position, (int voice, int position)); +AL_FUNC(int, _mixer_get_volume, (int voice)); +AL_FUNC(void, _mixer_set_volume, (int voice, int volume)); +AL_FUNC(void, _mixer_ramp_volume, (int voice, int tyme, int endvol)); +AL_FUNC(void, _mixer_stop_volume_ramp, (int voice)); +AL_FUNC(int, _mixer_get_frequency, (int voice)); +AL_FUNC(void, _mixer_set_frequency, (int voice, int frequency)); +AL_FUNC(void, _mixer_sweep_frequency, (int voice, int tyme, int endfreq)); +AL_FUNC(void, _mixer_stop_frequency_sweep, (int voice)); +AL_FUNC(int, _mixer_get_pan, (int voice)); +AL_FUNC(void, _mixer_set_pan, (int voice, int pan)); +AL_FUNC(void, _mixer_sweep_pan, (int voice, int tyme, int endpan)); +AL_FUNC(void, _mixer_stop_pan_sweep, (int voice)); +AL_FUNC(void, _mixer_set_echo, (int voice, int strength, int delay)); +AL_FUNC(void, _mixer_set_tremolo, (int voice, int rate, int depth)); +AL_FUNC(void, _mixer_set_vibrato, (int voice, int rate, int depth)); + +AL_FUNC(void, _dummy_noop1, (int p)); +AL_FUNC(void, _dummy_noop2, (int p1, int p2)); +AL_FUNC(void, _dummy_noop3, (int p1, int p2, int p3)); +AL_FUNC(int, _dummy_load_patches, (AL_CONST char *patches, AL_CONST char *drums)); +AL_FUNC(void, _dummy_adjust_patches, (AL_CONST char *patches, AL_CONST char *drums)); +AL_FUNC(void, _dummy_key_on, (int inst, int note, int bend, int vol, int pan)); + + +/* datafile ID's for compatibility with the old datafile format */ +#define V1_DAT_MAGIC 0x616C6C2EL + +#define V1_DAT_DATA 0 +#define V1_DAT_FONT 1 +#define V1_DAT_BITMAP_16 2 +#define V1_DAT_BITMAP_256 3 +#define V1_DAT_SPRITE_16 4 +#define V1_DAT_SPRITE_256 5 +#define V1_DAT_PALETTE_16 6 +#define V1_DAT_PALETTE_256 7 +#define V1_DAT_FONT_8x8 8 +#define V1_DAT_FONT_PROP 9 +#define V1_DAT_BITMAP 10 +#define V1_DAT_PALETTE 11 +#define V1_DAT_SAMPLE 12 +#define V1_DAT_MIDI 13 +#define V1_DAT_RLE_SPRITE 14 +#define V1_DAT_FLI 15 +#define V1_DAT_C_SPRITE 16 +#define V1_DAT_XC_SPRITE 17 + +#define OLD_FONT_SIZE 95 +#define LESS_OLD_FONT_SIZE 224 + + +/* datafile object loading functions */ +AL_FUNC(void, _unload_datafile_object, (DATAFILE *dat)); + + +/* information about a datafile object */ +typedef struct DATAFILE_TYPE +{ + int type; + AL_METHOD(void *, load, (PACKFILE *f, long size)); + AL_METHOD(void, destroy, (void *)); +} DATAFILE_TYPE; + + +#define MAX_DATAFILE_TYPES 32 + +AL_ARRAY(DATAFILE_TYPE, _datafile_type); + +AL_VAR(int, _compile_sprites); + +AL_FUNC(void, _construct_datafile, (DATAFILE *data)); + + +/* for readbmp.c */ +AL_FUNC(void, _register_bitmap_file_type_init, (void)); + +/* for readsmp.c */ +AL_FUNC(void, _register_sample_file_type_init, (void)); + +/* for readfont.c */ +AL_FUNC(void, _register_font_file_type_init, (void)); + + +/* for module linking system; see comment in allegro.c */ +struct _AL_LINKER_MIDI +{ + AL_METHOD(int, init, (void)); + AL_METHOD(void, exit, (void)); +}; + +AL_VAR(struct _AL_LINKER_MIDI *, _al_linker_midi); + +struct _AL_LINKER_MOUSE +{ + AL_METHOD(void, set_mouse_etc, (void)); + AL_METHOD(void, show_mouse, (BITMAP *)); + BITMAP **mouse_screen_ptr; +}; + +AL_VAR(struct _AL_LINKER_MOUSE *, _al_linker_mouse); + + +/* dynamic driver lists */ +AL_FUNC(_DRIVER_INFO *, _create_driver_list, (void)); +AL_FUNC(void, _destroy_driver_list, (_DRIVER_INFO *drvlist)); +AL_FUNC(void, _driver_list_append_driver, (_DRIVER_INFO **drvlist, int id, void *driver, int autodetect)); +AL_FUNC(void, _driver_list_prepend_driver, (_DRIVER_INFO **drvlist, int id, void *driver, int autodetect)); +AL_FUNC(void, _driver_list_append_list, (_DRIVER_INFO **drvlist, _DRIVER_INFO *srclist)); + + +/* various libc stuff */ +AL_FUNC(void *, _al_sane_realloc, (void *ptr, size_t size)); +AL_FUNC(char *, _al_sane_strncpy, (char *dest, const char *src, size_t n)); + + +#define _AL_RAND_MAX 0xFFFF +AL_FUNC(void, _al_srand, (int seed)); +AL_FUNC(int, _al_rand, (void)); + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef AINTERN_H */ diff --git a/lib/allegro/include/allegro/internal/aintvga.h b/lib/allegro/include/allegro/internal/aintvga.h new file mode 100644 index 0000000..4fd0e3e --- /dev/null +++ b/lib/allegro/include/allegro/internal/aintvga.h @@ -0,0 +1,139 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Helpers for accessing the VGA hardware registers. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef AINTVGA_H +#define AINTVGA_H + +#ifndef ALLEGRO_H + #error must include allegro.h first +#endif + +#ifdef GFX_HAS_VGA + +#ifdef __cplusplus + extern "C" { +#endif + + +AL_VAR(int, _crtc); + +AL_FUNC(void, _vga_regs_init, (void)); +AL_FUNC(void, _vga_vsync, (void)); +AL_FUNC(void, _vga_set_palette_range, (AL_CONST PALETTE p, int from, int to, int do_sync)); +AL_FUNC(void, _set_vga_virtual_width, (int old_width, int new_width)); +AL_FUNC(uintptr_t, _set_vga_mode, (int modenum)); +AL_FUNC(void, _unset_vga_mode, (void)); +AL_FUNC(void, _save_vga_mode, (void)); +AL_FUNC(void, _restore_vga_mode, (void)); + + +/* reads the current value of a VGA hardware register */ +AL_INLINE(int, _read_vga_register, (int port, int idx), +{ + if (port==0x3C0) + inportb(_crtc+6); + + outportb(port, idx); + return inportb(port+1); +}) + + +/* writes to a VGA hardware register */ +AL_INLINE(void, _write_vga_register, (int port, int idx, int v), +{ + if (port==0x3C0) { + inportb(_crtc+6); + outportb(port, idx); + outportb(port, v); + } + else { + outportb(port, idx); + outportb(port+1, v); + } +}) + + +/* alters specific bits of a VGA hardware register */ +AL_INLINE(void, _alter_vga_register, (int port, int idx, int mask, int v), +{ + int temp; + temp = _read_vga_register(port, idx); + temp &= (~mask); + temp |= (v & mask); + _write_vga_register(port, idx, temp); +}) + + +/* waits until the VGA isn't in a horizontal blank */ +AL_INLINE(void, _vsync_out_h, (void), +{ + do { + } while (inportb(0x3DA) & 1); +}) + + +/* waits until the VGA isn't in a vertical blank */ +AL_INLINE(void, _vsync_out_v, (void), +{ + do { + } while (inportb(0x3DA) & 8); +}) + + +/* waits until the VGA is in a vertical blank */ +AL_INLINE(void, _vsync_in, (void), +{ + if (_timer_use_retrace) { + int t = retrace_count; + + do { + } while (t == retrace_count); + } + else { + do { + } while (!(inportb(0x3DA) & 8)); + } +}) + + +/* modifies the VGA pelpan register */ +AL_INLINE(void, _write_hpp, (int value), +{ + if (_timer_use_retrace) { + _retrace_hpp_value = value; + + do { + } while (_retrace_hpp_value == value); + } + else { + do { + } while (!(inportb(0x3DA) & 8)); + + _write_vga_register(0x3C0, 0x33, value); + } +}) + + + +#ifdef __cplusplus + } +#endif + +#endif /* ifdef GFX_HAS_VGA */ + +#endif /* ifndef AINTVGA_H */ diff --git a/lib/allegro/include/allegro/internal/alconfig.h b/lib/allegro/include/allegro/internal/alconfig.h new file mode 100644 index 0000000..70ae05b --- /dev/null +++ b/lib/allegro/include/allegro/internal/alconfig.h @@ -0,0 +1,422 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +/* which color depths to include? */ +#define ALLEGRO_COLOR8 +#define ALLEGRO_COLOR16 +#define ALLEGRO_COLOR24 +#define ALLEGRO_COLOR32 + + +/* for backward compatibility */ +#ifdef USE_CONSOLE + #define ALLEGRO_NO_MAGIC_MAIN + #define ALLEGRO_USE_CONSOLE +#endif + + +/* include platform-specific stuff */ +#ifndef SCAN_EXPORT + #ifndef SCAN_DEPEND + #include "allegro/platform/alplatf.h" + #endif + + #if defined ALLEGRO_DJGPP + #include "allegro/platform/aldjgpp.h" + #elif defined ALLEGRO_WATCOM + #include "allegro/platform/alwatcom.h" + #elif defined ALLEGRO_MINGW32 + #include "allegro/platform/almngw32.h" + #elif defined ALLEGRO_BCC32 + #include "allegro/platform/albcc32.h" + #elif defined ALLEGRO_MSVC + #include "allegro/platform/almsvc.h" + #elif defined ALLEGRO_BEOS + #include "allegro/platform/albecfg.h" + #elif defined ALLEGRO_MPW + #include "allegro/platform/almaccfg.h" + #elif defined ALLEGRO_MACOSX + #include "allegro/platform/alosxcfg.h" + #elif defined ALLEGRO_QNX + #include "allegro/platform/alqnxcfg.h" + #elif defined ALLEGRO_UNIX + #include "allegro/platform/alucfg.h" + #else + #error platform not supported + #endif + + #ifndef SCAN_DEPEND + #include "allegro/platform/astdint.h" + #endif +#endif + + +/* special definitions for the GCC compiler */ +#ifdef __GNUC__ + #define ALLEGRO_GCC + + #ifndef AL_INLINE + #ifdef __cplusplus + #define AL_INLINE(type, name, args, code) \ + static inline type name args; \ + static inline type name args code + #else + #define AL_INLINE(type, name, args, code) \ + extern __inline__ type name args; \ + extern __inline__ type name args code + #endif + #endif + + #define AL_PRINTFUNC(type, name, args, a, b) AL_FUNC(type, name, args) __attribute__ ((format (printf, a, b))) + + #ifndef INLINE + #define INLINE __inline__ + #endif + + #if __GNUC__ >= 3 + /* SET: According to gcc volatile is ignored for a return type. + * I think the code should just ensure that inportb is declared as an + * __asm__ __volatile__ macro. If that's the case the extra volatile + * doesn't have any sense. + */ + #define RET_VOLATILE + #else + #define RET_VOLATILE volatile + #endif + + #ifndef ZERO_SIZE_ARRAY + #if __GNUC__ < 3 + #define ZERO_SIZE_ARRAY(type, name) __extension__ type name[0] + #else + #define ZERO_SIZE_ARRAY(type, name) type name[] /* ISO C99 flexible array members */ + #endif + #endif + + #ifndef LONG_LONG + #define LONG_LONG long long + #ifdef ALLEGRO_GUESS_INTTYPES_OK + #define int64_t signed long long + #define uint64_t unsigned long long + #endif + #endif + + #ifdef __i386__ + #define ALLEGRO_I386 + #ifndef ALLEGRO_NO_ASM + #define _AL_SINCOS(x, s, c) __asm__ ("fsincos" : "=t" (c), "=u" (s) : "0" (x)) + #endif + #endif + + #ifdef __amd64__ + #define ALLEGRO_AMD64 + #ifndef ALLEGRO_NO_ASM + #define _AL_SINCOS(x, s, c) __asm__ ("fsincos" : "=t" (c), "=u" (s) : "0" (x)) + #endif + #endif + + #ifdef __arm__ + #define ALLEGRO_ARM + #endif + + #ifndef AL_CONST + #define AL_CONST const + #endif + + #ifndef AL_FUNC_DEPRECATED + #if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) + #define AL_FUNC_DEPRECATED(type, name, args) AL_FUNC(__attribute__ ((deprecated)) type, name, args) + #define AL_PRINTFUNC_DEPRECATED(type, name, args, a, b) AL_PRINTFUNC(__attribute__ ((deprecated)) type, name, args, a, b) + #define AL_INLINE_DEPRECATED(type, name, args, code) AL_INLINE(__attribute__ ((deprecated)) type, name, args, code) + #endif + #endif + + #ifndef AL_ALIAS + #define AL_ALIAS(DECL, CALL) \ + static __attribute__((unused)) __inline__ DECL \ + { \ + return CALL; \ + } + #endif + + #ifndef AL_ALIAS_VOID_RET + #define AL_ALIAS_VOID_RET(DECL, CALL) \ + static __attribute__((unused)) __inline__ void DECL \ + { \ + CALL; \ + } + #endif +#endif + + +/* use constructor functions, if supported */ +#ifdef ALLEGRO_USE_CONSTRUCTOR + #define CONSTRUCTOR_FUNCTION(func) func __attribute__ ((constructor)) + #define DESTRUCTOR_FUNCTION(func) func __attribute__ ((destructor)) +#endif + + +/* the rest of this file fills in some default definitions of language + * features and helper functions, which are conditionalised so they will + * only be included if none of the above headers defined custom versions. + */ + +#ifndef _AL_SINCOS + #define _AL_SINCOS(x, s, c) do { (c) = cos(x); (s) = sin(x); } while (0) +#endif + +#ifndef INLINE + #define INLINE +#endif + +#ifndef RET_VOLATILE + #define RET_VOLATILE volatile +#endif + +#ifndef ZERO_SIZE_ARRAY + #define ZERO_SIZE_ARRAY(type, name) type name[] +#endif + +#ifndef AL_CONST + #define AL_CONST +#endif + +#ifndef AL_VAR + #define AL_VAR(type, name) extern type name +#endif + +#ifndef AL_ARRAY + #define AL_ARRAY(type, name) extern type name[] +#endif + +#ifndef AL_FUNC + #define AL_FUNC(type, name, args) type name args +#endif + +#ifndef AL_PRINTFUNC + #define AL_PRINTFUNC(type, name, args, a, b) AL_FUNC(type, name, args) +#endif + +#ifndef AL_METHOD + #define AL_METHOD(type, name, args) type (*name) args +#endif + +#ifndef AL_FUNCPTR + #define AL_FUNCPTR(type, name, args) extern type (*name) args +#endif + +#ifndef AL_FUNCPTRARRAY + #define AL_FUNCPTRARRAY(type, name, args) extern type (*name[]) args +#endif + +#ifndef AL_INLINE + #define AL_INLINE(type, name, args, code) type name args; +#endif + +#ifndef AL_FUNC_DEPRECATED + #define AL_FUNC_DEPRECATED(type, name, args) AL_FUNC(type, name, args) + #define AL_PRINTFUNC_DEPRECATED(type, name, args, a, b) AL_PRINTFUNC(type, name, args, a, b) + #define AL_INLINE_DEPRECATED(type, name, args, code) AL_INLINE(type, name, args, code) +#endif + +#ifndef AL_ALIAS + #define AL_ALIAS(DECL, CALL) \ + static INLINE DECL \ + { \ + return CALL; \ + } +#endif + +#ifndef AL_ALIAS_VOID_RET + #define AL_ALIAS_VOID_RET(DECL, CALL) \ + static INLINE void DECL \ + { \ + CALL; \ + } +#endif + +#ifndef END_OF_MAIN + #define END_OF_MAIN() +#endif + + +/* fill in default memory locking macros */ +#ifndef END_OF_FUNCTION + #define END_OF_FUNCTION(x) + #define END_OF_STATIC_FUNCTION(x) + #define LOCK_DATA(d, s) + #define LOCK_CODE(c, s) + #define UNLOCK_DATA(d, s) + #define LOCK_VARIABLE(x) + #define LOCK_FUNCTION(x) +#endif + + +/* fill in default filename behaviour */ +#ifndef ALLEGRO_LFN + #define ALLEGRO_LFN 1 +#endif + +#if (defined ALLEGRO_DOS) || (defined ALLEGRO_WINDOWS) + #define OTHER_PATH_SEPARATOR '\\' + #define DEVICE_SEPARATOR ':' +#else + #define OTHER_PATH_SEPARATOR '/' + #define DEVICE_SEPARATOR '\0' +#endif + + +/* emulate the FA_* flags for platforms that don't already have them */ +#ifndef FA_RDONLY + #define FA_RDONLY 1 + #define FA_HIDDEN 2 + #define FA_SYSTEM 4 + #define FA_LABEL 8 + #define FA_DIREC 16 + #define FA_ARCH 32 +#endif + #define FA_NONE 0 + #define FA_ALL (~FA_NONE) + + +#ifdef __cplusplus + extern "C" { +#endif + +/* emulate missing library functions */ +#ifdef ALLEGRO_NO_STRICMP + AL_FUNC(int, _alemu_stricmp, (AL_CONST char *s1, AL_CONST char *s2)); + #define stricmp _alemu_stricmp +#endif + +#ifdef ALLEGRO_NO_STRLWR + AL_FUNC(char *, _alemu_strlwr, (char *string)); + #define strlwr _alemu_strlwr +#endif + +#ifdef ALLEGRO_NO_STRUPR + AL_FUNC(char *, _alemu_strupr, (char *string)); + #define strupr _alemu_strupr +#endif + +#ifdef ALLEGRO_NO_MEMCMP + AL_FUNC(int, _alemu_memcmp, (AL_CONST void *s1, AL_CONST void *s2, size_t num)); + #define memcmp _alemu_memcmp +#endif + + +/* if nobody put them elsewhere, video bitmaps go in regular memory */ +#ifndef _video_ds + #define _video_ds() _default_ds() +#endif + + +/* not many places actually use these, but still worth emulating */ +#ifndef ALLEGRO_DJGPP + #define _farsetsel(seg) + #define _farnspokeb(addr, val) (*((uint8_t *)(addr)) = (val)) + #define _farnspokew(addr, val) (*((uint16_t *)(addr)) = (val)) + #define _farnspokel(addr, val) (*((uint32_t *)(addr)) = (val)) + #define _farnspeekb(addr) (*((uint8_t *)(addr))) + #define _farnspeekw(addr) (*((uint16_t *)(addr))) + #define _farnspeekl(addr) (*((uint32_t *)(addr))) +#endif + + +/* endian-independent 3-byte accessor macros */ +#ifdef ALLEGRO_LITTLE_ENDIAN + + #define READ3BYTES(p) ((*(unsigned char *)(p)) \ + | (*((unsigned char *)(p) + 1) << 8) \ + | (*((unsigned char *)(p) + 2) << 16)) + + #define WRITE3BYTES(p,c) ((*(unsigned char *)(p) = (c)), \ + (*((unsigned char *)(p) + 1) = (c) >> 8), \ + (*((unsigned char *)(p) + 2) = (c) >> 16)) + +#elif defined ALLEGRO_BIG_ENDIAN + + #define READ3BYTES(p) ((*(unsigned char *)(p) << 16) \ + | (*((unsigned char *)(p) + 1) << 8) \ + | (*((unsigned char *)(p) + 2))) + + #define WRITE3BYTES(p,c) ((*(unsigned char *)(p) = (c) >> 16), \ + (*((unsigned char *)(p) + 1) = (c) >> 8), \ + (*((unsigned char *)(p) + 2) = (c))) + +#elif defined SCAN_DEPEND + + #define READ3BYTES(p) + #define WRITE3BYTES(p,c) + +#else + #error endianess not defined +#endif + + +/* generic versions of the video memory access helpers */ +#ifndef bmp_select + #define bmp_select(bmp) +#endif + +#ifndef bmp_write8 + #define bmp_write8(addr, c) (*((uint8_t *)(addr)) = (c)) + #define bmp_write15(addr, c) (*((uint16_t *)(addr)) = (c)) + #define bmp_write16(addr, c) (*((uint16_t *)(addr)) = (c)) + #define bmp_write32(addr, c) (*((uint32_t *)(addr)) = (c)) + + #define bmp_read8(addr) (*((uint8_t *)(addr))) + #define bmp_read15(addr) (*((uint16_t *)(addr))) + #define bmp_read16(addr) (*((uint16_t *)(addr))) + #define bmp_read32(addr) (*((uint32_t *)(addr))) + + AL_INLINE(int, bmp_read24, (uintptr_t addr), + { + unsigned char *p = (unsigned char *)addr; + int c; + + c = READ3BYTES(p); + + return c; + }) + + AL_INLINE(void, bmp_write24, (uintptr_t addr, int c), + { + unsigned char *p = (unsigned char *)addr; + + WRITE3BYTES(p, c); + }) + +#endif + + +/* default random function definition */ +#ifndef AL_RAND + #define AL_RAND() (rand()) +#endif + +#ifdef __cplusplus + } +#endif + + +/* parameters for the color conversion code */ +#if (defined ALLEGRO_WINDOWS) || (defined ALLEGRO_QNX) + #define ALLEGRO_COLORCONV_ALIGNED_WIDTH + #define ALLEGRO_NO_COLORCOPY +#endif + diff --git a/lib/allegro/include/allegro/joystick.h b/lib/allegro/include/allegro/joystick.h new file mode 100644 index 0000000..76c7aca --- /dev/null +++ b/lib/allegro/include/allegro/joystick.h @@ -0,0 +1,145 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Joystick routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_JOYSTICK_H +#define ALLEGRO_JOYSTICK_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +#define JOY_TYPE_AUTODETECT -1 +#define JOY_TYPE_NONE 0 + + +#define MAX_JOYSTICKS 8 +#define MAX_JOYSTICK_AXIS 3 +#define MAX_JOYSTICK_STICKS 5 +#define MAX_JOYSTICK_BUTTONS 32 + + +/* information about a single joystick axis */ +typedef struct JOYSTICK_AXIS_INFO +{ + int pos; + int d1, d2; + AL_CONST char *name; +} JOYSTICK_AXIS_INFO; + + +/* information about one or more axis (a slider or directional control) */ +typedef struct JOYSTICK_STICK_INFO +{ + int flags; + int num_axis; + JOYSTICK_AXIS_INFO axis[MAX_JOYSTICK_AXIS]; + AL_CONST char *name; +} JOYSTICK_STICK_INFO; + + +/* information about a joystick button */ +typedef struct JOYSTICK_BUTTON_INFO +{ + int b; + AL_CONST char *name; +} JOYSTICK_BUTTON_INFO; + + +/* information about an entire joystick */ +typedef struct JOYSTICK_INFO +{ + int flags; + int num_sticks; + int num_buttons; + JOYSTICK_STICK_INFO stick[MAX_JOYSTICK_STICKS]; + JOYSTICK_BUTTON_INFO button[MAX_JOYSTICK_BUTTONS]; +} JOYSTICK_INFO; + + +/* joystick status flags */ +#define JOYFLAG_DIGITAL 1 +#define JOYFLAG_ANALOGUE 2 +#define JOYFLAG_CALIB_DIGITAL 4 +#define JOYFLAG_CALIB_ANALOGUE 8 +#define JOYFLAG_CALIBRATE 16 +#define JOYFLAG_SIGNED 32 +#define JOYFLAG_UNSIGNED 64 + + +/* alternative spellings */ +#define JOYFLAG_ANALOG JOYFLAG_ANALOGUE +#define JOYFLAG_CALIB_ANALOG JOYFLAG_CALIB_ANALOGUE + + +/* global joystick information */ +AL_ARRAY(JOYSTICK_INFO, joy); +AL_VAR(int, num_joysticks); + + +typedef struct JOYSTICK_DRIVER /* driver for reading joystick input */ +{ + int id; + AL_CONST char *name; + AL_CONST char *desc; + AL_CONST char *ascii_name; + AL_METHOD(int, init, (void)); + AL_METHOD(void, exit, (void)); + AL_METHOD(int, poll, (void)); + AL_METHOD(int, save_data, (void)); + AL_METHOD(int, load_data, (void)); + AL_METHOD(AL_CONST char *, calibrate_name, (int n)); + AL_METHOD(int, calibrate, (int n)); +} JOYSTICK_DRIVER; + + +AL_VAR(JOYSTICK_DRIVER, joystick_none); +AL_VAR(JOYSTICK_DRIVER *, joystick_driver); +AL_ARRAY(_DRIVER_INFO, _joystick_driver_list); + + +/* macros for constructing the driver list */ +#define BEGIN_JOYSTICK_DRIVER_LIST \ + _DRIVER_INFO _joystick_driver_list[] = \ + { + +#define END_JOYSTICK_DRIVER_LIST \ + { JOY_TYPE_NONE, &joystick_none, TRUE }, \ + { 0, NULL, 0 } \ + }; + + +AL_FUNC(int, install_joystick, (int type)); +AL_FUNC(void, remove_joystick, (void)); + +AL_FUNC(int, poll_joystick, (void)); + +AL_FUNC(int, save_joystick_data, (AL_CONST char *filename)); +AL_FUNC(int, load_joystick_data, (AL_CONST char *filename)); + +AL_FUNC(AL_CONST char *, calibrate_joystick_name, (int n)); +AL_FUNC(int, calibrate_joystick, (int n)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_JOYSTICK_H */ + + diff --git a/lib/allegro/include/allegro/keyboard.h b/lib/allegro/include/allegro/keyboard.h new file mode 100644 index 0000000..7a8c704 --- /dev/null +++ b/lib/allegro/include/allegro/keyboard.h @@ -0,0 +1,395 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Keyboard routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_KEYBOARD_H +#define ALLEGRO_KEYBOARD_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct KEYBOARD_DRIVER +{ + int id; + AL_CONST char *name; + AL_CONST char *desc; + AL_CONST char *ascii_name; + int autorepeat; + AL_METHOD(int, init, (void)); + AL_METHOD(void, exit, (void)); + AL_METHOD(void, poll, (void)); + AL_METHOD(void, set_leds, (int leds)); + AL_METHOD(void, set_rate, (int delay, int rate)); + AL_METHOD(void, wait_for_input, (void)); + AL_METHOD(void, stop_waiting_for_input, (void)); + AL_METHOD(int, scancode_to_ascii, (int scancode)); + AL_METHOD(AL_CONST char *, scancode_to_name, (int scancode)); +} KEYBOARD_DRIVER; + + +AL_VAR(KEYBOARD_DRIVER *, keyboard_driver); +AL_ARRAY(_DRIVER_INFO, _keyboard_driver_list); + +AL_FUNC(int, install_keyboard, (void)); +AL_FUNC(void, remove_keyboard, (void)); + +AL_FUNC(int, poll_keyboard, (void)); +AL_FUNC(int, keyboard_needs_poll, (void)); + +AL_FUNCPTR(int, keyboard_callback, (int key)); +AL_FUNCPTR(int, keyboard_ucallback, (int key, int *scancode)); +AL_FUNCPTR(void, keyboard_lowlevel_callback, (int scancode)); + +AL_FUNC(void, install_keyboard_hooks, (AL_METHOD(int, keypressed, (void)), AL_METHOD(int, readkey, (void)))); + +AL_ARRAY(volatile char, key); +AL_VAR(volatile int, key_shifts); + +AL_VAR(int, three_finger_flag); +AL_VAR(int, key_led_flag); + +AL_FUNC(int, keypressed, (void)); +AL_FUNC(int, readkey, (void)); +AL_FUNC(int, ureadkey, (int *scancode)); +AL_FUNC(void, simulate_keypress, (int keycode)); +AL_FUNC(void, simulate_ukeypress, (int keycode, int scancode)); +AL_FUNC(void, clear_keybuf, (void)); +AL_FUNC(void, set_leds, (int leds)); +AL_FUNC(void, set_keyboard_rate, (int delay, int repeat)); +AL_FUNC(int, scancode_to_ascii, (int scancode)); +AL_FUNC(AL_CONST char *, scancode_to_name, (int scancode)); + +/* The KEY_ macros are no longer #defined directly to avoid conflicting with + * linux (which has its own KEY_ constants). "__allegro_"-prefixed constants + * are used by the Allegro-Linux keyboard driver, but everyone else should + * continue to use the KEY_ constants. + */ + +enum { + __allegro_KB_SHIFT_FLAG = 0x0001, + __allegro_KB_CTRL_FLAG = 0x0002, + __allegro_KB_ALT_FLAG = 0x0004, + __allegro_KB_LWIN_FLAG = 0x0008, + __allegro_KB_RWIN_FLAG = 0x0010, + __allegro_KB_MENU_FLAG = 0x0020, + __allegro_KB_COMMAND_FLAG = 0x0040, + __allegro_KB_SCROLOCK_FLAG = 0x0100, + __allegro_KB_NUMLOCK_FLAG = 0x0200, + __allegro_KB_CAPSLOCK_FLAG = 0x0400, + __allegro_KB_INALTSEQ_FLAG = 0x0800, + __allegro_KB_ACCENT1_FLAG = 0x1000, + __allegro_KB_ACCENT2_FLAG = 0x2000, + __allegro_KB_ACCENT3_FLAG = 0x4000, + __allegro_KB_ACCENT4_FLAG = 0x8000 +}; + +enum { + __allegro_KEY_A = 1, + __allegro_KEY_B = 2, + __allegro_KEY_C = 3, + __allegro_KEY_D = 4, + __allegro_KEY_E = 5, + __allegro_KEY_F = 6, + __allegro_KEY_G = 7, + __allegro_KEY_H = 8, + __allegro_KEY_I = 9, + __allegro_KEY_J = 10, + __allegro_KEY_K = 11, + __allegro_KEY_L = 12, + __allegro_KEY_M = 13, + __allegro_KEY_N = 14, + __allegro_KEY_O = 15, + __allegro_KEY_P = 16, + __allegro_KEY_Q = 17, + __allegro_KEY_R = 18, + __allegro_KEY_S = 19, + __allegro_KEY_T = 20, + __allegro_KEY_U = 21, + __allegro_KEY_V = 22, + __allegro_KEY_W = 23, + __allegro_KEY_X = 24, + __allegro_KEY_Y = 25, + __allegro_KEY_Z = 26, + __allegro_KEY_0 = 27, + __allegro_KEY_1 = 28, + __allegro_KEY_2 = 29, + __allegro_KEY_3 = 30, + __allegro_KEY_4 = 31, + __allegro_KEY_5 = 32, + __allegro_KEY_6 = 33, + __allegro_KEY_7 = 34, + __allegro_KEY_8 = 35, + __allegro_KEY_9 = 36, + __allegro_KEY_0_PAD = 37, + __allegro_KEY_1_PAD = 38, + __allegro_KEY_2_PAD = 39, + __allegro_KEY_3_PAD = 40, + __allegro_KEY_4_PAD = 41, + __allegro_KEY_5_PAD = 42, + __allegro_KEY_6_PAD = 43, + __allegro_KEY_7_PAD = 44, + __allegro_KEY_8_PAD = 45, + __allegro_KEY_9_PAD = 46, + __allegro_KEY_F1 = 47, + __allegro_KEY_F2 = 48, + __allegro_KEY_F3 = 49, + __allegro_KEY_F4 = 50, + __allegro_KEY_F5 = 51, + __allegro_KEY_F6 = 52, + __allegro_KEY_F7 = 53, + __allegro_KEY_F8 = 54, + __allegro_KEY_F9 = 55, + __allegro_KEY_F10 = 56, + __allegro_KEY_F11 = 57, + __allegro_KEY_F12 = 58, + __allegro_KEY_ESC = 59, + __allegro_KEY_TILDE = 60, + __allegro_KEY_MINUS = 61, + __allegro_KEY_EQUALS = 62, + __allegro_KEY_BACKSPACE = 63, + __allegro_KEY_TAB = 64, + __allegro_KEY_OPENBRACE = 65, + __allegro_KEY_CLOSEBRACE = 66, + __allegro_KEY_ENTER = 67, + __allegro_KEY_COLON = 68, + __allegro_KEY_QUOTE = 69, + __allegro_KEY_BACKSLASH = 70, + __allegro_KEY_BACKSLASH2 = 71, + __allegro_KEY_COMMA = 72, + __allegro_KEY_STOP = 73, + __allegro_KEY_SLASH = 74, + __allegro_KEY_SPACE = 75, + __allegro_KEY_INSERT = 76, + __allegro_KEY_DEL = 77, + __allegro_KEY_HOME = 78, + __allegro_KEY_END = 79, + __allegro_KEY_PGUP = 80, + __allegro_KEY_PGDN = 81, + __allegro_KEY_LEFT = 82, + __allegro_KEY_RIGHT = 83, + __allegro_KEY_UP = 84, + __allegro_KEY_DOWN = 85, + __allegro_KEY_SLASH_PAD = 86, + __allegro_KEY_ASTERISK = 87, + __allegro_KEY_MINUS_PAD = 88, + __allegro_KEY_PLUS_PAD = 89, + __allegro_KEY_DEL_PAD = 90, + __allegro_KEY_ENTER_PAD = 91, + __allegro_KEY_PRTSCR = 92, + __allegro_KEY_PAUSE = 93, + __allegro_KEY_ABNT_C1 = 94, + __allegro_KEY_YEN = 95, + __allegro_KEY_KANA = 96, + __allegro_KEY_CONVERT = 97, + __allegro_KEY_NOCONVERT = 98, + __allegro_KEY_AT = 99, + __allegro_KEY_CIRCUMFLEX = 100, + __allegro_KEY_COLON2 = 101, + __allegro_KEY_KANJI = 102, + __allegro_KEY_EQUALS_PAD = 103, /* MacOS X */ + __allegro_KEY_BACKQUOTE = 104, /* MacOS X */ + __allegro_KEY_SEMICOLON = 105, /* MacOS X */ + __allegro_KEY_COMMAND = 106, /* MacOS X */ + __allegro_KEY_UNKNOWN1 = 107, + __allegro_KEY_UNKNOWN2 = 108, + __allegro_KEY_UNKNOWN3 = 109, + __allegro_KEY_UNKNOWN4 = 110, + __allegro_KEY_UNKNOWN5 = 111, + __allegro_KEY_UNKNOWN6 = 112, + __allegro_KEY_UNKNOWN7 = 113, + __allegro_KEY_UNKNOWN8 = 114, + + __allegro_KEY_MODIFIERS = 115, + + __allegro_KEY_LSHIFT = 115, + __allegro_KEY_RSHIFT = 116, + __allegro_KEY_LCONTROL = 117, + __allegro_KEY_RCONTROL = 118, + __allegro_KEY_ALT = 119, + __allegro_KEY_ALTGR = 120, + __allegro_KEY_LWIN = 121, + __allegro_KEY_RWIN = 122, + __allegro_KEY_MENU = 123, + __allegro_KEY_SCRLOCK = 124, + __allegro_KEY_NUMLOCK = 125, + __allegro_KEY_CAPSLOCK = 126, + + __allegro_KEY_MAX = 127 +}; + +#ifndef ALLEGRO_NO_KEY_DEFINES + +#define KB_SHIFT_FLAG __allegro_KB_SHIFT_FLAG +#define KB_CTRL_FLAG __allegro_KB_CTRL_FLAG +#define KB_ALT_FLAG __allegro_KB_ALT_FLAG +#define KB_LWIN_FLAG __allegro_KB_LWIN_FLAG +#define KB_RWIN_FLAG __allegro_KB_RWIN_FLAG +#define KB_MENU_FLAG __allegro_KB_MENU_FLAG +#define KB_COMMAND_FLAG __allegro_KB_COMMAND_FLAG +#define KB_SCROLOCK_FLAG __allegro_KB_SCROLOCK_FLAG +#define KB_NUMLOCK_FLAG __allegro_KB_NUMLOCK_FLAG +#define KB_CAPSLOCK_FLAG __allegro_KB_CAPSLOCK_FLAG +#define KB_INALTSEQ_FLAG __allegro_KB_INALTSEQ_FLAG +#define KB_ACCENT1_FLAG __allegro_KB_ACCENT1_FLAG +#define KB_ACCENT2_FLAG __allegro_KB_ACCENT2_FLAG +#define KB_ACCENT3_FLAG __allegro_KB_ACCENT3_FLAG +#define KB_ACCENT4_FLAG __allegro_KB_ACCENT4_FLAG + +#define KEY_A __allegro_KEY_A +#define KEY_B __allegro_KEY_B +#define KEY_C __allegro_KEY_C +#define KEY_D __allegro_KEY_D +#define KEY_E __allegro_KEY_E +#define KEY_F __allegro_KEY_F +#define KEY_G __allegro_KEY_G +#define KEY_H __allegro_KEY_H +#define KEY_I __allegro_KEY_I +#define KEY_J __allegro_KEY_J +#define KEY_K __allegro_KEY_K +#define KEY_L __allegro_KEY_L +#define KEY_M __allegro_KEY_M +#define KEY_N __allegro_KEY_N +#define KEY_O __allegro_KEY_O +#define KEY_P __allegro_KEY_P +#define KEY_Q __allegro_KEY_Q +#define KEY_R __allegro_KEY_R +#define KEY_S __allegro_KEY_S +#define KEY_T __allegro_KEY_T +#define KEY_U __allegro_KEY_U +#define KEY_V __allegro_KEY_V +#define KEY_W __allegro_KEY_W +#define KEY_X __allegro_KEY_X +#define KEY_Y __allegro_KEY_Y +#define KEY_Z __allegro_KEY_Z +#define KEY_0 __allegro_KEY_0 +#define KEY_1 __allegro_KEY_1 +#define KEY_2 __allegro_KEY_2 +#define KEY_3 __allegro_KEY_3 +#define KEY_4 __allegro_KEY_4 +#define KEY_5 __allegro_KEY_5 +#define KEY_6 __allegro_KEY_6 +#define KEY_7 __allegro_KEY_7 +#define KEY_8 __allegro_KEY_8 +#define KEY_9 __allegro_KEY_9 +#define KEY_0_PAD __allegro_KEY_0_PAD +#define KEY_1_PAD __allegro_KEY_1_PAD +#define KEY_2_PAD __allegro_KEY_2_PAD +#define KEY_3_PAD __allegro_KEY_3_PAD +#define KEY_4_PAD __allegro_KEY_4_PAD +#define KEY_5_PAD __allegro_KEY_5_PAD +#define KEY_6_PAD __allegro_KEY_6_PAD +#define KEY_7_PAD __allegro_KEY_7_PAD +#define KEY_8_PAD __allegro_KEY_8_PAD +#define KEY_9_PAD __allegro_KEY_9_PAD +#define KEY_F1 __allegro_KEY_F1 +#define KEY_F2 __allegro_KEY_F2 +#define KEY_F3 __allegro_KEY_F3 +#define KEY_F4 __allegro_KEY_F4 +#define KEY_F5 __allegro_KEY_F5 +#define KEY_F6 __allegro_KEY_F6 +#define KEY_F7 __allegro_KEY_F7 +#define KEY_F8 __allegro_KEY_F8 +#define KEY_F9 __allegro_KEY_F9 +#define KEY_F10 __allegro_KEY_F10 +#define KEY_F11 __allegro_KEY_F11 +#define KEY_F12 __allegro_KEY_F12 +#define KEY_ESC __allegro_KEY_ESC +#define KEY_TILDE __allegro_KEY_TILDE +#define KEY_MINUS __allegro_KEY_MINUS +#define KEY_EQUALS __allegro_KEY_EQUALS +#define KEY_BACKSPACE __allegro_KEY_BACKSPACE +#define KEY_TAB __allegro_KEY_TAB +#define KEY_OPENBRACE __allegro_KEY_OPENBRACE +#define KEY_CLOSEBRACE __allegro_KEY_CLOSEBRACE +#define KEY_ENTER __allegro_KEY_ENTER +#define KEY_COLON __allegro_KEY_COLON +#define KEY_QUOTE __allegro_KEY_QUOTE +#define KEY_BACKSLASH __allegro_KEY_BACKSLASH +#define KEY_BACKSLASH2 __allegro_KEY_BACKSLASH2 +#define KEY_COMMA __allegro_KEY_COMMA +#define KEY_STOP __allegro_KEY_STOP +#define KEY_SLASH __allegro_KEY_SLASH +#define KEY_SPACE __allegro_KEY_SPACE +#define KEY_INSERT __allegro_KEY_INSERT +#define KEY_DEL __allegro_KEY_DEL +#define KEY_HOME __allegro_KEY_HOME +#define KEY_END __allegro_KEY_END +#define KEY_PGUP __allegro_KEY_PGUP +#define KEY_PGDN __allegro_KEY_PGDN +#define KEY_LEFT __allegro_KEY_LEFT +#define KEY_RIGHT __allegro_KEY_RIGHT +#define KEY_UP __allegro_KEY_UP +#define KEY_DOWN __allegro_KEY_DOWN +#define KEY_SLASH_PAD __allegro_KEY_SLASH_PAD +#define KEY_ASTERISK __allegro_KEY_ASTERISK +#define KEY_MINUS_PAD __allegro_KEY_MINUS_PAD +#define KEY_PLUS_PAD __allegro_KEY_PLUS_PAD +#define KEY_DEL_PAD __allegro_KEY_DEL_PAD +#define KEY_ENTER_PAD __allegro_KEY_ENTER_PAD +#define KEY_PRTSCR __allegro_KEY_PRTSCR +#define KEY_PAUSE __allegro_KEY_PAUSE +#define KEY_ABNT_C1 __allegro_KEY_ABNT_C1 +#define KEY_YEN __allegro_KEY_YEN +#define KEY_KANA __allegro_KEY_KANA +#define KEY_CONVERT __allegro_KEY_CONVERT +#define KEY_NOCONVERT __allegro_KEY_NOCONVERT +#define KEY_AT __allegro_KEY_AT +#define KEY_CIRCUMFLEX __allegro_KEY_CIRCUMFLEX +#define KEY_COLON2 __allegro_KEY_COLON2 +#define KEY_KANJI __allegro_KEY_KANJI +#define KEY_EQUALS_PAD __allegro_KEY_EQUALS_PAD +#define KEY_BACKQUOTE __allegro_KEY_BACKQUOTE +#define KEY_SEMICOLON __allegro_KEY_SEMICOLON +#define KEY_COMMAND __allegro_KEY_COMMAND +#define KEY_UNKNOWN1 __allegro_KEY_UNKNOWN1 +#define KEY_UNKNOWN2 __allegro_KEY_UNKNOWN2 +#define KEY_UNKNOWN3 __allegro_KEY_UNKNOWN3 +#define KEY_UNKNOWN4 __allegro_KEY_UNKNOWN4 +#define KEY_UNKNOWN5 __allegro_KEY_UNKNOWN5 +#define KEY_UNKNOWN6 __allegro_KEY_UNKNOWN6 +#define KEY_UNKNOWN7 __allegro_KEY_UNKNOWN7 +#define KEY_UNKNOWN8 __allegro_KEY_UNKNOWN8 + +#define KEY_MODIFIERS __allegro_KEY_MODIFIERS + +#define KEY_LSHIFT __allegro_KEY_LSHIFT +#define KEY_RSHIFT __allegro_KEY_RSHIFT +#define KEY_LCONTROL __allegro_KEY_LCONTROL +#define KEY_RCONTROL __allegro_KEY_RCONTROL +#define KEY_ALT __allegro_KEY_ALT +#define KEY_ALTGR __allegro_KEY_ALTGR +#define KEY_LWIN __allegro_KEY_LWIN +#define KEY_RWIN __allegro_KEY_RWIN +#define KEY_MENU __allegro_KEY_MENU +#define KEY_SCRLOCK __allegro_KEY_SCRLOCK +#define KEY_NUMLOCK __allegro_KEY_NUMLOCK +#define KEY_CAPSLOCK __allegro_KEY_CAPSLOCK + +#define KEY_MAX __allegro_KEY_MAX + +#endif /* ALLEGRO_NO_KEY_DEFINES */ + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_KEYBOARD_H */ + + diff --git a/lib/allegro/include/allegro/lzss.h b/lib/allegro/include/allegro/lzss.h new file mode 100644 index 0000000..f6bc91d --- /dev/null +++ b/lib/allegro/include/allegro/lzss.h @@ -0,0 +1,47 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Compression routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_LZSS_H +#define ALLEGRO_LZSS_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct LZSS_PACK_DATA LZSS_PACK_DATA; +typedef struct LZSS_UNPACK_DATA LZSS_UNPACK_DATA; + + +AL_FUNC(LZSS_PACK_DATA *, create_lzss_pack_data, (void)); +AL_FUNC(void, free_lzss_pack_data, (LZSS_PACK_DATA *dat)); +AL_FUNC(int, lzss_write, (PACKFILE *file, LZSS_PACK_DATA *dat, int size, unsigned char *buf, int last)); + +AL_FUNC(LZSS_UNPACK_DATA *, create_lzss_unpack_data, (void)); +AL_FUNC(void, free_lzss_unpack_data, (LZSS_UNPACK_DATA *dat)); +AL_FUNC(int, lzss_read, (PACKFILE *file, LZSS_UNPACK_DATA *dat, int s, unsigned char *buf)); + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_LZSS_H */ + + diff --git a/lib/allegro/include/allegro/matrix.h b/lib/allegro/include/allegro/matrix.h new file mode 100644 index 0000000..3b24b64 --- /dev/null +++ b/lib/allegro/include/allegro/matrix.h @@ -0,0 +1,96 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Matrix math routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_MATRIX_H +#define ALLEGRO_MATRIX_H + +#include "base.h" +#include "fixed.h" +#include "fmaths.h" + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct MATRIX /* transformation matrix (fixed point) */ +{ + fixed v[3][3]; /* scaling and rotation */ + fixed t[3]; /* translation */ +} MATRIX; + + +typedef struct MATRIX_f /* transformation matrix (floating point) */ +{ + float v[3][3]; /* scaling and rotation */ + float t[3]; /* translation */ +} MATRIX_f; + + +AL_VAR(MATRIX, identity_matrix); +AL_VAR(MATRIX_f, identity_matrix_f); + +AL_FUNC(void, get_translation_matrix, (MATRIX *m, fixed x, fixed y, fixed z)); +AL_FUNC(void, get_translation_matrix_f, (MATRIX_f *m, float x, float y, float z)); + +AL_FUNC(void, get_scaling_matrix, (MATRIX *m, fixed x, fixed y, fixed z)); +AL_FUNC(void, get_scaling_matrix_f, (MATRIX_f *m, float x, float y, float z)); + +AL_FUNC(void, get_x_rotate_matrix, (MATRIX *m, fixed r)); +AL_FUNC(void, get_x_rotate_matrix_f, (MATRIX_f *m, float r)); + +AL_FUNC(void, get_y_rotate_matrix, (MATRIX *m, fixed r)); +AL_FUNC(void, get_y_rotate_matrix_f, (MATRIX_f *m, float r)); + +AL_FUNC(void, get_z_rotate_matrix, (MATRIX *m, fixed r)); +AL_FUNC(void, get_z_rotate_matrix_f, (MATRIX_f *m, float r)); + +AL_FUNC(void, get_rotation_matrix, (MATRIX *m, fixed x, fixed y, fixed z)); +AL_FUNC(void, get_rotation_matrix_f, (MATRIX_f *m, float x, float y, float z)); + +AL_FUNC(void, get_align_matrix, (MATRIX *m, fixed xfront, fixed yfront, fixed zfront, fixed xup, fixed yup, fixed zup)); +AL_FUNC(void, get_align_matrix_f, (MATRIX_f *m, float xfront, float yfront, float zfront, float xup, float yup, float zup)); + +AL_FUNC(void, get_vector_rotation_matrix, (MATRIX *m, fixed x, fixed y, fixed z, fixed a)); +AL_FUNC(void, get_vector_rotation_matrix_f, (MATRIX_f *m, float x, float y, float z, float a)); + +AL_FUNC(void, get_transformation_matrix, (MATRIX *m, fixed scale, fixed xrot, fixed yrot, fixed zrot, fixed x, fixed y, fixed z)); +AL_FUNC(void, get_transformation_matrix_f, (MATRIX_f *m, float scale, float xrot, float yrot, float zrot, float x, float y, float z)); + +AL_FUNC(void, get_camera_matrix, (MATRIX *m, fixed x, fixed y, fixed z, fixed xfront, fixed yfront, fixed zfront, fixed xup, fixed yup, fixed zup, fixed fov, fixed aspect)); +AL_FUNC(void, get_camera_matrix_f, (MATRIX_f *m, float x, float y, float z, float xfront, float yfront, float zfront, float xup, float yup, float zup, float fov, float aspect)); + +AL_FUNC(void, qtranslate_matrix, (MATRIX *m, fixed x, fixed y, fixed z)); +AL_FUNC(void, qtranslate_matrix_f, (MATRIX_f *m, float x, float y, float z)); + +AL_FUNC(void, qscale_matrix, (MATRIX *m, fixed scale)); +AL_FUNC(void, qscale_matrix_f, (MATRIX_f *m, float scale)); + +AL_FUNC(void, matrix_mul, (AL_CONST MATRIX *m1, AL_CONST MATRIX *m2, MATRIX *out)); +AL_FUNC(void, matrix_mul_f, (AL_CONST MATRIX_f *m1, AL_CONST MATRIX_f *m2, MATRIX_f *out)); + +AL_FUNC(void, apply_matrix_f, (AL_CONST MATRIX_f *m, float x, float y, float z, float *xout, float *yout, float *zout)); + +#ifdef __cplusplus + } +#endif + +#include "inline/matrix.inl" + +#endif /* ifndef ALLEGRO_MATRIX_H */ + + diff --git a/lib/allegro/include/allegro/midi.h b/lib/allegro/include/allegro/midi.h new file mode 100644 index 0000000..26c7a81 --- /dev/null +++ b/lib/allegro/include/allegro/midi.h @@ -0,0 +1,144 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * MIDI music routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_MIDI_H +#define ALLEGRO_MIDI_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + /* Theoretical maximums: */ +#define MIDI_VOICES 64 /* actual drivers may not be */ +#define MIDI_TRACKS 32 /* able to handle this many */ + + + +typedef struct MIDI /* a midi file */ +{ + int divisions; /* number of ticks per quarter note */ + struct { + unsigned char *data; /* MIDI message stream */ + int len; /* length of the track data */ + } track[MIDI_TRACKS]; +} MIDI; + + + +#define MIDI_AUTODETECT -1 +#define MIDI_NONE 0 +#define MIDI_DIGMID AL_ID('D','I','G','I') + +typedef struct MIDI_DRIVER /* driver for playing midi music */ +{ + int id; /* driver ID code */ + AL_CONST char *name; /* driver name */ + AL_CONST char *desc; /* description string */ + AL_CONST char *ascii_name; /* ASCII format name string */ + int voices; /* available voices */ + int basevoice; /* voice number offset */ + int max_voices; /* maximum voices we can support */ + int def_voices; /* default number of voices to use */ + int xmin, xmax; /* reserved voice range */ + + /* setup routines */ + AL_METHOD(int, detect, (int input)); + AL_METHOD(int, init, (int input, int voices)); + AL_METHOD(void, exit, (int input)); + AL_METHOD(int, set_mixer_volume, (int volume)); + AL_METHOD(int, get_mixer_volume, (void)); + + /* raw MIDI output to MPU-401, etc. */ + AL_METHOD(void, raw_midi, (int data)); + + /* dynamic patch loading routines */ + AL_METHOD(int, load_patches, (AL_CONST char *patches, AL_CONST char *drums)); + AL_METHOD(void, adjust_patches, (AL_CONST char *patches, AL_CONST char *drums)); + + /* note control functions */ + AL_METHOD(void, key_on, (int inst, int note, int bend, int vol, int pan)); + AL_METHOD(void, key_off, (int voice)); + AL_METHOD(void, set_volume, (int voice, int vol)); + AL_METHOD(void, set_pitch, (int voice, int note, int bend)); + AL_METHOD(void, set_pan, (int voice, int pan)); + AL_METHOD(void, set_vibrato, (int voice, int amount)); +} MIDI_DRIVER; + + +AL_VAR(MIDI_DRIVER, midi_digmid); + +AL_ARRAY(_DRIVER_INFO, _midi_driver_list); + + +/* macros for constructing the driver lists */ +#define BEGIN_MIDI_DRIVER_LIST \ + _DRIVER_INFO _midi_driver_list[] = \ + { + +#define END_MIDI_DRIVER_LIST \ + { 0, NULL, 0 } \ + }; + +#define MIDI_DRIVER_DIGMID \ + { MIDI_DIGMID, &midi_digmid, TRUE }, + + +AL_VAR(MIDI_DRIVER *, midi_driver); + +AL_VAR(MIDI_DRIVER *, midi_input_driver); + +AL_VAR(int, midi_card); + +AL_VAR(int, midi_input_card); + +AL_VAR(volatile long, midi_pos); /* current position in the midi file, in beats */ +AL_VAR(volatile long, midi_time); /* current position in the midi file, in seconds */ + +AL_VAR(long, midi_loop_start); /* where to loop back to at EOF */ +AL_VAR(long, midi_loop_end); /* loop when we hit this position */ + +AL_FUNC(int, detect_midi_driver, (int driver_id)); + +AL_FUNC(MIDI *, load_midi, (AL_CONST char *filename)); +AL_FUNC(void, destroy_midi, (MIDI *midi)); +AL_FUNC(int, play_midi, (MIDI *midi, int loop)); +AL_FUNC(int, play_looped_midi, (MIDI *midi, int loop_start, int loop_end)); +AL_FUNC(void, stop_midi, (void)); +AL_FUNC(void, midi_pause, (void)); +AL_FUNC(void, midi_resume, (void)); +AL_FUNC(int, midi_seek, (int target)); +AL_FUNC(int, get_midi_length, (MIDI *midi)); +AL_FUNC(void, midi_out, (unsigned char *data, int length)); +AL_FUNC(int, load_midi_patches, (void)); + +AL_FUNCPTR(void, midi_msg_callback, (int msg, int byte1, int byte2)); +AL_FUNCPTR(void, midi_meta_callback, (int type, AL_CONST unsigned char *data, int length)); +AL_FUNCPTR(void, midi_sysex_callback, (AL_CONST unsigned char *data, int length)); + +AL_FUNCPTR(void, midi_recorder, (unsigned char data)); + +AL_FUNC(void, lock_midi, (struct MIDI *midi)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_MIDI_H */ + + diff --git a/lib/allegro/include/allegro/mouse.h b/lib/allegro/include/allegro/mouse.h new file mode 100644 index 0000000..0b39637 --- /dev/null +++ b/lib/allegro/include/allegro/mouse.h @@ -0,0 +1,117 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Mouse routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_MOUSE_H +#define ALLEGRO_MOUSE_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +#define MOUSEDRV_AUTODETECT -1 +#define MOUSEDRV_NONE 0 + + +typedef struct MOUSE_DRIVER +{ + int id; + AL_CONST char *name; + AL_CONST char *desc; + AL_CONST char *ascii_name; + AL_METHOD(int, init, (void)); + AL_METHOD(void, exit, (void)); + AL_METHOD(void, poll, (void)); + AL_METHOD(void, timer_poll, (void)); + AL_METHOD(void, position, (int x, int y)); + AL_METHOD(void, set_range, (int x1, int y_1, int x2, int y2)); + AL_METHOD(void, set_speed, (int xspeed, int yspeed)); + AL_METHOD(void, get_mickeys, (int *mickeyx, int *mickeyy)); + AL_METHOD(int, analyse_data, (AL_CONST char *buffer, int size)); + AL_METHOD(void, enable_hardware_cursor, (int mode)); + AL_METHOD(int, select_system_cursor, (int cursor)); +} MOUSE_DRIVER; + + +AL_VAR(MOUSE_DRIVER, mousedrv_none); +AL_VAR(MOUSE_DRIVER *, mouse_driver); +AL_ARRAY(_DRIVER_INFO, _mouse_driver_list); + +AL_FUNC(int, install_mouse, (void)); +AL_FUNC(void, remove_mouse, (void)); + +AL_FUNC(int, poll_mouse, (void)); +AL_FUNC(int, mouse_needs_poll, (void)); + +AL_FUNC(void, enable_hardware_cursor, (void)); +AL_FUNC(void, disable_hardware_cursor, (void)); + +/* Mouse cursors */ +#define MOUSE_CURSOR_NONE 0 +#define MOUSE_CURSOR_ALLEGRO 1 +#define MOUSE_CURSOR_ARROW 2 +#define MOUSE_CURSOR_BUSY 3 +#define MOUSE_CURSOR_QUESTION 4 +#define MOUSE_CURSOR_EDIT 5 +#define NUM_MOUSE_CURSORS 6 + +AL_VAR(struct BITMAP *, mouse_sprite); +AL_VAR(int, mouse_x_focus); +AL_VAR(int, mouse_y_focus); + +AL_VAR(volatile int, mouse_x); +AL_VAR(volatile int, mouse_y); +AL_VAR(volatile int, mouse_z); +AL_VAR(volatile int, mouse_b); +AL_VAR(volatile int, mouse_pos); + +AL_VAR(volatile int, freeze_mouse_flag); + +#define MOUSE_FLAG_MOVE 1 +#define MOUSE_FLAG_LEFT_DOWN 2 +#define MOUSE_FLAG_LEFT_UP 4 +#define MOUSE_FLAG_RIGHT_DOWN 8 +#define MOUSE_FLAG_RIGHT_UP 16 +#define MOUSE_FLAG_MIDDLE_DOWN 32 +#define MOUSE_FLAG_MIDDLE_UP 64 +#define MOUSE_FLAG_MOVE_Z 128 + +AL_FUNCPTR(void, mouse_callback, (int flags)); + +AL_FUNC(void, show_mouse, (struct BITMAP *bmp)); +AL_FUNC(void, scare_mouse, (void)); +AL_FUNC(void, scare_mouse_area, (int x, int y, int w, int h)); +AL_FUNC(void, unscare_mouse, (void)); +AL_FUNC(void, position_mouse, (int x, int y)); +AL_FUNC(void, position_mouse_z, (int z)); +AL_FUNC(void, set_mouse_range, (int x1, int y_1, int x2, int y2)); +AL_FUNC(void, set_mouse_speed, (int xspeed, int yspeed)); +AL_FUNC(void, select_mouse_cursor, (int cursor)); +AL_FUNC(void, set_mouse_cursor_bitmap, (int cursor, struct BITMAP *bmp)); +AL_FUNC(void, set_mouse_sprite_focus, (int x, int y)); +AL_FUNC(void, get_mouse_mickeys, (int *mickeyx, int *mickeyy)); +AL_FUNC(void, set_mouse_sprite, (struct BITMAP *sprite)); +AL_FUNC(int, show_os_cursor, (int cursor)); +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_MOUSE_H */ + + diff --git a/lib/allegro/include/allegro/palette.h b/lib/allegro/include/allegro/palette.h new file mode 100644 index 0000000..7843421 --- /dev/null +++ b/lib/allegro/include/allegro/palette.h @@ -0,0 +1,42 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Palette type. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_PALETTE_H +#define ALLEGRO_PALETTE_H + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct RGB +{ + unsigned char r, g, b; + unsigned char filler; +} RGB; + +#define PAL_SIZE 256 + +typedef RGB PALETTE[PAL_SIZE]; + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_PALETTE_H */ + + diff --git a/lib/allegro/include/allegro/platform/aintbeos.h b/lib/allegro/include/allegro/platform/aintbeos.h new file mode 100644 index 0000000..72e3385 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aintbeos.h @@ -0,0 +1,151 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Definitions for internal use by the BeOS configuration. + * + * By Jason Wilkins. + * + * See readme.txt for copyright information. + */ + + +#include "bealleg.h" + +#ifdef __cplusplus +extern status_t ignore_result; + +extern volatile int32 focus_count; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define WND_TITLE_SIZE 128 + +AL_ARRAY(char, wnd_title); + +int be_key_init(void); +void be_key_exit(void); +void be_key_set_leds(int leds); +void be_key_set_rate(int delay, int repeat); +void be_key_wait_for_input(void); +void be_key_stop_waiting_for_input(void); +void be_key_suspend(void); +void be_key_resume(void); + +int be_sys_init(void); +void be_sys_exit(void); +void _be_sys_get_executable_name(char *output, int size); +void be_sys_get_executable_name(char *output, int size); +int be_sys_find_resource(char *dest, AL_CONST char *resource, int size); +void be_sys_set_window_title(AL_CONST char *name); +int be_sys_set_close_button_callback(void (*proc)(void)); +void be_sys_message(AL_CONST char *msg); +int be_sys_set_display_switch_mode(int mode); +int be_sys_desktop_color_depth(void); +int be_sys_get_desktop_resolution(int *width, int *height); +void be_sys_get_gfx_safe_mode(int *driver, struct GFX_MODE *mode); +void be_sys_yield_timeslice(void); +void *be_sys_create_mutex(void); +void be_sys_destroy_mutex(void *handle); +void be_sys_lock_mutex(void *handle); +void be_sys_unlock_mutex(void *handle); +void be_sys_suspend(void); +void be_sys_resume(void); +void be_main_suspend(void); +void be_main_resume(void); + +struct BITMAP *be_gfx_bwindowscreen_accel_init(int w, int h, int v_w, int v_h, int color_depth); +struct BITMAP *be_gfx_bwindowscreen_init(int w, int h, int v_w, int v_h, int color_depth); +void be_gfx_bwindowscreen_exit(struct BITMAP *b); +void be_gfx_bwindowscreen_acquire(struct BITMAP *b); +void be_gfx_bwindowscreen_release(struct BITMAP *b); +void be_gfx_bwindowscreen_set_palette(AL_CONST struct RGB *p, int from, int to, int vsync); +int be_gfx_bwindowscreen_scroll(int x, int y); +int be_gfx_bwindowscreen_request_scroll(int x, int y); +int be_gfx_bwindowscreen_poll_scroll(void); +int be_gfx_bwindowscreen_request_video_bitmap(struct BITMAP *bitmap); +void be_gfx_vsync(void); +struct GFX_MODE_LIST *be_gfx_bwindowscreen_fetch_mode_list(void); +void be_gfx_bwindowscreen_accelerate(int color_depth); +#ifdef ALLEGRO_NO_ASM +uintptr_t be_gfx_bwindowscreen_read_write_bank(BITMAP *bmp, int lyne); +void be_gfx_bwindowscreen_unwrite_bank(BITMAP *bmp); +#else +uintptr_t _be_gfx_bwindowscreen_read_write_bank_asm(BITMAP *bmp, int lyne); +void _be_gfx_bwindowscreen_unwrite_bank_asm(BITMAP *bmp); +#endif + +struct BITMAP *be_gfx_bdirectwindow_init(int w, int h, int v_w, int v_h, int color_depth); +void be_gfx_bdirectwindow_exit(struct BITMAP *b); +void be_gfx_bdirectwindow_acquire(struct BITMAP *bmp); +void be_gfx_bdirectwindow_release(struct BITMAP *bmp); +void be_gfx_bdirectwindow_set_palette(AL_CONST struct RGB *p, int from, int to, int vsync); + +struct BITMAP *be_gfx_bwindow_init(int w, int h, int v_w, int v_h, int color_depth); +void be_gfx_bwindow_exit(struct BITMAP *b); +void be_gfx_bwindow_acquire(struct BITMAP *bmp); +void be_gfx_bwindow_release(struct BITMAP *bmp); +void be_gfx_bwindow_set_palette(AL_CONST struct RGB *p, int from, int to, int vsync); + +#ifdef ALLEGRO_NO_ASM +void _be_gfx_bwindow_unwrite_bank(BITMAP *bmp); +uintptr_t _be_gfx_bwindow_read_write_bank(BITMAP *bmp, int lyne); +#else +void _be_gfx_bwindow_unwrite_bank_asm(BITMAP *bmp); +uintptr_t _be_gfx_bwindow_read_write_bank_asm(BITMAP *bmp, int lyne); +#endif + +struct BITMAP *be_gfx_overlay_init(int w, int h, int v_w, int v_h, int color_depth); +void be_gfx_overlay_exit(struct BITMAP *b); + +int be_time_init(void); +void be_time_exit(void); +void be_time_rest(unsigned int tyme, AL_METHOD(void, callback, (void))); +void be_time_suspend(void); +void be_time_resume(void); + +int be_mouse_init(void); +void be_mouse_exit(void); +void be_mouse_position(int x, int y); +void be_mouse_set_range(int x1, int y_1, int x2, int y2); +void be_mouse_set_speed(int xspeed, int yspeed); +void be_mouse_get_mickeys(int *mickeyx, int *mickeyy); + +int be_joy_init(void); +void be_joy_exit(void); +int be_joy_poll(void); + +int be_sound_detect(int input); +int be_sound_init(int input, int voices); +void be_sound_exit(int input); +void *be_sound_lock_voice(int voice, int start, int end); +void be_sound_unlock_voice(int voice); +int be_sound_buffer_size(void); +int be_sound_set_mixer_volume(int volume); +int be_sound_get_mixer_volume(void); +void be_sound_suspend(void); +void be_sound_resume(void); + +int be_midi_detect(int input); +int be_midi_init(int input, int voices); +void be_midi_exit(int input); +int be_midi_set_mixer_volume(int volume); +int be_midi_get_mixer_volume(void); +void be_midi_key_on(int inst, int note, int bend, int vol, int pan); +void be_midi_key_off(int voice); +void be_midi_set_volume(int voice, int vol); +void be_midi_set_pitch(int voice, int note, int bend); +void be_midi_set_pan(int voice, int pan); + +#ifdef __cplusplus +} +#endif diff --git a/lib/allegro/include/allegro/platform/aintdos.h b/lib/allegro/include/allegro/platform/aintdos.h new file mode 100644 index 0000000..c01b254 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aintdos.h @@ -0,0 +1,184 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Some definitions for internal use by the DOS library code. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef AINTDOS_H +#define AINTDOS_H + +#ifndef ALLEGRO_H + #error must include allegro.h first +#endif + +#ifndef ALLEGRO_DOS + #error bad include +#endif + +#ifdef __cplusplus + extern "C" { +#endif + + +/* macros to enable and disable interrupts */ +#if defined ALLEGRO_GCC + + #define DISABLE() asm volatile ("cli") + #define ENABLE() asm volatile ("sti") + +#elif defined ALLEGRO_WATCOM + + void DISABLE(void); + void ENABLE(void); + + #pragma aux DISABLE = "cli"; + #pragma aux ENABLE = "sti"; + +#else + + #define DISABLE() asm { cli } + #define ENABLE() asm { sti } + +#endif + + +AL_INLINE(void, _enter_critical, (void), +{ + /* check if windows is running */ + if ((os_type == OSTYPE_WIN3) || (os_type == OSTYPE_WIN95) || + (os_type == OSTYPE_WIN98) || (os_type == OSTYPE_WINME) || + (os_type == OSTYPE_WINNT) || (os_type == OSTYPE_WIN2000)) { + __dpmi_regs r; + r.x.ax = 0x1681; + __dpmi_int(0x2F, &r); + } + + DISABLE(); +}) + + +AL_INLINE(void, _exit_critical, (void), +{ + /* check if windows is running */ + if ((os_type == OSTYPE_WIN3) || (os_type == OSTYPE_WIN95) || + (os_type == OSTYPE_WIN98) || (os_type == OSTYPE_WINME) || + (os_type == OSTYPE_WINNT) || (os_type == OSTYPE_WIN2000)) { + __dpmi_regs r; + r.x.ax = 0x1682; + __dpmi_int(0x2F, &r); + } + + ENABLE(); +}) + + +/* interrupt hander stuff */ +AL_FUNC(void, _dos_irq_init, (void)); +AL_FUNC(void, _dos_irq_exit, (void)); + +#define _map_irq(irq) (((irq)>7) ? ((irq)+104) : ((irq)+8)) + +AL_FUNC(int, _install_irq, (int num, AL_METHOD(int, handler, (void)))); +AL_FUNC(void, _remove_irq, (int num)); +AL_FUNC(void, _restore_irq, (int irq)); +AL_FUNC(void, _enable_irq, (int irq)); +AL_FUNC(void, _disable_irq, (int irq)); + +#define _eoi(irq) { outportb(0x20, 0x20); if ((irq)>7) outportb(0xA0, 0x20); } + +typedef struct _IRQ_HANDLER +{ + AL_METHOD(int, handler, (void)); /* our C handler */ + int number; /* irq number */ + + #ifdef ALLEGRO_DJGPP + __dpmi_paddr old_vector; /* original protected mode vector */ + #else + void (__interrupt __far *old_vector)(); + #endif +} _IRQ_HANDLER; + + +/* sound lib stuff */ +AL_VAR(int, _fm_port); +AL_VAR(int, _mpu_port); +AL_VAR(int, _mpu_irq); + + +/* DPMI memory mapping routines */ +AL_FUNC(int, _create_physical_mapping, (unsigned long *linear, int *segment, unsigned long physaddr, int size)); +AL_FUNC(void, _remove_physical_mapping, (unsigned long *linear, int *segment)); +AL_FUNC(int, _create_linear_mapping, (unsigned long *linear, unsigned long physaddr, int size)); +AL_FUNC(void, _remove_linear_mapping, (unsigned long *linear)); +AL_FUNC(int, _create_selector, (int *segment, unsigned long linear, int size)); +AL_FUNC(void, _remove_selector, (int *segment)); +AL_FUNC(void, _unlock_dpmi_data, (void *addr, int size)); + + +/* bank switching routines (these use a non-C calling convention on i386!) */ +AL_FUNC(void, _vesa_window_1, (void)); +AL_FUNC(void, _vesa_window_1_end, (void)); + +AL_FUNC(void, _vesa_window_2, (void)); +AL_FUNC(void, _vesa_window_2_end, (void)); + +AL_FUNC(void, _vesa_pm_window_1, (void)); +AL_FUNC(void, _vesa_pm_window_1_end, (void)); + +AL_FUNC(void, _vesa_pm_window_2, (void)); +AL_FUNC(void, _vesa_pm_window_2_end, (void)); + +AL_FUNC(void, _vesa_pm_es_window_1, (void)); +AL_FUNC(void, _vesa_pm_es_window_1_end, (void)); + +AL_FUNC(void, _vesa_pm_es_window_2, (void)); +AL_FUNC(void, _vesa_pm_es_window_2_end, (void)); + + +/* stuff for the VESA driver */ +AL_VAR(__dpmi_regs, _dpmi_reg); + +AL_VAR(int, _window_2_offset); + +AL_VAR(int, _mmio_segment); + +AL_FUNCPTR(void, _pm_vesa_switcher, (void)); +AL_FUNCPTR(void, _pm_vesa_scroller, (void)); +AL_FUNCPTR(void, _pm_vesa_palette, (void)); + + +AL_FUNC(int, _sb_read_dsp_version, (void)); +AL_FUNC(int, _sb_reset_dsp, (int data)); +AL_FUNC(void, _sb_voice, (int state)); +AL_FUNC(int, _sb_set_mixer, (int digi_volume, int midi_volume)); + +AL_FUNC(void, _mpu_poll, (void)); + +AL_FUNC(int, _dma_allocate_mem, (int bytes, int *sel, unsigned long *phys)); +AL_FUNC(void, _dma_start, (int channel, unsigned long addr, int size, int auto_init, int input)); +AL_FUNC(void, _dma_stop, (int channel)); +AL_FUNC(unsigned long, _dma_todo, (int channel)); +AL_FUNC(void, _dma_lock_mem, (void)); + + + +#ifdef __cplusplus + } +#endif + +/* VGA register access helpers */ +#include "allegro/internal/aintvga.h" + +#endif /* ifndef AINTDOS_H */ diff --git a/lib/allegro/include/allegro/platform/aintlnx.h b/lib/allegro/include/allegro/platform/aintlnx.h new file mode 100644 index 0000000..f3dcd35 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aintlnx.h @@ -0,0 +1,252 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Some definitions for internal use by the Linux console code. + * + * By George Foot. + * + * See readme.txt for copyright information. + */ + +#ifndef AINTLNX_H +#define AINTLNX_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/**************************************/ +/************ Driver lists ************/ +/**************************************/ + +extern _DRIVER_INFO _linux_gfx_driver_list[]; +extern _DRIVER_INFO _linux_keyboard_driver_list[]; +extern _DRIVER_INFO _linux_mouse_driver_list[]; +extern _DRIVER_INFO _linux_timer_driver_list[]; +extern _DRIVER_INFO _linux_joystick_driver_list[]; + + +/****************************************/ +/************ Memory mapping ************/ /* (src/linux/lmemory.c) */ +/****************************************/ + +/* struct MAPPED_MEMORY: Used to describe a block of memory mapped + * into our address space (in particular, the video memory). + */ +struct MAPPED_MEMORY { + unsigned int base, size; /* linear address and size of block */ + int perms; /* PROT_READ | PROT_WRITE, etc */ + void *data; /* pointer to block after mapping */ +}; + +extern int __al_linux_have_ioperms; + +int __al_linux_init_memory (void); +int __al_linux_shutdown_memory (void); +int __al_linux_map_memory (struct MAPPED_MEMORY *info); +int __al_linux_unmap_memory (struct MAPPED_MEMORY *info); + + +/******************************************/ +/************ Standard drivers ************/ /* (src/linux/lstddrv.c) */ +/******************************************/ + +/* This "standard drivers" business is mostly a historical artifact. + * It was highly over-engineered, now simplified. It has been mostly + * superseded by the newer, shinier, better bg_man. But hey, at least + * it didn't suffer the fate of its cousin lasyncio.c, now dead, + * buried, and without a tombstone to show for it. --pw + */ + +typedef struct STD_DRIVER { + unsigned type; /* One of the below STD_ constants */ + + int (*update) (void); + void (*resume) (void); + void (*suspend) (void); + + int fd; /* Descriptor of the opened device */ +} STD_DRIVER; + +#define STD_MOUSE 0 +#define STD_KBD 1 + +#define N_STD_DRIVERS 2 + +/* List of standard drivers */ +extern STD_DRIVER *__al_linux_std_drivers[]; + +/* Exported functions */ +int __al_linux_add_standard_driver (STD_DRIVER *spec); +int __al_linux_remove_standard_driver (STD_DRIVER *spec); +void __al_linux_update_standard_drivers (int threaded); +void __al_linux_suspend_standard_drivers (void); +void __al_linux_resume_standard_drivers (void); + + +/******************************************/ +/************ Console routines ************/ /* (src/linux/lconsole.c) */ +/******************************************/ + +#define N_CRTC_REGS 24 +#define N_ATC_REGS 21 +#define N_GC_REGS 9 +#define N_SEQ_REGS 5 + +#define MISC_REG_R 0x03CC +#define MISC_REG_W 0x03C2 +#define ATC_REG_IW 0x03C0 +#define ATC_REG_R 0x03C1 +#define GC_REG_I 0x03CE +#define GC_REG_RW 0x03CF +#define SEQ_REG_I 0x03C4 +#define SEQ_REG_RW 0x03C5 +#define PEL_REG_IW 0x03C8 +#define PEL_REG_IR 0x03C7 +#define PEL_REG_D 0x03C9 + +#define _is1 0x03DA + +#define ATC_DELAY 10 /* microseconds - for usleep() */ + +#define VGA_MEMORY_BASE 0xA0000 +#define VGA_MEMORY_SIZE 0x10000 +#define VGA_FONT_SIZE 0x02000 + +/* This structure is also used for video state saving/restoring, therefore it + * contains fields that are used only when saving/restoring the text mode. */ +typedef struct MODE_REGISTERS +{ + unsigned char crt[N_CRTC_REGS]; + unsigned char seq[N_SEQ_REGS]; + unsigned char atc[N_ATC_REGS]; + unsigned char gc[N_GC_REGS]; + unsigned char misc; + unsigned char *ext; + unsigned short ext_count; + unsigned char *text_font1; + unsigned char *text_font2; + unsigned long flags; + union { + unsigned char vga[768]; + PALETTE allegro; + } palette; +} MODE_REGISTERS; + +extern int __al_linux_vt; +extern int __al_linux_console_fd; +extern int __al_linux_prev_vt; +extern int __al_linux_got_text_message; +extern struct termios __al_linux_startup_termio; +extern struct termios __al_linux_work_termio; + +int __al_linux_use_console (void); +int __al_linux_leave_console (void); + +int __al_linux_console_graphics (void); +int __al_linux_console_text (void); + +int __al_linux_wait_for_display (void); + + +/*************************************/ +/************ VGA helpers ************/ /* (src/linux/lvgahelp.c) */ +/*************************************/ + +int __al_linux_init_vga_helpers (void); +int __al_linux_shutdown_vga_helpers (void); + +void __al_linux_screen_off (void); +void __al_linux_screen_on (void); + +void __al_linux_clear_vram (void); + +void __al_linux_set_vga_regs (MODE_REGISTERS *regs); +void __al_linux_get_vga_regs (MODE_REGISTERS *regs); + +void __al_linux_save_gfx_mode (void); +void __al_linux_restore_gfx_mode (void); +void __al_linux_save_text_mode (void); +void __al_linux_restore_text_mode (void); + +#define __just_a_moment() usleep(ATC_DELAY) + + +/**************************************/ +/************ VT switching ************/ /* (src/linux/vtswitch.c) */ +/**************************************/ + +/* signals for VT switching */ +#define SIGRELVT SIGUSR1 +#define SIGACQVT SIGUSR2 + +int __al_linux_init_vtswitch (void); +int __al_linux_done_vtswitch (void); + +void __al_linux_acquire_bitmap (BITMAP *bmp); +void __al_linux_release_bitmap (BITMAP *bmp); + +int __al_linux_set_display_switch_mode (int mode); +void __al_linux_display_switch_lock (int lock, int foreground); + +extern volatile int __al_linux_switching_blocked; + + +/**************************************/ +/************ Mode setting ************/ /* (src/linux/lgraph.c) */ +/**************************************/ + +typedef struct GFX_MODE_INFO { + int w,h,c; /* width, height, colour depth */ + int id; /* ID code, for driver's reference */ + void *data; /* data for driver's use in setting the mode */ +} GFX_MODE_INFO; + +BITMAP *__al_linux_gfx_mode_set_helper ( + int w, int h, int v_w, int v_h, int c, + GFX_DRIVER *driver, GFX_MODE_INFO *mode, + int (*set_video_mode) (GFX_MODE_INFO *mode), + void (*set_width) (int w) +); + + +/*******************************/ +/************ Mouse ************/ /* (src/linux/lmouse.c) */ +/*******************************/ + +typedef struct INTERNAL_MOUSE_DRIVER { + int device; + int (*process) (unsigned char *buf, int buf_size); + int num_buttons; +} INTERNAL_MOUSE_DRIVER; + +int __al_linux_mouse_init (INTERNAL_MOUSE_DRIVER *drv); +void __al_linux_mouse_exit (void); +void __al_linux_mouse_position (int x, int y); +void __al_linux_mouse_set_range (int x1, int y_1, int x2, int y2); +void __al_linux_mouse_set_speed (int xspeed, int yspeed); +void __al_linux_mouse_get_mickeys (int *mickeyx, int *mickeyy); +void __al_linux_mouse_handler (int x, int y, int z, int b); + + +#ifdef __cplusplus +} +#endif + +/* VGA register access helpers */ +/* This is conditional because configure may have disabled VGA support */ +#ifdef ALLEGRO_LINUX_VGA + #include "allegro/internal/aintern.h" + #include "allegro/internal/aintvga.h" +#endif + +#endif /* ifndef AINTLNX_H */ + diff --git a/lib/allegro/include/allegro/platform/aintmac.h b/lib/allegro/include/allegro/platform/aintmac.h new file mode 100644 index 0000000..0625ce1 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aintmac.h @@ -0,0 +1,95 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Some definitions for internal use by the MacOs library code. + * + * By Ronaldo Hideki Yamada. + * + * See readme.txt for copyright information. + */ + + +#ifndef AINTMAC_H +#define AINTMAC_H + +#ifndef ALLEGRO_H + #error must include allegro.h first +#endif + +#ifndef ALLEGRO_MPW + #error bad include +#endif + +#include "macalleg.h" +#include "allegro/aintern.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/*macsbmp.c*/ +extern void _mac_init_system_bitmap(void); +extern BITMAP *_mac_create_system_bitmap(int w, int h); +extern void _mac_destroy_system_bitmap(BITMAP *bmp); +extern void _mac_sys_set_clip(struct BITMAP *dst); +extern void _mac_sys_clear_to_color8(BITMAP *bmp, int color); +extern void _mac_sys_blit8(BITMAP *src, BITMAP *dst, int src_x, int src_y, int dst_x, int dst_y, int w, int h); +extern void _mac_sys_selfblit8(BITMAP *src, BITMAP *dst, int src_x, int src_y, int dst_x, int dst_y, int w, int h); +extern int _mac_sys_triangle(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color); +extern void _mac_sys_rectfill8(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); +extern void _mac_sys_hline8(struct BITMAP *bmp, int x1, int y, int x2, int color); +extern void _mac_sys_vline8(struct BITMAP *bmp, int x, int y_1, int y2, int color); +extern BITMAP *_CGrafPtr_to_system_bitmap(CGrafPtr cg); + +/*macdraw.c*/ +extern GDHandle MainGDevice; +extern CTabHandle MainCTable; +extern short dspr_depth; +extern volatile short _sync; +extern const RGBColor ForeDef; +extern const RGBColor BackDef; +extern int _dspr_sys_init(); +extern void _dspr_sys_exit(); + +enum{kRDDNull =0, + kRDDStarted =1, + kRDDReserved =2, + kRDDFadeOut =4, + kRDDActive =8, + kRDDPaused =16, + kRDDUnder =32, + kRDDOver =64, + kRDDouble =128, +}; + +/*macsys.c*/ +extern void _mac_get_executable_name(char *output, int size); +extern void _mac_message(const char *msg); +extern int _tm_sys_init(); +extern void _tm_sys_exit(); + +/*macfile.c*/ +extern int _al_open(const char *filename, int mode); +extern int _mac_file_sys_init(); + +/*macallegro.c*/ +extern QDGlobals qd; /*The our QuickDraw globals */ +extern char *strdup(const char *p); +extern void ptoc(StringPtr pstr, char *cstr); +extern Boolean RTrapAvailable(short tNumber, TrapType tType); +extern void MacEntry(); + +#ifdef __cplusplus + } +#endif + + +#endif /* ifndef AINTMAC_H */ + diff --git a/lib/allegro/include/allegro/platform/aintosx.h b/lib/allegro/include/allegro/platform/aintosx.h new file mode 100644 index 0000000..83aab0c --- /dev/null +++ b/lib/allegro/include/allegro/platform/aintosx.h @@ -0,0 +1,190 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Internal header file for the MacOS X Allegro library port. + * + * By Angelo Mottola. + * + * See readme.txt for copyright information. + */ + + +#ifndef AINTOSX_H +#define AINTOSX_H + +#ifdef __OBJC__ + +#include "allegro/platform/aintunix.h" + +#include +#include +#include +#include +#include +#include + + +#ifndef NSAppKitVersionNumber10_1 +#define NSAppKitVersionNumber10_1 620 +#endif +#ifndef NSAppKitVersionNumber10_2 +#define NSAppKitVersionNumber10_2 663 +#endif + + +#define OSX_GFX_NONE 0 +#define OSX_GFX_WINDOW 1 +#define OSX_GFX_FULL 2 + +#define BMP_EXTRA(bmp) ((BMP_EXTRA_INFO *)((bmp)->extra)) + +#define HID_MAX_DEVICES MAX_JOYSTICKS +#define HID_MOUSE 0 +#define HID_JOYSTICK 1 +#define HID_GAMEPAD 2 + +#define HID_MAX_DEVICE_ELEMENTS ((MAX_JOYSTICK_AXIS * MAX_JOYSTICK_STICKS) + MAX_JOYSTICK_BUTTONS) +#define HID_ELEMENT_BUTTON 0 +#define HID_ELEMENT_AXIS 1 +#define HID_ELEMENT_AXIS_PRIMARY_X 2 +#define HID_ELEMENT_AXIS_PRIMARY_Y 3 +#define HID_ELEMENT_STANDALONE_AXIS 4 +#define HID_ELEMENT_HAT 5 + + + +@interface AllegroAppDelegate : NSObject +- (BOOL)application: (NSApplication *)theApplication openFile: (NSString *)filename; +- (void)applicationDidFinishLaunching: (NSNotification *)aNotification; +- (void)applicationDidChangeScreenParameters: (NSNotification *)aNotification; ++ (void)app_main: (id)arg; +- (NSApplicationTerminateReply) applicationShouldTerminate: (id)sender; +@end + + +@interface AllegroWindow : NSWindow +- (void)display; +- (void)miniaturize: (id)sender; +@end + + +@interface AllegroWindowDelegate : NSObject +- (BOOL)windowShouldClose: (id)sender; +- (void)windowDidDeminiaturize: (NSNotification *)aNotification; +@end + + +@interface AllegroView: NSQuickDrawView +- (void)resetCursorRects; +@end + + +typedef void RETSIGTYPE; + + +typedef struct BMP_EXTRA_INFO +{ + GrafPtr port; +} BMP_EXTRA_INFO; + + +typedef struct HID_ELEMENT +{ + int type; + IOHIDElementCookie cookie; + int max, min; + int app; + int col; + int index; + char *name; +} HID_ELEMENT; + + +typedef struct HID_DEVICE +{ + int type; + char *manufacturer; + char *product; + int num_elements; + int capacity; + HID_ELEMENT *element; + IOHIDDeviceInterface **interface; + int cur_app; +} HID_DEVICE; + +typedef struct +{ + int count; + int capacity; + HID_DEVICE* devices; +} HID_DEVICE_COLLECTION; + + +void osx_event_handler(void); +int osx_bootstrap_ok(void); + +void setup_direct_shifts(void); +void osx_init_fade_system(void); +void osx_fade_screen(int fade_in, double seconds); +void osx_qz_blit_to_self(BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); +void osx_qz_created_sub_bitmap(BITMAP *bmp, BITMAP *parent); +BITMAP *osx_qz_create_video_bitmap(int width, int height); +BITMAP *osx_qz_create_system_bitmap(int width, int height); +void osx_qz_destroy_video_bitmap(BITMAP *bmp); +int osx_setup_colorconv_blitter(void); +void osx_update_dirty_lines(void); + +uintptr_t osx_qz_write_line(BITMAP *bmp, int lyne); +void osx_qz_unwrite_line(BITMAP *bmp); +void osx_qz_acquire(BITMAP *bmp); +void osx_qz_release(BITMAP *bmp); + +void osx_keyboard_handler(int pressed, NSEvent *event); +void osx_keyboard_modifiers(unsigned int new_mods); +void osx_keyboard_focused(int focused, int state); + +void osx_mouse_handler(int x, int y, int dx, int dy, int dz, int buttons); +int osx_mouse_set_sprite(BITMAP *sprite, int x, int y); +int osx_mouse_show(BITMAP *bmp, int x, int y); +void osx_mouse_hide(void); +void osx_mouse_move(int x, int y); + +HID_DEVICE_COLLECTION *osx_hid_scan(int type, HID_DEVICE_COLLECTION*); +void osx_hid_free(HID_DEVICE_COLLECTION *); + + +AL_VAR(NSBundle *, osx_bundle); +AL_VAR(void *, osx_event_mutex); +AL_VAR(void *, osx_window_mutex); +AL_VAR(int, osx_gfx_mode); +AL_VAR(int, osx_screen_used); +AL_VAR(NSCursor *, osx_blank_cursor); +AL_VAR(NSCursor *, osx_cursor); +AL_VAR(AllegroWindow *, osx_window); +AL_ARRAY(char, osx_window_title); +AL_VAR(int, osx_window_first_expose); +AL_VAR(CGDirectPaletteRef, osx_palette); +AL_VAR(int, osx_palette_dirty); +AL_VAR(int, osx_mouse_warped); +AL_VAR(int, osx_skip_mouse_move); +AL_VAR(int, osx_emulate_mouse_buttons); +AL_VAR(NSTrackingRectTag, osx_mouse_tracking_rect); +extern AL_METHOD(void, osx_window_close_hook, (void)); + + +#endif + +#endif + +/* Local variables: */ +/* mode: objc */ +/* c-basic-offset: 3 */ +/* indent-tabs-mode: nil */ +/* End: */ diff --git a/lib/allegro/include/allegro/platform/aintqnx.h b/lib/allegro/include/allegro/platform/aintqnx.h new file mode 100644 index 0000000..b3b61a6 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aintqnx.h @@ -0,0 +1,113 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Internal header for the QNX Allegro library. + * + * By Angelo Mottola. + * + * See readme.txt for copyright information. + */ + + +#ifndef AINTQNX_H +#define AINTQNX_H + +#include "allegro/platform/aintunix.h" + +#ifndef SCAN_DEPEND + #include + #include + #include +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* from qphaccel.c */ +AL_FUNC(void, enable_acceleration, (GFX_DRIVER * drv)); +AL_FUNC(void, enable_triple_buffering, (GFX_DRIVER *drv)); + + +/* from qphbmp.c */ +typedef struct BMP_EXTRA_INFO { + PdOffscreenContext_t *context; +} BMP_EXTRA_INFO; + +#define BMP_EXTRA(bmp) ((BMP_EXTRA_INFO *)(bmp->extra)) + +AL_VAR(BITMAP *, ph_frontbuffer); + +AL_FUNC(uintptr_t, ph_write_line, (BITMAP *bmp, int lyne)); +AL_FUNC(uintptr_t, ph_write_line_asm, (BITMAP *bmp, int lyne)); +AL_FUNC(void, ph_unwrite_line, (BITMAP *bmp, int lyne)); +AL_FUNC(void, ph_unwrite_line_asm, (BITMAP *bmp, int lyne)); +AL_FUNC(void, ph_acquire, (BITMAP *bmp)); +AL_FUNC(void, ph_release, (BITMAP *bmp)); +AL_FUNC(BITMAP *, make_photon_bitmap, (PdOffscreenContext_t *context, int w, int h, int id)); +AL_FUNC(void, destroy_photon_bitmap, (BITMAP *bmp)); +AL_FUNC(void, qnx_ph_created_sub_bitmap, (BITMAP *bmp, BITMAP *parent)); +AL_FUNC(BITMAP *, qnx_ph_create_video_bitmap, (int width, int height)); +AL_FUNC(void, qnx_ph_destroy_video_bitmap, (BITMAP *bmp)); +AL_FUNC(int, qnx_ph_show_video_bitmap, (BITMAP *bmp)); +AL_FUNC(int, qnx_ph_request_video_bitmap, (BITMAP *bmp)); + + +/* from qphoton.c */ +#define PH_GFX_NONE 0 +#define PH_GFX_WINDOW 1 +#define PH_GFX_DIRECT 2 +#define PH_GFX_OVERLAY 3 + +AL_VAR(int, ph_gfx_mode); +AL_VAR(PgVideoModeInfo_t, ph_gfx_mode_info); +AL_ARRAY(PgColor_t, ph_palette); + +AL_FUNC(void, setup_direct_shifts, (void)); +AL_FUNC(void, setup_driver, (GFX_DRIVER *drv, int w, int h, int color_depth)); + + +/* from qphwin.c */ +AL_VAR(BITMAP *, pseudo_screen); + +AL_FUNCPTR(void, ph_update_window, (PhRect_t* rect)); + + +/* from qsystem.c */ +AL_VAR(PtWidget_t, *ph_window); +AL_VAR(pthread_mutex_t, qnx_event_mutex); +AL_VAR(pthread_mutex_t, qnx_gfx_mutex); + + +/* from qkeydrv.c */ +AL_FUNC(void, qnx_keyboard_handler, (int, int)); +AL_FUNC(void, qnx_keyboard_focused, (int, int)); + + +/* from qmouse.c */ +AL_VAR(int, qnx_mouse_warped); +AL_FUNC(void, qnx_mouse_handler, (int, int, int, int)); + + +/* A very strange thing: PgWaitHWIdle() cannot be found in any system + * header file, but it is explained in the QNX docs, and it actually + * exists in the Photon library... So until QNX fixes the missing declaration, + * we will declare it here. + */ +int PgWaitHWIdle(void); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/allegro/include/allegro/platform/aintunix.h b/lib/allegro/include/allegro/platform/aintunix.h new file mode 100644 index 0000000..42b66c9 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aintunix.h @@ -0,0 +1,194 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Some definitions for internal use by the Unix library code. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + +#ifndef AINTUNIX_H +#define AINTUNIX_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_LIBPTHREAD + /* Synchronization routines using POSIX threads */ + AL_FUNC(void *, _unix_create_mutex, (void)); + AL_FUNC(void, _unix_destroy_mutex, (void *handle)); + AL_FUNC(void, _unix_lock_mutex, (void *handle)); + AL_FUNC(void, _unix_unlock_mutex, (void *handle)); +#else + /* Asynchronous event processing with SIGALRM */ + AL_FUNC(void, _sigalrm_request_abort, (void)); + AL_FUNCPTR(void, _sigalrm_timer_interrupt_handler, (unsigned long interval)); +#endif + + /* Macros to enable and disable interrupts */ + #define DISABLE() _unix_bg_man->disable_interrupts() + #define ENABLE() _unix_bg_man->enable_interrupts() + + + /* Helper for locating config files */ + AL_FUNC(int, _unix_find_resource, (char *dest, AL_CONST char *resource, int size)); + + + /* Generic system driver entry for finding the executable */ + AL_FUNC(void, _unix_get_executable_name, (char *output, int size)); + + + /* Helper for setting os_type */ + AL_FUNC(void, _unix_read_os_type, (void)); + + + /* Helper for yield CPU */ + AL_FUNC(void, _unix_yield_timeslice, (void)); + + + /* Unix rest function */ + AL_FUNC(void, _unix_rest, (unsigned int, AL_METHOD(void, callback, (void)))); + + + /* Module support */ + AL_FUNC(void, _unix_load_modules, (int system_driver_id)); + AL_FUNC(void, _unix_unload_modules, (void)); + + + /* Dynamic driver lists, for modules */ + AL_VAR(_DRIVER_INFO *, _unix_gfx_driver_list); + AL_VAR(_DRIVER_INFO *, _unix_digi_driver_list); + AL_VAR(_DRIVER_INFO *, _unix_midi_driver_list); + AL_FUNC(void, _unix_driver_lists_init, (void)); + AL_FUNC(void, _unix_driver_lists_shutdown, (void)); + AL_FUNC(void, _unix_register_gfx_driver, (int id, GFX_DRIVER *driver, int autodetect, int priority)); + AL_FUNC(void, _unix_register_digi_driver, (int id, DIGI_DRIVER *driver, int autodetect, int priority)); + AL_FUNC(void, _unix_register_midi_driver, (int id, MIDI_DRIVER *driver, int autodetect, int priority)); + + + /* File system helpers */ + AL_FUNC(void, _unix_guess_file_encoding, (void)); + + + /* Get size of a memory page in bytes */ + AL_FUNC(size_t, _unix_get_page_size, (void)); + + +#ifdef ALLEGRO_WITH_XWINDOWS + AL_FUNCPTR(void, _xwin_keyboard_interrupt, (int pressed, int code)); + AL_FUNCPTR(void, _xwin_keyboard_focused, (int focused, int state)); + AL_FUNCPTR(void, _xwin_mouse_interrupt, (int x, int y, int z, int buttons)); + AL_FUNCPTR(void, _xwin_timer_interrupt, (unsigned long interval)); + + AL_ARRAY(_DRIVER_INFO, _xwin_gfx_driver_list); + AL_ARRAY(_DRIVER_INFO, _xwin_keyboard_driver_list); + AL_ARRAY(_DRIVER_INFO, _xwin_mouse_driver_list); + AL_ARRAY(_DRIVER_INFO, _xwin_timer_driver_list); + + AL_FUNC(void, _xwin_handle_input, (void)); + AL_FUNC(void, _xwin_private_handle_input, (void)); + +#ifndef ALLEGRO_MULTITHREADED + + AL_VAR(int, _xwin_missed_input); + + #define XLOCK() \ + do { \ + _xwin.lock_count++; \ + } while (0) + + #define XUNLOCK() \ + do { \ + if (_xwin.lock_count == 1) { \ + while(_xwin_missed_input) { \ + if (_xwin_input_handler) \ + _xwin_input_handler(); \ + else \ + _xwin_private_handle_input(); \ + --_xwin_missed_input; \ + } \ + } \ + _xwin.lock_count--; \ + } while (0) + +#else + + #define XLOCK() \ + do { \ + if (_xwin.mutex) \ + _unix_lock_mutex (_xwin.mutex); \ + _xwin.lock_count++; \ + } while (0) + + #define XUNLOCK() \ + do { \ + if (_xwin.mutex) \ + _unix_unlock_mutex (_xwin.mutex); \ + _xwin.lock_count--; \ + } while (0) + +#endif + +#endif + + +#ifdef ALLEGRO_WITH_OSSDIGI + /* So the setup program can read what we detected */ + AL_VAR(int, _oss_fragsize); + AL_VAR(int, _oss_numfrags); +#endif + + +#ifdef __cplusplus +} +#endif + + +#ifdef ALLEGRO_LINUX + #include "aintlnx.h" +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Typedef for background functions, called frequently in the background. + * `threaded' is nonzero if the function is being called from a thread. + */ +typedef void (*bg_func) (int threaded); + +/* Background function manager -- responsible for calling background + * functions. `int' methods return -1 on failure, 0 on success. */ +struct bg_manager +{ + int multi_threaded; + int (*init) (void); + void (*exit) (void); + int (*register_func) (bg_func f); + int (*unregister_func) (bg_func f); + void (*enable_interrupts) (void); + void (*disable_interrupts) (void); + int (*interrupts_disabled) (void); +}; + +extern struct bg_manager _bg_man_pthreads; +extern struct bg_manager _bg_man_sigalrm; + +extern struct bg_manager *_unix_bg_man; + + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef AINTUNIX_H */ diff --git a/lib/allegro/include/allegro/platform/aintwin.h b/lib/allegro/include/allegro/platform/aintwin.h new file mode 100644 index 0000000..0699e11 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aintwin.h @@ -0,0 +1,222 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Some definitions for internal use by the Windows library code. + * + * By Stefan Schimanski. + * + * See readme.txt for copyright information. + */ + + +#ifndef AINTWIN_H +#define AINTWIN_H + +#ifndef ALLEGRO_H + #error must include allegro.h first +#endif + +#ifndef ALLEGRO_WINDOWS + #error bad include +#endif + + +#include "winalleg.h" + +#ifndef SCAN_DEPEND + /* workaround for buggy MinGW32 headers */ + #ifdef ALLEGRO_MINGW32 + #ifndef HMONITOR_DECLARED + #define HMONITOR_DECLARED + #endif + #if (defined _HRESULT_DEFINED) && (defined WINNT) + #undef WINNT + #endif + #endif + + #include /* for LPGUID */ +#endif + + +#ifdef __cplusplus + extern "C" { +#endif + +/* generals */ +AL_VAR(HINSTANCE, allegro_inst); +AL_VAR(HANDLE, allegro_thread); +AL_VAR(CRITICAL_SECTION, allegro_critical_section); +AL_VAR(int, _dx_ver); + +#define _enter_critical() EnterCriticalSection(&allegro_critical_section) +#define _exit_critical() LeaveCriticalSection(&allegro_critical_section) + +AL_FUNC(int, init_directx_window, (void)); +AL_FUNC(void, exit_directx_window, (void)); +AL_FUNC(int, get_dx_ver, (void)); +AL_FUNC(int, adjust_window, (int w, int h)); +AL_FUNC(void, restore_window_style, (void)); +AL_FUNC(void, save_window_pos, (void)); + + +/* main window */ +#define WND_TITLE_SIZE 128 + +AL_ARRAY(char, wnd_title); +AL_VAR(int, wnd_x); +AL_VAR(int, wnd_y); +AL_VAR(int, wnd_width); +AL_VAR(int, wnd_height); +AL_VAR(int, wnd_sysmenu); + +AL_FUNCPTR(void, user_close_proc, (void)); + + +/* gfx synchronization */ +AL_VAR(CRITICAL_SECTION, gfx_crit_sect); +AL_VAR(int, gfx_crit_sect_nesting); + +#define _enter_gfx_critical() EnterCriticalSection(&gfx_crit_sect); \ + gfx_crit_sect_nesting++ +#define _exit_gfx_critical() LeaveCriticalSection(&gfx_crit_sect); \ + gfx_crit_sect_nesting-- +#define GFX_CRITICAL_RELEASED (!gfx_crit_sect_nesting) + + +/* switch routines */ +AL_VAR(int, _win_app_foreground); + +AL_FUNC(void, sys_directx_display_switch_init, (void)); +AL_FUNC(void, sys_directx_display_switch_exit, (void)); +AL_FUNC(int, sys_directx_set_display_switch_mode, (int mode)); + +AL_FUNC(void, _win_switch_in, (void)); +AL_FUNC(void, _win_switch_out, (void)); +AL_FUNC(void, _win_reset_switch_mode, (void)); + +AL_FUNC(int, _win_thread_switch_out, (void)); + + +/* main window routines */ +AL_FUNC(int, wnd_call_proc, (int (*proc)(void))); +AL_FUNC(void, wnd_schedule_proc, (int (*proc)(void))); + + +/* input routines */ +AL_VAR(int, _win_input_events); +AL_ARRAY(HANDLE, _win_input_event_id); +AL_FUNCPTRARRAY(void, _win_input_event_handler, (void)); + +AL_FUNC(void, _win_input_init, (int need_thread)); +AL_FUNC(void, _win_input_exit, (void)); +AL_FUNC(int, _win_input_register_event, (HANDLE event_id, void (*event_handler)(void))); +AL_FUNC(void, _win_input_unregister_event, (HANDLE event_id)); + + +/* keyboard routines */ +AL_FUNC(int, key_dinput_acquire, (void)); +AL_FUNC(int, key_dinput_unacquire, (void)); + + +/* mouse routines */ +AL_VAR(HCURSOR, _win_hcursor); +AL_FUNC(int, mouse_dinput_acquire, (void)); +AL_FUNC(int, mouse_dinput_unacquire, (void)); +AL_FUNC(int, mouse_dinput_grab, (void)); +AL_FUNC(int, mouse_set_syscursor, (void)); +AL_FUNC(int, mouse_set_sysmenu, (int state)); + + +/* joystick routines */ +#define WINDOWS_MAX_AXES 6 + +#define WINDOWS_JOYSTICK_INFO_MEMBERS \ + int caps; \ + int num_axes; \ + int axis[WINDOWS_MAX_AXES]; \ + char *axis_name[WINDOWS_MAX_AXES]; \ + int hat; \ + char *hat_name; \ + int num_buttons; \ + int button[MAX_JOYSTICK_BUTTONS]; \ + char *button_name[MAX_JOYSTICK_BUTTONS]; + +typedef struct WINDOWS_JOYSTICK_INFO { + WINDOWS_JOYSTICK_INFO_MEMBERS +} WINDOWS_JOYSTICK_INFO; + +AL_FUNC(int, win_add_joystick, (WINDOWS_JOYSTICK_INFO *win_joy)); +AL_FUNC(void, win_remove_all_joysticks, (void)); +AL_FUNC(int, win_update_joystick_status, (int n, WINDOWS_JOYSTICK_INFO *win_joy)); + +AL_FUNC(int, joystick_dinput_acquire, (void)); +AL_FUNC(int, joystick_dinput_unacquire, (void)); + + +/* thread routines */ +AL_FUNC(void, _win_thread_init, (void)); +AL_FUNC(void, _win_thread_exit, (void)); + + +/* synchronization routines */ +AL_FUNC(void *, sys_directx_create_mutex, (void)); +AL_FUNC(void, sys_directx_destroy_mutex, (void *handle)); +AL_FUNC(void, sys_directx_lock_mutex, (void *handle)); +AL_FUNC(void, sys_directx_unlock_mutex, (void *handle)); + + +/* sound routines */ +AL_FUNC(_DRIVER_INFO *, _get_win_digi_driver_list, (void)); +AL_FUNC(void, _free_win_digi_driver_list, (void)); + +AL_FUNC(DIGI_DRIVER *, _get_dsalmix_driver, (char *name, LPGUID guid, int num)); +AL_FUNC(DIGI_DRIVER *, _get_woalmix_driver, (int num)); + +AL_FUNC(int, digi_directsound_capture_init, (LPGUID guid)); +AL_FUNC(void, digi_directsound_capture_exit, (void)); +AL_FUNC(int, digi_directsound_capture_detect, (LPGUID guid)); +AL_FUNC(int, digi_directsound_rec_cap_rate, (int bits, int stereo)); +AL_FUNC(int, digi_directsound_rec_cap_param, (int rate, int bits, int stereo)); +AL_FUNC(int, digi_directsound_rec_source, (int source)); +AL_FUNC(int, digi_directsound_rec_start, (int rate, int bits, int stereo)); +AL_FUNC(void, digi_directsound_rec_stop, (void)); +AL_FUNC(int, digi_directsound_rec_read, (void *buf)); + + +/* midi routines */ +AL_FUNC(_DRIVER_INFO *, _get_win_midi_driver_list, (void)); +AL_FUNC(void, _free_win_midi_driver_list, (void)); + +AL_FUNC(void, midi_switch_out, (void)); + + +/* error handling */ +AL_FUNC(char* , win_err_str, (long err)); +AL_FUNC(void, thread_safe_trace, (char *msg, ...)); + +#if DEBUGMODE >= 2 + #define _TRACE thread_safe_trace +#else + #define _TRACE 1 ? (void) 0 : thread_safe_trace +#endif + +#define IS_OLD_WINDOWS (os_type==OSTYPE_WIN3 || os_type==OSTYPE_WIN95 || \ + os_type==OSTYPE_WIN98 || os_type==OSTYPE_WINME || \ + os_type==OSTYPE_UNKNOWN) + +AL_FUNC(int, _alwin_open, (const char*, int, int)); +#define _al_open _alwin_open + +#ifdef __cplusplus + } +#endif + +#endif /* !defined AINTWIN_H */ + diff --git a/lib/allegro/include/allegro/platform/al386gcc.h b/lib/allegro/include/allegro/platform/al386gcc.h new file mode 100644 index 0000000..136f064 --- /dev/null +++ b/lib/allegro/include/allegro/platform/al386gcc.h @@ -0,0 +1,402 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Inline functions (gcc style 386 asm). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#if (!defined ALLEGRO_GCC) || (!defined ALLEGRO_I386) + #error bad include +#endif + +#ifdef ALLEGRO_IMPORT_GFX_ASM + +/* _default_ds: + * Return a copy of the current %ds selector. + */ +AL_INLINE(int, _default_ds, (void), +{ + short result; + + __asm__ ( + " movw %%ds, %0 " + + : "=r" (result) + ); + + return result; +}) + + + +/* bmp_write_line: + * Bank switch function. + */ +AL_INLINE(uintptr_t, bmp_write_line, (BITMAP *bmp, int lyne), +{ + uintptr_t result; + + __asm__ volatile ( + " call *%3 " + + : "=a" (result) /* result in eax */ + + : "d" (bmp), /* bitmap in edx */ + "0" (lyne), /* line number in eax */ + "r" (bmp->write_bank) /* the bank switch routine */ + ); + + return result; +}) + + + +/* bmp_read_line: + * Bank switch function. + */ +AL_INLINE(uintptr_t, bmp_read_line, (BITMAP *bmp, int lyne), +{ + uintptr_t result; + + __asm__ volatile ( + " call *%3 " + + : "=a" (result) /* result in eax */ + + : "d" (bmp), /* bitmap in edx */ + "0" (lyne), /* line number in eax */ + "r" (bmp->read_bank) /* the bank switch routine */ + ); + + return result; +}) + + + +/* bmp_unwrite_line: + * Terminate bank switch function. + */ +AL_INLINE(void, bmp_unwrite_line, (BITMAP *bmp), +{ + __asm__ volatile ( + " call *%1 " + : + : "d" (bmp), /* bitmap in edx */ + "r" (bmp->vtable->unwrite_bank) /* the bank switch routine */ + ); +}) + +#endif /* ALLEGRO_IMPORT_GFX_ASM */ + + +#ifdef ALLEGRO_IMPORT_MATH_ASM + +/* Helper macro that makes the compiler reduce fixadd(), fixsub(), fixmul() and + fixdiv() calls to a single constant if both operands are constant. Since + this doesn't work unless we compile with optimization, it's better to skip + the test then. */ +#if (defined __OPTIMIZE__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 95))) + #define __PRECALCULATE_CONSTANTS(calc) \ + if(__builtin_constant_p(x) && __builtin_constant_p(y)) { \ + if((calc) > (double)0x7FFFFFFF) { \ + *allegro_errno = ERANGE; \ + return 0x7FFFFFFF; \ + } \ + else if(-(calc) > (double)0x7FFFFFFF) { \ + *allegro_errno = ERANGE; \ + return -0x7FFFFFFF; \ + } \ + else \ + return (fixed)(calc); \ + } \ + else +#else + #define __PRECALCULATE_CONSTANTS(calc) +#endif + + + +/* fixadd: + * Fixed point (16.16) addition. + */ +AL_INLINE(fixed, fixadd, (fixed x, fixed y), +{ + fixed result; + + __PRECALCULATE_CONSTANTS(x + (double)y) + { + __asm__ ( + " addl %2, %0 ; " /* do the addition */ + " jno 0f ; " /* check for overflow */ + + " movl %4, %0 ; " /* on overflow, set errno */ + " movl %3, (%0) ; " + " movl $0x7FFFFFFF, %0 ; " /* and return MAXINT */ + " cmpl $0, %2 ; " + " jg 0f ; " + " negl %0 ; " + + " 0: " /* finished */ + + : "=r" (result) /* result in a register */ + + : "0" (x), /* x in the output register */ + "rm" (y), /* y can go in register or memory */ + "i" (ERANGE), + "m" (allegro_errno) + + : "%cc", "memory" /* clobbers flags and errno */ + ); + + return result; + } +}) + + + +/* fixsub: + * Fixed point (16.16) subtraction. + */ +AL_INLINE(fixed, fixsub, (fixed x, fixed y), +{ + fixed result; + + __PRECALCULATE_CONSTANTS(x - (double)y) + { + __asm__ ( + " subl %2, %0 ; " /* do the subtraction */ + " jno 0f ; " /* check for overflow */ + + " movl %4, %0 ; " /* on overflow, set errno */ + " movl %3, (%0) ; " + " movl $0x7FFFFFFF, %0 ; " /* and return MAXINT */ + " cmpl $0, %2 ; " + " jl 0f ; " + " negl %0 ; " + + " 0: " /* finished */ + + : "=r" (result) /* result in a register */ + + : "0" (x), /* x in the output register */ + "rm" (y), /* y can go in register or memory */ + "i" (ERANGE), + "m" (allegro_errno) + + : "%cc", "memory" /* clobbers flags and errno */ + ); + + return result; + } +}) + + + +/* fixmul: + * Fixed point (16.16) multiplication. + */ +AL_INLINE(fixed, fixmul, (fixed x, fixed y), +{ + fixed edx __attribute__ ((__unused__)); + fixed result; + + __PRECALCULATE_CONSTANTS(x / 65536.0 * y) + { + __asm__ ( + " movl %2, %%eax ; " + " imull %3 ; " /* do the multiply */ + " shrdl $16, %%edx, %%eax ; " + + " sarl $15, %%edx ; " /* check for overflow */ + " jz 0f ; " + " cmpl $-1, %%edx ; " + " je 0f ; " + + " movl %5, %%eax ; " /* on overflow, set errno */ + " movl %4, (%%eax) ; " + " movl $0x7FFFFFFF, %%eax ; " /* and return MAXINT */ + " cmpl $0, %2 ; " + " jge 1f ; " + " negl %%eax ; " + " 1: " + " cmpl $0, %3 ; " + " jge 0f ; " + " negl %%eax ; " + + " .balign 4, 0x90 ; " + + " 0: " /* finished */ + + : "=&a" (result), /* the result has to go in eax */ + "=&d" (edx) /* reliably reserve edx */ + + : "mr" (x), /* x and y can be regs or mem */ + "mr" (y), + "i" (ERANGE), + "m" (allegro_errno) + + : "%cc", "memory" /* clobbers flags and errno */ + ); + + return result; + } +}) + + + +/* fixdiv: + * Fixed point (16.16) division. + */ +AL_INLINE(fixed, fixdiv, (fixed x, fixed y), +{ + fixed edx __attribute__ ((__unused__)); + fixed reg __attribute__ ((__unused__)); + fixed result; + + __PRECALCULATE_CONSTANTS(x * 65536.0 / y) + { + __asm__ ( + " testl %%eax, %%eax ; " /* test sign of x */ + " js 3f ; " + + " testl %2, %2 ; " /* test sign of y */ + " jns 4f ; " + " negl %2 ; " + + " 0: " /* result will be negative */ + " movl %%eax, %%edx ; " /* check the range is ok */ + " shrl $16, %%edx ; " + " shll $16, %%eax ; " + " cmpl %2, %%edx ; " + " jae 1f ; " + + " divl %2 ; " /* do the divide */ + " testl %%eax, %%eax ; " + " jns 2f ; " + + " 1: " + " movl %6, %%eax ; " /* on overflow, set errno */ + " movl %5, (%%eax) ; " + " movl $0x7FFFFFFF, %%eax ; " /* and return MAXINT */ + + " 2: " + " negl %%eax ; " /* fix up the sign of the result */ + " jmp 6f ; " + + " .balign 4, 0x90 ; " + + " 3: " /* x is negative */ + " negl %%eax ; " + " testl %2, %2 ; " /* test sign of y */ + " jns 0b ; " + " negl %2 ; " + + " 4: " /* result will be positive */ + " movl %%eax, %%edx ; " /* check the range is ok */ + " shrl $16, %%edx ; " + " shll $16, %%eax ; " + " cmpl %2, %%edx ; " + " jae 5f ; " + + " divl %2 ; " /* do the divide */ + " testl %%eax, %%eax ; " + " jns 6f ; " + + " 5: " + " movl %6, %%eax ; " /* on overflow, set errno */ + " movl %5, (%%eax) ; " + " movl $0x7FFFFFFF, %%eax ; " /* and return MAXINT */ + + " 6: " /* finished */ + + : "=a" (result), /* the result has to go in eax */ + "=&d" (edx), /* reliably reserve edx */ + "=r" (reg) /* input operand will be clobbered */ + + : "0" (x), /* x in eax */ + "2" (y), /* y in register */ + "i" (ERANGE), + "m" (allegro_errno) + + : "%cc", "memory" /* clobbers flags and memory */ + ); + + return result; + } +}) + + + +/* fixfloor: + * Fixed point version of floor(). + * Note that it returns an integer result (not a fixed one) + */ +AL_INLINE(int, fixfloor, (fixed x), +{ + int result; + + __asm__ ( + " sarl $16, %0 " /* convert to int */ + + : "=r" (result) /* result in a register */ + + : "0" (x) /* x in the output register */ + ); + + return result; +}) + + + +/* fixceil: + * Fixed point version of ceil(). + * Note that it returns an integer result (not a fixed one) + */ +AL_INLINE(int, fixceil, (fixed x), +{ + int result; + + __asm__ ( + " addl $0xFFFF, %0 ;" /* ceil () */ + " jns 0f ;" + " jo 1f ;" + + "0:" + " sarl $16, %0 ;" /* convert to int */ + " jmp 2f ;" + + "1:" + " movl %3, %0 ;" /* on overflow, set errno */ + " movl %2, (%0) ;" + " movl $0x7FFF, %0 ;" /* and return large int */ + + "2:" + : "=r" (result) /* result in a register */ + + : "0" (x), /* x in the output register */ + "i" (ERANGE), + "m" (allegro_errno) + + : "%cc", "memory" /* clobbers flags and errno */ + ); + + return result; +}) + + + +#undef __PRECALCULATE_CONSTANTS + +#endif /* ALLEGRO_IMPORT_MATH_ASM */ + diff --git a/lib/allegro/include/allegro/platform/al386vc.h b/lib/allegro/include/allegro/platform/al386vc.h new file mode 100644 index 0000000..63e75b0 --- /dev/null +++ b/lib/allegro/include/allegro/platform/al386vc.h @@ -0,0 +1,269 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Inline functions (MSVC style 386 asm). + * + * By Stefan Schimanski. + * + * See readme.txt for copyright information. + */ + + +#if (!defined ALLEGRO_MSVC) || (!defined ALLEGRO_I386) + #error bad include +#endif + + +#pragma warning (disable: 4035) + + +#ifdef ALLEGRO_IMPORT_GFX_ASM + +/* _default_ds: + * Return a copy of the current %ds selector. + */ +INLINE _AL_DLL int _default_ds(void) +{ + _asm { + mov eax, 0 + mov ax, ds + } +} + +END_OF_INLINE(_default_ds); + + + +/* bmp_write_line: + * Bank switch function. + */ +INLINE _AL_DLL uintptr_t bmp_write_line(BITMAP *bmp, int lyne) +{ + _asm { + mov edx, bmp + mov ecx, [edx]BITMAP.write_bank + mov eax, lyne + call ecx + } +} + +END_OF_INLINE(bmp_write_line); + + + +/* bmp_read_line: + * Bank switch function. + */ +INLINE _AL_DLL uintptr_t bmp_read_line(BITMAP *bmp, int lyne) +{ + _asm { + mov edx, bmp + mov ecx, [edx]BITMAP.read_bank + mov eax, lyne + call ecx + } +} + +END_OF_INLINE(bmp_read_line); + + + +/* bmp_unwrite_line: + * Terminate bank switch function. + */ +INLINE _AL_DLL void bmp_unwrite_line(BITMAP *bmp) +{ + _asm { + mov edx, bmp + mov ecx, [edx]BITMAP.vtable + mov ecx, [ecx]GFX_VTABLE.unwrite_bank + call ecx + } +} + +END_OF_INLINE(bmp_unwrite_line); + + +#endif /* ALLEGRO_IMPORT_GFX_ASM */ + + +#ifdef ALLEGRO_IMPORT_MATH_ASM + +/* _set_errno_erange: + */ +INLINE void _set_errno_erange(void) +{ + *allegro_errno = ERANGE; +} + +END_OF_INLINE(_set_errno_erange); + + + +/* fixadd: + * Fixed point (16.16) addition. + */ +INLINE _AL_DLL fixed fixadd(fixed x, fixed y) +{ + _asm { + mov eax, x + add eax, y + jno Out1 + call _set_errno_erange + mov eax, 0x7FFFFFFF + cmp y, 0 + jg Out1 + neg eax + Out1: + } +} + +END_OF_INLINE(fixadd); + + + +/* fixsub: + * Fixed point (16.16) subtraction. + */ +INLINE _AL_DLL fixed fixsub(fixed x, fixed y) +{ + _asm { + mov eax, x + sub eax, y + jno Out1 + call _set_errno_erange + mov eax, 0x7FFFFFFF + cmp y, 0 + jl Out1 + neg eax + Out1: + } +} + +END_OF_INLINE(fixsub); + + + +/* fixmul: + * Fixed point (16.16) multiplication. + */ +INLINE _AL_DLL fixed fixmul(fixed x, fixed y) +{ + _asm { + mov eax, x + imul y + shrd eax, edx, 16 + sar edx, 15 + jz Out2 + cmp edx, -1 + jz Out2 + call _set_errno_erange + mov eax, 0x7FFFFFFF + cmp x, 0 + jge Out1 + neg eax + Out1: + cmp y, 0 + jge Out2 + neg eax + Out2: + } +} + +END_OF_INLINE(fixmul); + + + +/* fixdiv: + * Fixed point (16.16) division. + */ +INLINE _AL_DLL fixed fixdiv(fixed x, fixed y) +{ + _asm { + mov ecx, y + xor ebx, ebx + mov eax, x + or eax, eax + jns Out1 + neg eax + inc ebx + Out1: + or ecx, ecx + jns Out2 + neg ecx + inc ebx + Out2: + mov edx, eax + shr edx, 0x10 + shl eax, 0x10 + cmp edx, ecx + jae Out3 + div ecx + or eax, eax + jns Out4 + Out3: + call _set_errno_erange + mov eax, 0x7FFFFFFF + Out4: + test ebx, 1 + je Out5 + neg eax + Out5: + } +} + +END_OF_INLINE(fixdiv); + + + +/* fixfloor : + * Fixed point version of floor(). + * Note that it returns an integer result (not a fixed one) + */ +INLINE _AL_DLL int fixfloor(fixed x) +{ + _asm { + mov eax, x + sar eax, 0x10 + } +} + +END_OF_INLINE(fixfloor); + + + +/* fixceil: + * Fixed point version of ceil(). + * Note that it returns an integer result (not a fixed one) + */ +INLINE _AL_DLL int fixceil(fixed x) +{ + _asm { + mov eax, x + add eax, 0xFFFF + jns Out1 + jo Out2 + Out1: + sar eax, 0x10 + jmp Out3 + Out2: + call _set_errno_erange + mov eax, 0x7FFF + Out3: + } +} + +END_OF_INLINE(fixceil); + +#endif /* ALLEGRO_IMPORT_MATH_ASM */ + + +#pragma warning (default: 4035) + diff --git a/lib/allegro/include/allegro/platform/al386wat.h b/lib/allegro/include/allegro/platform/al386wat.h new file mode 100644 index 0000000..1647744 --- /dev/null +++ b/lib/allegro/include/allegro/platform/al386wat.h @@ -0,0 +1,241 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Inline functions (Watcom style 386 asm). + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#if (!defined ALLEGRO_WATCOM) || (!defined ALLEGRO_I386) + #error bad include +#endif + + +#ifdef ALLEGRO_IMPORT_GFX_ASM + +/* _default_ds: + * Return a copy of the current %ds selector. + */ +int _default_ds(void); + +#pragma aux _default_ds = \ + " mov eax, 0 " \ + " mov ax, ds " \ + \ + value [eax]; + + + +/* _my_cs: + * Return a copy of the current %cs selector. + */ +int _my_cs(void); + +#pragma aux _my_cs = \ + " mov eax, 0 " \ + " mov ax, cs " \ + \ + value [eax]; + + + +/* bmp_write_line/bmp_read_line: + * Bank switch functions. + */ +uintptr_t _bmp_bank_switcher(BITMAP *bmp, int lyne, void *bank_switch); + +#pragma aux _bmp_bank_switcher = \ + " call ecx " \ + \ + parm [edx] [eax] [ecx] \ + value [eax]; + +#define bmp_write_line(bmp, lyne) _bmp_bank_switcher(bmp, lyne, (void *)bmp->write_bank) +#define bmp_read_line(bmp, lyne) _bmp_bank_switcher(bmp, lyne, (void *)bmp->read_bank) + + + +/* bmp_unwrite_line: + * Terminate bank switch function. + */ +void _bmp_unbank_switcher(BITMAP *bmp, void *bank_unswitcher); + +#pragma aux _bmp_unbank_switcher = \ + " call ecx " \ + \ + parm [edx] [ecx]; + +#define bmp_unwrite_line(bmp) _bmp_unbank_switcher(bmp, (void *)bmp->vtable->unwrite_bank) + +#endif /* ALLEGRO_IMPORT_GFX_ASM */ + + +#ifdef ALLEGRO_IMPORT_MATH_ASM + +/* _set_errno_erange: + * Watcom's asm syntax doesn't provide any nice way to do this inline... + */ +AL_INLINE(void, _set_errno_erange, (void), +{ + *allegro_errno = ERANGE; +}) + + + +/* fixadd: + * Fixed point (16.16) addition. + */ +fixed fixadd(fixed x, fixed y); + +#pragma aux fixadd = \ + " add eax, edx " \ + " jno Out1 " \ + " call _set_errno_erange " \ + " mov eax, 0x7FFFFFFF " \ + " cmp edx, 0 " \ + " jg Out1 " \ + " neg eax " \ + " Out1: " \ + \ + parm [eax] [edx] \ + value [eax]; + + + +/* fixsub: + * Fixed point (16.16) subtraction. + */ +fixed fixsub(fixed x, fixed y); + +#pragma aux fixsub = \ + " sub eax, edx " \ + " jno Out1 " \ + " call _set_errno_erange " \ + " mov eax, 0x7FFFFFFF " \ + " cmp edx, 0 " \ + " jl Out1 " \ + " neg eax " \ + " Out1: " \ + \ + parm [eax] [edx] \ + value [eax]; + + + +/* fixmul: + * Fixed point (16.16) multiplication. + */ +fixed fixmul(fixed x, fixed y); + +#pragma aux fixmul = \ + " mov eax, ebx " \ + " imul ecx " \ + " shrd eax, edx, 16 " \ + " sar edx, 15 " \ + " jz Out2 " \ + " cmp edx, -1 " \ + " jz Out2 " \ + " call _set_errno_erange " \ + " mov eax, 0x7FFFFFFF " \ + " cmp ebx, 0 " \ + " jge Out1 " \ + " neg eax " \ + " Out1: " \ + " cmp ecx, 0 " \ + " jge Out2 " \ + " neg eax " \ + " Out2: " \ + \ + parm [ebx] [ecx] \ + modify [edx] \ + value [eax]; + + + +/* fixdiv: + * Fixed point (16.16) division. + */ +fixed fixdiv(fixed x, fixed y); + +#pragma aux fixdiv = \ + " xor ebx, ebx " \ + " or eax, eax " \ + " jns Out1 " \ + " neg eax " \ + " inc ebx " \ + " Out1: " \ + " or ecx, ecx " \ + " jns Out2 " \ + " neg ecx " \ + " inc ebx " \ + " Out2: " \ + " mov edx, eax " \ + " shr edx, 0x10 " \ + " shl eax, 0x10 " \ + " cmp edx, ecx " \ + " jae Out3 " \ + " div ecx " \ + " or eax, eax " \ + " jns Out4 " \ + " Out3: " \ + " call _set_errno_erange " \ + " mov eax, 0x7FFFFFFF " \ + " Out4: " \ + " test ebx, 1 " \ + " je Out5 " \ + " neg eax " \ + " Out5: " \ + \ + parm [eax] [ecx] \ + modify [ebx edx] \ + value [eax]; + + + +/* fixfloor : + * Fixed point version of floor(). + * Note that it returns an integer result (not a fixed one) + */ +int fixfloor(fixed x); + +#pragma aux fixfloor = \ + " sar eax, 0x10 " \ + \ + parm [eax] \ + value [eax]; + + + +/* fixceil : + * Fixed point version of ceil(). + * Note that it returns an integer result (not a fixed one) + */ +int fixceil(fixed x); + +#pragma aux fixceil = \ + " add eax, 0xFFFF " \ + " jns Out1 " \ + " jo Out2 " \ + " Out1: " \ + " sar eax, 0x10 " \ + " jmp Out3 " \ + " Out2: " \ + " call _set_errno_erange " \ + " mov eax, 0x7FFF " \ + " Out3: " \ + \ + parm [eax] \ + value [eax]; + +#endif /* ALLEGRO_IMPORT_MATH_ASM */ + diff --git a/lib/allegro/include/allegro/platform/albcc32.h b/lib/allegro/include/allegro/platform/albcc32.h new file mode 100644 index 0000000..f28c1a4 --- /dev/null +++ b/lib/allegro/include/allegro/platform/albcc32.h @@ -0,0 +1,85 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with Borland C++Builder. + * + * By Greg Hackmann. + * + * See readme.txt for copyright information. + */ + + +#ifdef ALLEGRO_SRC + #error Currently BCC32 cannot build the library +#endif + +#ifndef SCAN_DEPEND + #include + #include + #include + #include +#endif + + +#pragma warn -8004 /* unused assigned value */ +#pragma warn -8008 /* condition always met */ +#pragma warn -8057 /* unused parameter */ +#pragma warn -8066 /* unreachable code */ + + +/* describe this platform */ +#define ALLEGRO_PLATFORM_STR "BCC32" +#define ALLEGRO_WINDOWS +#define ALLEGRO_I386 +#define ALLEGRO_LITTLE_ENDIAN +#define ALLEGRO_GUESS_INTTYPES_OK + /* TODO: check if BCC has inttypes.h and/or stdint.h */ +#define ALLEGRO_MULTITHREADED + +#ifdef ALLEGRO_USE_CONSOLE + #define ALLEGRO_CONSOLE_OK + #define ALLEGRO_NO_MAGIC_MAIN +#endif + + +/* describe how function prototypes look to BCC32 */ +#if (defined ALLEGRO_STATICLINK) || (defined ALLEGRO_SRC) + #define _AL_DLL +#else + #define _AL_DLL __declspec(dllimport) +#endif + +#define AL_VAR(type, name) extern _AL_DLL type name +#define AL_ARRAY(type, name) extern _AL_DLL type name[] +#define AL_FUNC(type, name, args) _AL_DLL type __cdecl name args +#define AL_METHOD(type, name, args) type (__cdecl *name) args +#define AL_FUNCPTR(type, name, args) extern _AL_DLL type (__cdecl *name) args + + +#define END_OF_INLINE(name) +#define AL_INLINE(type, name, args, code) extern __inline type __cdecl name args code END_OF_INLINE(name) + +#define INLINE __inline + +#define LONG_LONG __int64 +#define int64_t signed __int64 +#define uint64_t unsigned __int64 + +#define AL_CONST const + +/* windows specific defines */ +#ifdef NONAMELESSUNION + #undef NONAMELESSUNION +#endif +/* This fixes 99.999999% of Borland C++Builder's problems with structs. */ + +/* arrange for other headers to be included later on */ +#define ALLEGRO_EXTRA_HEADER "allegro/platform/alwin.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintwin.h" diff --git a/lib/allegro/include/allegro/platform/albecfg.h b/lib/allegro/include/allegro/platform/albecfg.h new file mode 100644 index 0000000..c6dc39f --- /dev/null +++ b/lib/allegro/include/allegro/platform/albecfg.h @@ -0,0 +1,45 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with BeOS. + * + * By Jason Wilkins. + * + * See readme.txt for copyright information. + */ + + +#include +#include + +/* provide implementations of missing functions */ +#define ALLEGRO_NO_STRICMP +#define ALLEGRO_NO_STRLWR +#define ALLEGRO_NO_STRUPR + +/* a static auto config */ +#define HAVE_DIRENT_H +#define HAVE_INTTYPES_H /* TODO: check this */ +#define HAVE_STDINT_H /* TODO: check this */ +#define HAVE_SYS_DIR_H +#define HAVE_SYS_TIME_H +#define TIME_WITH_SYS_TIME + +/* describe this platform */ +#define ALLEGRO_PLATFORM_STR "BeOS" +#define ALLEGRO_LITTLE_ENDIAN +#define ALLEGRO_CONSOLE_OK +#define ALLEGRO_USE_CONSTRUCTOR +#define ALLEGRO_MULTITHREADED + +/* arrange for other headers to be included later on */ +#define ALLEGRO_EXTRA_HEADER "allegro/platform/albeos.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintbeos.h" +#define ALLEGRO_ASMCAPA_HEADER "obj/beos/asmcapa.h" diff --git a/lib/allegro/include/allegro/platform/albeos.h b/lib/allegro/include/allegro/platform/albeos.h new file mode 100644 index 0000000..9af2dbf --- /dev/null +++ b/lib/allegro/include/allegro/platform/albeos.h @@ -0,0 +1,76 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * BeOS specific definitions header file. + * + * By Jason Wilkins. + * + * See readme.txt for copyright information. + */ + + +/* system driver */ +#define SYSTEM_BEOS AL_ID('B','S','Y','S') +AL_VAR(SYSTEM_DRIVER, system_beos); + +/* timer driver */ +#define TIMER_BEOS AL_ID('B','T','I','M') +AL_VAR(TIMER_DRIVER, timer_beos); + +/* keyboard driver */ +#define KEYBOARD_BEOS AL_ID('B','K','E','Y') +AL_VAR(KEYBOARD_DRIVER, keyboard_beos); + +/* mouse driver */ +#define MOUSE_BEOS AL_ID('B','M','O','U') +AL_VAR(MOUSE_DRIVER, mouse_beos); + +/* joystick driver */ +#define JOYSTICK_BEOS AL_ID('B','J','O','Y') +AL_VAR(JOYSTICK_DRIVER, joystick_beos); + +/* graphics drivers */ +#define GFX_BWINDOWSCREEN_ACCEL AL_ID('B','W','S','A') +#define GFX_BWINDOWSCREEN AL_ID('B','W','S',' ') +AL_VAR(GFX_DRIVER, gfx_beos_bwindowscreen_accel); +AL_VAR(GFX_DRIVER, gfx_beos_bwindowscreen); + +#define GFX_BDIRECTWINDOW AL_ID('B','D','W','N') +#define GFX_BWINDOW AL_ID('B','W','N',' ') +AL_VAR(GFX_DRIVER, gfx_beos_bdirectwindow); +AL_VAR(GFX_DRIVER, gfx_beos_bwindow); + +#define GFX_BWINDOW_OVERLAY AL_ID('B','O','V','L') +AL_VAR(GFX_DRIVER, gfx_beos_overlay); + +/* digi drivers */ +#define DIGI_BEOS AL_ID('B','D','I','G') +AL_VAR(DIGI_DRIVER, digi_beos); + +/* midi drivers */ +#define MIDI_BEOS AL_ID('B','M','I','D') +AL_VAR(MIDI_DRIVER, midi_beos); + +#define GFX_DRIVER_BEOS \ + { GFX_BWINDOWSCREEN_ACCEL, &gfx_beos_bwindowscreen_accel, TRUE }, \ + { GFX_BWINDOWSCREEN, &gfx_beos_bwindowscreen, TRUE }, \ + { GFX_BDIRECTWINDOW, &gfx_beos_bdirectwindow, TRUE }, \ + { GFX_BWINDOW, &gfx_beos_bwindow, TRUE }, \ + { GFX_BWINDOW_OVERLAY, &gfx_beos_overlay, TRUE }, + +#define DIGI_DRIVER_BEOS \ + { DIGI_BEOS, &digi_beos, TRUE }, + +#define MIDI_DRIVER_BEOS \ + { MIDI_BEOS, &midi_beos, TRUE }, + +#define JOYSTICK_DRIVER_BEOS \ + { JOYSTICK_BEOS, &joystick_beos, TRUE }, + diff --git a/lib/allegro/include/allegro/platform/aldjgpp.h b/lib/allegro/include/allegro/platform/aldjgpp.h new file mode 100644 index 0000000..a9ea3f9 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aldjgpp.h @@ -0,0 +1,99 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with djgpp. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef SCAN_DEPEND + #include + #include + #include + #include + #include + #include + #include +#endif + + +/* describe this platform */ +#define ALLEGRO_PLATFORM_STR "djgpp" +#define ALLEGRO_DOS +#define ALLEGRO_I386 +#define ALLEGRO_LITTLE_ENDIAN +#define ALLEGRO_GUESS_INTTYPES_OK + /* inttypes.h and stdint.h not available in djgpp 2.02 */ +#define ALLEGRO_CONSOLE_OK +#define ALLEGRO_VRAM_SINGLE_SURFACE +#define ALLEGRO_USE_CONSTRUCTOR + + +#ifdef __cplusplus +extern "C" { +#endif + +/* memory locking macros */ +void _unlock_dpmi_data(void *addr, int size); + +#define END_OF_FUNCTION(x) void x##_end(void) { } +#define END_OF_STATIC_FUNCTION(x) static void x##_end(void) { } +#define LOCK_DATA(d, s) _go32_dpmi_lock_data((void *)d, s) +#define LOCK_CODE(c, s) _go32_dpmi_lock_code((void *)c, s) +#define UNLOCK_DATA(d,s) _unlock_dpmi_data((void *)d, s) +#define LOCK_VARIABLE(x) LOCK_DATA((void *)&x, sizeof(x)) +#define LOCK_FUNCTION(x) LOCK_CODE((void *)x, (intptr_t)x##_end - (intptr_t)x) + + +/* long filename status */ +#ifdef _USE_LFN + #define ALLEGRO_LFN _USE_LFN +#else + #define ALLEGRO_LFN 0 +#endif + + +/* selector for video memory bitmaps */ +#define _video_ds() _dos_ds + + +/* helpers for talking to video memory */ +#define bmp_select(bmp) _farsetsel((bmp)->seg) + +#define bmp_write8(addr, c) _farnspokeb(addr, c) +#define bmp_write15(addr, c) _farnspokew(addr, c) +#define bmp_write16(addr, c) _farnspokew(addr, c) +#define bmp_write24(addr, c) ({ _farnspokew(addr, c&0xFFFF); \ + _farnspokeb(addr+2, c>>16); }) +#define bmp_write32(addr, c) _farnspokel(addr, c) + +#define bmp_read8(addr) _farnspeekb(addr) +#define bmp_read15(addr) _farnspeekw(addr) +#define bmp_read16(addr) _farnspeekw(addr) +#define bmp_read32(addr) _farnspeekl(addr) +#define bmp_read24(addr) (_farnspeekl(addr) & 0xFFFFFF) + +#ifdef __cplusplus +} +#endif + + +/* describe the asm syntax for this platform */ +#define ALLEGRO_ASM_PREFIX "_" +#define ALLEGRO_ASM_USE_FS + + +/* arrange for other headers to be included later on */ +#define ALLEGRO_EXTRA_HEADER "allegro/platform/aldos.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintdos.h" +#define ALLEGRO_ASMCAPA_HEADER "obj/djgpp/asmcapa.h" diff --git a/lib/allegro/include/allegro/platform/aldos.h b/lib/allegro/include/allegro/platform/aldos.h new file mode 100644 index 0000000..3f16d15 --- /dev/null +++ b/lib/allegro/include/allegro/platform/aldos.h @@ -0,0 +1,354 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * DOS-specific header defines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_DOS + #error bad include +#endif + + +/********************************************/ +/************ Platform-specifics ************/ +/********************************************/ + +#define SYSTEM_DOS AL_ID('D','O','S',' ') + +AL_VAR(SYSTEM_DRIVER, system_dos); + +AL_VAR(int, i_love_bill); + + +#define KEYDRV_PCDOS AL_ID('P','C','K','B') + +AL_VAR(KEYBOARD_DRIVER, keydrv_pcdos); + + +#define TIMEDRV_FIXED_RATE AL_ID('F','I','X','T') +#define TIMEDRV_VARIABLE_RATE AL_ID('V','A','R','T') + +AL_VAR(TIMER_DRIVER, timedrv_fixed_rate); +AL_VAR(TIMER_DRIVER, timedrv_variable_rate); + + +#define MOUSEDRV_MICKEYS AL_ID('M','I','C','K') +#define MOUSEDRV_INT33 AL_ID('I','3','3',' ') +#define MOUSEDRV_POLLING AL_ID('P','O','L','L') +#define MOUSEDRV_WINNT AL_ID('W','N','T',' ') +#define MOUSEDRV_WIN2K AL_ID('W','2','K',' ') + +AL_VAR(MOUSE_DRIVER, mousedrv_mickeys); +AL_VAR(MOUSE_DRIVER, mousedrv_int33); +AL_VAR(MOUSE_DRIVER, mousedrv_polling); +AL_VAR(MOUSE_DRIVER, mousedrv_winnt); +AL_VAR(MOUSE_DRIVER, mousedrv_win2k); + + + +/*******************************************/ +/************ Joystick routines ************/ +/*******************************************/ + +#define JOY_TYPE_STANDARD AL_ID('S','T','D',' ') +#define JOY_TYPE_2PADS AL_ID('2','P','A','D') +#define JOY_TYPE_4BUTTON AL_ID('4','B','U','T') +#define JOY_TYPE_6BUTTON AL_ID('6','B','U','T') +#define JOY_TYPE_8BUTTON AL_ID('8','B','U','T') +#define JOY_TYPE_FSPRO AL_ID('F','P','R','O') +#define JOY_TYPE_WINGEX AL_ID('W','I','N','G') +#define JOY_TYPE_SIDEWINDER AL_ID('S','W',' ',' ') +#define JOY_TYPE_SIDEWINDER_AG AL_ID('S','W','A','G') +#define JOY_TYPE_SIDEWINDER_PP AL_ID('S','W','P','P') +#define JOY_TYPE_GAMEPAD_PRO AL_ID('G','P','R','O') +#define JOY_TYPE_GRIP AL_ID('G','R','I','P') +#define JOY_TYPE_GRIP4 AL_ID('G','R','I','4') +#define JOY_TYPE_SNESPAD_LPT1 AL_ID('S','N','E','1') +#define JOY_TYPE_SNESPAD_LPT2 AL_ID('S','N','E','2') +#define JOY_TYPE_SNESPAD_LPT3 AL_ID('S','N','E','3') +#define JOY_TYPE_PSXPAD_LPT1 AL_ID('P','S','X','1') +#define JOY_TYPE_PSXPAD_LPT2 AL_ID('P','S','X','2') +#define JOY_TYPE_PSXPAD_LPT3 AL_ID('P','S','X','3') +#define JOY_TYPE_N64PAD_LPT1 AL_ID('N','6','4','1') +#define JOY_TYPE_N64PAD_LPT2 AL_ID('N','6','4','2') +#define JOY_TYPE_N64PAD_LPT3 AL_ID('N','6','4','3') +#define JOY_TYPE_DB9_LPT1 AL_ID('D','B','9','1') +#define JOY_TYPE_DB9_LPT2 AL_ID('D','B','9','2') +#define JOY_TYPE_DB9_LPT3 AL_ID('D','B','9','3') +#define JOY_TYPE_TURBOGRAFX_LPT1 AL_ID('T','G','X','1') +#define JOY_TYPE_TURBOGRAFX_LPT2 AL_ID('T','G','X','2') +#define JOY_TYPE_TURBOGRAFX_LPT3 AL_ID('T','G','X','3') +#define JOY_TYPE_IFSEGA_ISA AL_ID('S','E','G','I') +#define JOY_TYPE_IFSEGA_PCI AL_ID('S','E','G','P') +#define JOY_TYPE_IFSEGA_PCI_FAST AL_ID('S','G','P','F') +#define JOY_TYPE_WINGWARRIOR AL_ID('W','W','A','R') + + +AL_VAR(JOYSTICK_DRIVER, joystick_standard); +AL_VAR(JOYSTICK_DRIVER, joystick_2pads); +AL_VAR(JOYSTICK_DRIVER, joystick_4button); +AL_VAR(JOYSTICK_DRIVER, joystick_6button); +AL_VAR(JOYSTICK_DRIVER, joystick_8button); +AL_VAR(JOYSTICK_DRIVER, joystick_fspro); +AL_VAR(JOYSTICK_DRIVER, joystick_wingex); +AL_VAR(JOYSTICK_DRIVER, joystick_sw); +AL_VAR(JOYSTICK_DRIVER, joystick_sw_ag); +AL_VAR(JOYSTICK_DRIVER, joystick_sw_pp); +AL_VAR(JOYSTICK_DRIVER, joystick_gpro); +AL_VAR(JOYSTICK_DRIVER, joystick_grip); +AL_VAR(JOYSTICK_DRIVER, joystick_grip4); +AL_VAR(JOYSTICK_DRIVER, joystick_sp1); +AL_VAR(JOYSTICK_DRIVER, joystick_sp2); +AL_VAR(JOYSTICK_DRIVER, joystick_sp3); +AL_VAR(JOYSTICK_DRIVER, joystick_psx1); +AL_VAR(JOYSTICK_DRIVER, joystick_psx2); +AL_VAR(JOYSTICK_DRIVER, joystick_psx3); +AL_VAR(JOYSTICK_DRIVER, joystick_n641); +AL_VAR(JOYSTICK_DRIVER, joystick_n642); +AL_VAR(JOYSTICK_DRIVER, joystick_n643); +AL_VAR(JOYSTICK_DRIVER, joystick_db91); +AL_VAR(JOYSTICK_DRIVER, joystick_db92); +AL_VAR(JOYSTICK_DRIVER, joystick_db93); +AL_VAR(JOYSTICK_DRIVER, joystick_tgx1); +AL_VAR(JOYSTICK_DRIVER, joystick_tgx2); +AL_VAR(JOYSTICK_DRIVER, joystick_tgx3); +AL_VAR(JOYSTICK_DRIVER, joystick_sg1); +AL_VAR(JOYSTICK_DRIVER, joystick_sg2); +AL_VAR(JOYSTICK_DRIVER, joystick_sg2f); +AL_VAR(JOYSTICK_DRIVER, joystick_ww); + + +#define JOYSTICK_DRIVER_STANDARD \ + { JOY_TYPE_STANDARD, &joystick_standard, TRUE }, \ + { JOY_TYPE_2PADS, &joystick_2pads, FALSE }, \ + { JOY_TYPE_4BUTTON, &joystick_4button, FALSE }, \ + { JOY_TYPE_6BUTTON, &joystick_6button, FALSE }, \ + { JOY_TYPE_8BUTTON, &joystick_8button, FALSE }, \ + { JOY_TYPE_FSPRO, &joystick_fspro, FALSE }, \ + { JOY_TYPE_WINGEX, &joystick_wingex, FALSE }, + +#define JOYSTICK_DRIVER_SIDEWINDER \ + { JOY_TYPE_SIDEWINDER, &joystick_sw, TRUE }, \ + { JOY_TYPE_SIDEWINDER_AG, &joystick_sw_ag, TRUE }, \ + { JOY_TYPE_SIDEWINDER_PP, &joystick_sw_pp, TRUE }, + +#define JOYSTICK_DRIVER_GAMEPAD_PRO \ + { JOY_TYPE_GAMEPAD_PRO, &joystick_gpro, TRUE }, + +#define JOYSTICK_DRIVER_GRIP \ + { JOY_TYPE_GRIP, &joystick_grip, TRUE }, \ + { JOY_TYPE_GRIP4, &joystick_grip4, TRUE }, + +#define JOYSTICK_DRIVER_SNESPAD \ + { JOY_TYPE_SNESPAD_LPT1, &joystick_sp1, FALSE }, \ + { JOY_TYPE_SNESPAD_LPT2, &joystick_sp2, FALSE }, \ + { JOY_TYPE_SNESPAD_LPT3, &joystick_sp3, FALSE }, + +#define JOYSTICK_DRIVER_PSXPAD \ + { JOY_TYPE_PSXPAD_LPT1, &joystick_psx1, FALSE }, \ + { JOY_TYPE_PSXPAD_LPT2, &joystick_psx2, FALSE }, \ + { JOY_TYPE_PSXPAD_LPT3, &joystick_psx3, FALSE }, + +#define JOYSTICK_DRIVER_N64PAD \ + { JOY_TYPE_N64PAD_LPT1, &joystick_n641, FALSE }, \ + { JOY_TYPE_N64PAD_LPT2, &joystick_n642, FALSE }, \ + { JOY_TYPE_N64PAD_LPT3, &joystick_n643, FALSE }, + +#define JOYSTICK_DRIVER_DB9 \ + { JOY_TYPE_DB9_LPT1, &joystick_db91, FALSE }, \ + { JOY_TYPE_DB9_LPT2, &joystick_db92, FALSE }, \ + { JOY_TYPE_DB9_LPT3, &joystick_db93, FALSE }, + +#define JOYSTICK_DRIVER_TURBOGRAFX \ + { JOY_TYPE_TURBOGRAFX_LPT1,&joystick_tgx1, FALSE }, \ + { JOY_TYPE_TURBOGRAFX_LPT2,&joystick_tgx2, FALSE }, \ + { JOY_TYPE_TURBOGRAFX_LPT3,&joystick_tgx3, FALSE }, + +#define JOYSTICK_DRIVER_IFSEGA_ISA \ + { JOY_TYPE_IFSEGA_ISA, &joystick_sg1, FALSE }, + +#define JOYSTICK_DRIVER_IFSEGA_PCI \ + { JOY_TYPE_IFSEGA_PCI, &joystick_sg2, FALSE }, + +#define JOYSTICK_DRIVER_IFSEGA_PCI_FAST \ + { JOY_TYPE_IFSEGA_PCI_FAST,&joystick_sg2f, FALSE }, + +#define JOYSTICK_DRIVER_WINGWARRIOR \ + { JOY_TYPE_WINGWARRIOR, &joystick_ww, TRUE }, + + +#define joy_FSPRO_trigger joy_b1 +#define joy_FSPRO_butleft joy_b2 +#define joy_FSPRO_butright joy_b3 +#define joy_FSPRO_butmiddle joy_b4 + +#define joy_WINGEX_trigger joy_b1 +#define joy_WINGEX_buttop joy_b2 +#define joy_WINGEX_butthumb joy_b3 +#define joy_WINGEX_butmiddle joy_b4 + + +AL_FUNC(int, calibrate_joystick_tl, (void)); +AL_FUNC(int, calibrate_joystick_br, (void)); +AL_FUNC(int, calibrate_joystick_throttle_min, (void)); +AL_FUNC(int, calibrate_joystick_throttle_max, (void)); +AL_FUNC(int, calibrate_joystick_hat, (int direction)); + + + +/*******************************************/ +/************ Graphics routines ************/ +/*******************************************/ + +#define GFX_HAS_VGA +#define GFX_HAS_VBEAF + +#define GFX_VGA AL_ID('V','G','A',' ') +#define GFX_MODEX AL_ID('M','O','D','X') +#define GFX_VESA1 AL_ID('V','B','E','1') +#define GFX_VESA2B AL_ID('V','B','2','B') +#define GFX_VESA2L AL_ID('V','B','2','L') +#define GFX_VESA3 AL_ID('V','B','E','3') +#define GFX_VBEAF AL_ID('V','B','A','F') +#define GFX_XTENDED AL_ID('X','T','N','D') + +AL_VAR(GFX_DRIVER, gfx_vga); +AL_VAR(GFX_DRIVER, gfx_modex); +AL_VAR(GFX_DRIVER, gfx_vesa_1); +AL_VAR(GFX_DRIVER, gfx_vesa_2b); +AL_VAR(GFX_DRIVER, gfx_vesa_2l); +AL_VAR(GFX_DRIVER, gfx_vesa_3); +AL_VAR(GFX_DRIVER, gfx_vbeaf); +AL_VAR(GFX_DRIVER, gfx_xtended); + + +#define GFX_DRIVER_VGA \ + { GFX_VGA, &gfx_vga, TRUE }, + +#define GFX_DRIVER_MODEX \ + { GFX_MODEX, &gfx_modex, TRUE }, + +#define GFX_DRIVER_VBEAF \ + { GFX_VBEAF, &gfx_vbeaf, TRUE }, + +#define GFX_DRIVER_VESA3 \ + { GFX_VESA3, &gfx_vesa_3, TRUE }, + +#define GFX_DRIVER_VESA2L \ + { GFX_VESA2L, &gfx_vesa_2l, TRUE }, + +#define GFX_DRIVER_VESA2B \ + { GFX_VESA2B, &gfx_vesa_2b, TRUE }, + +#define GFX_DRIVER_XTENDED \ + { GFX_XTENDED, &gfx_xtended, FALSE }, + +#define GFX_DRIVER_VESA1 \ + { GFX_VESA1, &gfx_vesa_1, TRUE }, + + +AL_FUNC_DEPRECATED(void, split_modex_screen, (int lyne)); + + +AL_INLINE(void, _set_color, (int index, AL_CONST RGB *p), +{ + outportb(0x3C8, index); + outportb(0x3C9, p->r); + outportb(0x3C9, p->g); + outportb(0x3C9, p->b); + + _current_palette[index] = *p; +}) + + + +/****************************************/ +/************ Sound routines ************/ +/****************************************/ + +#define DIGI_SB10 AL_ID('S','B','1','0') +#define DIGI_SB15 AL_ID('S','B','1','5') +#define DIGI_SB20 AL_ID('S','B','2','0') +#define DIGI_SBPRO AL_ID('S','B','P',' ') +#define DIGI_SB16 AL_ID('S','B','1','6') +#define DIGI_AUDIODRIVE AL_ID('E','S','S',' ') +#define DIGI_SOUNDSCAPE AL_ID('E','S','C',' ') +#define DIGI_WINSOUNDSYS AL_ID('W','S','S',' ') + +#define MIDI_OPL2 AL_ID('O','P','L','2') +#define MIDI_2XOPL2 AL_ID('O','P','L','X') +#define MIDI_OPL3 AL_ID('O','P','L','3') +#define MIDI_SB_OUT AL_ID('S','B',' ',' ') +#define MIDI_MPU AL_ID('M','P','U',' ') +#define MIDI_AWE32 AL_ID('A','W','E',' ') + + +AL_VAR(DIGI_DRIVER, digi_sb10); +AL_VAR(DIGI_DRIVER, digi_sb15); +AL_VAR(DIGI_DRIVER, digi_sb20); +AL_VAR(DIGI_DRIVER, digi_sbpro); +AL_VAR(DIGI_DRIVER, digi_sb16); +AL_VAR(DIGI_DRIVER, digi_audiodrive); +AL_VAR(DIGI_DRIVER, digi_soundscape); +AL_VAR(DIGI_DRIVER, digi_wss); + +AL_VAR(MIDI_DRIVER, midi_opl2); +AL_VAR(MIDI_DRIVER, midi_2xopl2); +AL_VAR(MIDI_DRIVER, midi_opl3); +AL_VAR(MIDI_DRIVER, midi_sb_out); +AL_VAR(MIDI_DRIVER, midi_mpu401); +AL_VAR(MIDI_DRIVER, midi_awe32); + + +#define DIGI_DRIVER_WINSOUNDSYS \ + { DIGI_WINSOUNDSYS, &digi_wss, FALSE }, + +#define DIGI_DRIVER_AUDIODRIVE \ + { DIGI_AUDIODRIVE, &digi_audiodrive, TRUE }, + +#define DIGI_DRIVER_SOUNDSCAPE \ + { DIGI_SOUNDSCAPE, &digi_soundscape, TRUE }, + +#define DIGI_DRIVER_SB \ + { DIGI_SB16, &digi_sb16, TRUE }, \ + { DIGI_SBPRO, &digi_sbpro, TRUE }, \ + { DIGI_SB20, &digi_sb20, TRUE }, \ + { DIGI_SB15, &digi_sb15, TRUE }, \ + { DIGI_SB10, &digi_sb10, TRUE }, + +#define MIDI_DRIVER_AWE32 \ + { MIDI_AWE32, &midi_awe32, TRUE }, + +#define MIDI_DRIVER_ADLIB \ + { MIDI_OPL3, &midi_opl3, TRUE }, \ + { MIDI_2XOPL2, &midi_2xopl2, TRUE }, \ + { MIDI_OPL2, &midi_opl2, TRUE }, + +#define MIDI_DRIVER_SB_OUT \ + { MIDI_SB_OUT, &midi_sb_out, FALSE }, + +#define MIDI_DRIVER_MPU \ + { MIDI_MPU, &midi_mpu401, FALSE }, + + +#ifdef __cplusplus +extern "C" { +#endif + +AL_FUNC(int, load_ibk, (AL_CONST char *filename, int drums)); + +#ifdef __cplusplus +} +#endif diff --git a/lib/allegro/include/allegro/platform/almac.h b/lib/allegro/include/allegro/platform/almac.h new file mode 100644 index 0000000..374601a --- /dev/null +++ b/lib/allegro/include/allegro/platform/almac.h @@ -0,0 +1,68 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Mac-specific header defines. + * + * By Ronaldo Hideki Yamada. + * + * See readme.txt for copyright information. + */ + + +/*******************************************/ +/************* system drivers **************/ +/*******************************************/ +#define SYSTEM_MACOS AL_ID('M','C','O','S') +AL_VAR(SYSTEM_DRIVER, system_macos); + +/*******************************************/ +/************** timer drivers **************/ +/*******************************************/ +#define TIMER_MACOS AL_ID('M','C','O','S') +AL_VAR(TIMER_DRIVER, timer_macos); + +/*******************************************/ +/************ keyboard drivers *************/ +/*******************************************/ +#define KEYBOARD_MACOS AL_ID('M','C','O','S') +AL_VAR(KEYBOARD_DRIVER, keyboard_macos); +#define KEYBOARD_ADB AL_ID('M','A','D','B') +AL_VAR(KEYBOARD_DRIVER, keyboard_adb); + +/*******************************************/ +/************* mouse drivers ***************/ +/*******************************************/ +#define MOUSE_MACOS AL_ID('M','C','O','S') +AL_VAR(MOUSE_DRIVER, mouse_macos); +#define MOUSE_ADB AL_ID('M','A','D','B') +AL_VAR(MOUSE_DRIVER, mouse_adb); + + +/*******************************************/ +/*************** gfx drivers ***************/ +/*******************************************/ +#define GFX_DRAWSPROCKET AL_ID('D','S','P',' ') +AL_VAR(GFX_DRIVER,gfx_drawsprocket); + + +/********************************************/ +/*************** sound drivers **************/ +/********************************************/ +#define DIGI_MACOS AL_ID('M','C','O','S') +AL_VAR(DIGI_DRIVER, digi_macos); + +#define MIDI_QUICKTIME AL_ID('Q','T',' ',' ') +AL_VAR(MIDI_DRIVER, midi_quicktime); + +/*******************************************/ +/************ joystick drivers *************/ +/*******************************************/ +/*no yet */ + diff --git a/lib/allegro/include/allegro/platform/almaccfg.h b/lib/allegro/include/allegro/platform/almaccfg.h new file mode 100644 index 0000000..f394246 --- /dev/null +++ b/lib/allegro/include/allegro/platform/almaccfg.h @@ -0,0 +1,78 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with MPW. + * + * By Ronaldo Hideki Yamada. + * + * See readme.txt for copyright information. + */ + + +#ifndef SCAN_DEPEND + #include + #include +#endif +#define CALL_NOT_IN_CARBON 1 + +#include +#ifndef ENOSYS +#define ENOSYS ENOENT +#endif + +/* describe this platform */ +#define ALLEGRO_PLATFORM_STR "mpw" +#define ALLEGRO_BIG_ENDIAN +#undef ALLEGRO_CONSOLE_OK + +#define INLINE +#define ZERO_SIZE_ARRAY(type, name) type name[64] +#define AL_CONST const +#define AL_VAR(type, name) extern type name +#define AL_ARRAY(type, name) extern type name[] +#define AL_FUNC(type, name, args) type name args +#define AL_PRINTFUNC(type, name, args, a, b) AL_FUNC(type, name, args) +#define AL_METHOD(type, name, args) type (*name) args +#define AL_FUNCPTR(type, name, args) extern type (*name) args + +#define END_OF_MAIN() void x##_end(void) { } + +#define END_OF_FUNCTION(x) void x##_end(void) { } +#define END_OF_STATIC_FUNCTION(x) static void x##_end(void) { } +#define LOCK_DATA(d, s) _mac_lock((void *)d, s) +#define LOCK_CODE(c, s) _mac_lock((void *)c, s) +#define UNLOCK_DATA(d,s) _mac_unlock((void *)d, s) +#define LOCK_VARIABLE(x) LOCK_DATA((void *)&x, sizeof(x)) +#define LOCK_FUNCTION(x) LOCK_CODE((void *)x, (intptr_t)x##_end - (intptr_t)x) + +/* long filename status */ +#define ALLEGRO_LFN 0 + +#define ALLEGRO_NO_STRICMP 1 + +#define ALLEGRO_NO_STRUPR 1 + +//#define ALLEGRO_NO_STRDUP 1 +#ifdef __cplusplus +extern "C" +#endif +char *strdup(const char *); + +#ifndef AL_INLINE + #define AL_INLINE(type, name, args, code) static type name args code +#endif + + +// gm_time has an strange return +#define gmtime localtime + + +#define ALLEGRO_EXTRA_HEADER "allegro/platform/almac.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintmac.h" diff --git a/lib/allegro/include/allegro/platform/almngw32.h b/lib/allegro/include/allegro/platform/almngw32.h new file mode 100644 index 0000000..3823f08 --- /dev/null +++ b/lib/allegro/include/allegro/platform/almngw32.h @@ -0,0 +1,101 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with Mingw32. + * + * By Michael Rickmann. + * + * Native build version by Henrik Stokseth. + * + * See readme.txt for copyright information. + */ + + +#ifndef SCAN_DEPEND + #include + #include + #include + #include +#endif + + +/* a static auto config */ +/* older mingw's don't seem to have inttypes.h */ +/* #define HAVE_INTTYPES_H */ +#define HAVE_STDINT_H + + +/* describe this platform */ +#ifdef ALLEGRO_STATICLINK + #define ALLEGRO_PLATFORM_STR "MinGW32.s" +#else + #define ALLEGRO_PLATFORM_STR "MinGW32" +#endif + +#define ALLEGRO_WINDOWS +#define ALLEGRO_I386 +#define ALLEGRO_LITTLE_ENDIAN +#define ALLEGRO_USE_CONSTRUCTOR +#define ALLEGRO_MULTITHREADED + +#ifdef ALLEGRO_USE_CONSOLE + #define ALLEGRO_CONSOLE_OK + #define ALLEGRO_NO_MAGIC_MAIN +#endif + + +/* describe how function prototypes look to MINGW32 */ +#if (defined ALLEGRO_STATICLINK) || (defined ALLEGRO_SRC) + #define _AL_DLL +#else + #define _AL_DLL __declspec(dllimport) +#endif + +#define AL_VAR(type, name) extern _AL_DLL type name +#define AL_ARRAY(type, name) extern _AL_DLL type name[] +#define AL_FUNC(type, name, args) extern type name args +#define AL_METHOD(type, name, args) type (*name) args +#define AL_FUNCPTR(type, name, args) extern _AL_DLL type (*name) args + + +/* windows specific defines */ + +#if (defined ALLEGRO_SRC) +/* pathches to handle DX7 headers on a win9x system */ + +/* should WINNT be defined on win9x systems? */ +#ifdef WINNT + #undef WINNT +#endif + +/* defined in windef.h */ +#ifndef HMONITOR_DECLARED + #define HMONITOR_DECLARED 1 +#endif + +/* already defined... */ +#ifndef _LPCWAVEFORMATEX_DEFINED + #define _LPCWAVEFORMATEX_DEFINED +#endif + +#endif /* ALLEGRO_SRC */ + +/* another instance of missing constants in the mingw32 headers */ +#ifndef ENUM_CURRENT_SETTINGS + #define ENUM_CURRENT_SETTINGS ((DWORD)-1) +#endif + +/* describe the asm syntax for this platform */ +#define ALLEGRO_ASM_PREFIX "_" + +/* arrange for other headers to be included later on */ +#define ALLEGRO_EXTRA_HEADER "allegro/platform/alwin.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintwin.h" +#define ALLEGRO_ASMCAPA_HEADER "obj/mingw32/asmcapa.h" diff --git a/lib/allegro/include/allegro/platform/almsvc.h b/lib/allegro/include/allegro/platform/almsvc.h new file mode 100644 index 0000000..12fb988 --- /dev/null +++ b/lib/allegro/include/allegro/platform/almsvc.h @@ -0,0 +1,99 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with MSVC. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef SCAN_DEPEND + #include + #include + #include + #include +#endif + + +#pragma warning (disable: 4200 4244 4305) + + +/* describe this platform */ +#ifdef ALLEGRO_STATICLINK + #define ALLEGRO_PLATFORM_STR "MSVC.s" +#else + #define ALLEGRO_PLATFORM_STR "MSVC" +#endif + +#define ALLEGRO_WINDOWS +#define ALLEGRO_I386 +#define ALLEGRO_LITTLE_ENDIAN +#define ALLEGRO_GUESS_INTTYPES_OK +#define ALLEGRO_MULTITHREADED + +#ifdef ALLEGRO_USE_CONSOLE + #define ALLEGRO_CONSOLE_OK + #define ALLEGRO_NO_MAGIC_MAIN +#endif + +#ifdef ALLEGRO_AND_MFC + #define ALLEGRO_NO_MAGIC_MAIN +#endif + + +/* describe how function prototypes look to MSVC */ +#if (defined ALLEGRO_STATICLINK) || (defined ALLEGRO_SRC) + #define _AL_DLL +#else + #define _AL_DLL __declspec(dllimport) +#endif + +#define AL_VAR(type, name) extern _AL_DLL type name +#define AL_ARRAY(type, name) extern _AL_DLL type name[] +#define AL_FUNC(type, name, args) _AL_DLL type __cdecl name args +#define AL_METHOD(type, name, args) type (__cdecl *name) args +#define AL_FUNCPTR(type, name, args) extern _AL_DLL type (__cdecl *name) args + +#ifdef AL_INLINE + #define END_OF_INLINE(name) void *_force_instantiate_##name = name; +#else + #define END_OF_INLINE(name) +#endif + +#undef AL_INLINE + +#define AL_INLINE(type, name, args, code) __inline _AL_DLL type __cdecl name args code END_OF_INLINE(name) + +#define INLINE __inline + +#define LONG_LONG __int64 +#define int64_t signed __int64 +#define uint64_t unsigned __int64 + +#define AL_CONST const + + +/* describe the asm syntax for this platform */ +#define ALLEGRO_ASM_PREFIX "_" + + +/* life would be so easy if compilers would all use the same names! */ +#if (!defined S_IRUSR) && (!defined SCAN_DEPEND) + #define S_IRUSR S_IREAD + #define S_IWUSR S_IWRITE +#endif + + +/* arrange for other headers to be included later on */ +#define ALLEGRO_EXTRA_HEADER "allegro/platform/alwin.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintwin.h" +#define ALLEGRO_ASMCAPA_HEADER "obj/msvc/asmcapa.h" diff --git a/lib/allegro/include/allegro/platform/alosx.h b/lib/allegro/include/allegro/platform/alosx.h new file mode 100644 index 0000000..6f7061b --- /dev/null +++ b/lib/allegro/include/allegro/platform/alosx.h @@ -0,0 +1,115 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * MacOS X specific header defines. + * + * By Angelo Mottola. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALOSX_H +#define ALOSX_H + +#ifndef ALLEGRO_MACOSX + #error bad include +#endif + + +#ifndef SCAN_DEPEND + #include + #include + #include + #include + #include + #include + #if defined __OBJC__ && defined ALLEGRO_SRC + #undef TRUE + #undef FALSE + #import + #import + #import + #import + #import + #import + #import + #import + #import + #import + #import + #import + #import + #import + #undef TRUE + #undef FALSE + #undef assert + #define TRUE -1 + #define FALSE 0 + #endif +#endif + + +/* The following code comes from alunix.h */ +/* Magic to capture name of executable file */ +extern int __crt0_argc; +extern char **__crt0_argv; + +#ifndef ALLEGRO_NO_MAGIC_MAIN + #define ALLEGRO_MAGIC_MAIN + #define main _mangled_main + #undef END_OF_MAIN + #define END_OF_MAIN() void *_mangled_main_address = (void*) _mangled_main; +#else + #undef END_OF_MAIN + #define END_OF_MAIN() void *_mangled_main_address; +#endif + + +/* System driver */ +#define SYSTEM_MACOSX AL_ID('O','S','X',' ') +AL_VAR(SYSTEM_DRIVER, system_macosx); + +/* Timer driver */ +#define TIMERDRV_UNIX_PTHREADS AL_ID('P','T','H','R') +AL_VAR(TIMER_DRIVER, timerdrv_unix_pthreads); + +/* Keyboard driver */ +#define KEYBOARD_MACOSX AL_ID('O','S','X','K') +AL_VAR(KEYBOARD_DRIVER, keyboard_macosx); + +/* Mouse driver */ +#define MOUSE_MACOSX AL_ID('O','S','X','M') +AL_VAR(MOUSE_DRIVER, mouse_macosx); + +/* Gfx drivers */ +#define GFX_QUARTZ_WINDOW AL_ID('Q','Z','W','N') +#define GFX_QUARTZ_FULLSCREEN AL_ID('Q','Z','F','L') +AL_VAR(GFX_DRIVER, gfx_quartz_window); +AL_VAR(GFX_DRIVER, gfx_quartz_full); + +/* Digital sound drivers */ +#define DIGI_CORE_AUDIO AL_ID('D','C','A',' ') +#define DIGI_SOUND_MANAGER AL_ID('S','N','D','M') +AL_VAR(DIGI_DRIVER, digi_core_audio); +AL_VAR(DIGI_DRIVER, digi_sound_manager); + +/* MIDI music drivers */ +#define MIDI_CORE_AUDIO AL_ID('M','C','A',' ') +#define MIDI_QUICKTIME AL_ID('Q','T','M',' ') +AL_VAR(MIDI_DRIVER, midi_core_audio); +AL_VAR(MIDI_DRIVER, midi_quicktime); + +/* Joystick drivers */ +#define JOYSTICK_HID AL_ID('H','I','D','J') +AL_VAR(JOYSTICK_DRIVER, joystick_hid); + + +#endif diff --git a/lib/allegro/include/allegro/platform/alosxcfg.h b/lib/allegro/include/allegro/platform/alosxcfg.h new file mode 100644 index 0000000..62dabb5 --- /dev/null +++ b/lib/allegro/include/allegro/platform/alosxcfg.h @@ -0,0 +1,68 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with MacOS X. + * + * By Angelo Mottola. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALOSXCFG_H +#define ALOSXCFG_H + +/* Provide implementations of missing functions */ +#define ALLEGRO_NO_STRICMP +#define ALLEGRO_NO_STRLWR +#define ALLEGRO_NO_STRUPR + +/* Provide implementations of missing definitions */ +#define O_BINARY 0 + +/* Override default definitions for this platform */ +#define AL_RAND() ((rand() >> 16) & 0x7fff) + +/* A static auto config */ +#define HAVE_LIBPTHREAD +#define HAVE_DIRENT_H +#define HAVE_INTTYPES_H +#define HAVE_STDINT_H +#define HAVE_SYS_DIR_H +#define HAVE_SYS_TIME_H +#define TIME_WITH_SYS_TIME +#define HAVE_SYS_STAT_H +#define HAVE_MKSTEMP + +/* Describe this platform */ +#define ALLEGRO_PLATFORM_STR "MacOS X" +#define ALLEGRO_CONSOLE_OK +#define ALLEGRO_USE_CONSTRUCTOR +#define ALLEGRO_MULTITHREADED + +/* Endianesse - different between Intel and PPC based Mac's */ +#ifdef __LITTLE_ENDIAN__ + #define ALLEGRO_LITTLE_ENDIAN +#endif +#ifdef __BIG_ENDIAN__ + #define ALLEGRO_BIG_ENDIAN +#endif + +/* Exclude ASM */ + +#ifndef ALLEGRO_NO_ASM + #define ALLEGRO_NO_ASM +#endif + +/* Arrange for other headers to be included later on */ +#define ALLEGRO_EXTRA_HEADER "allegro/platform/alosx.h" + + +#endif diff --git a/lib/allegro/include/allegro/platform/alplatf.h b/lib/allegro/include/allegro/platform/alplatf.h new file mode 100644 index 0000000..39e8147 --- /dev/null +++ b/lib/allegro/include/allegro/platform/alplatf.h @@ -0,0 +1,2 @@ +/* generated by fix.bat */ +#define ALLEGRO_MSVC diff --git a/lib/allegro/include/allegro/platform/alqnx.h b/lib/allegro/include/allegro/platform/alqnx.h new file mode 100644 index 0000000..acce2bd --- /dev/null +++ b/lib/allegro/include/allegro/platform/alqnx.h @@ -0,0 +1,74 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * QNX specific driver definitions. + * + * By Angelo Mottola. + * + * See readme.txt for copyright information. + */ + + +/* magic to capture name of executable file */ +extern int __crt0_argc; +extern char **__crt0_argv; + +#ifndef ALLEGRO_NO_MAGIC_MAIN + #define ALLEGRO_MAGIC_MAIN + #define main _mangled_main + #undef END_OF_MAIN + #define END_OF_MAIN() void *_mangled_main_address = (void*) _mangled_main; +#else + #undef END_OF_MAIN + #define END_OF_MAIN() void *_mangled_main_address; +#endif + + +/* System driver */ +#define SYSTEM_QNX AL_ID('Q','S','Y','S') +AL_VAR(SYSTEM_DRIVER, system_qnx); + + +/* Timer driver */ +#define TIMERDRV_UNIX_PTHREADS AL_ID('P','T','H','R') +AL_VAR(TIMER_DRIVER, timerdrv_unix_pthreads); + + +/* Keyboard driver */ +#define KEYBOARD_QNX AL_ID('Q','K','E','Y') +AL_VAR(KEYBOARD_DRIVER, keyboard_qnx); + + +/* Mouse driver */ +#define MOUSE_QNX AL_ID('Q','M','S','E') +AL_VAR(MOUSE_DRIVER, mouse_qnx); + + +/* Graphics drivers */ +#define GFX_PHOTON AL_ID('Q','P','A','C') +#define GFX_PHOTON_ACCEL AL_ID('Q','P','A','C') +#define GFX_PHOTON_SOFT AL_ID('Q','P','S','O') +#define GFX_PHOTON_SAFE AL_ID('Q','P','S','A') +#define GFX_PHOTON_WIN AL_ID('Q','P','W','N') +AL_VAR(GFX_DRIVER, gfx_photon); +AL_VAR(GFX_DRIVER, gfx_photon_accel); +AL_VAR(GFX_DRIVER, gfx_photon_soft); +AL_VAR(GFX_DRIVER, gfx_photon_safe); +AL_VAR(GFX_DRIVER, gfx_photon_win); + + +/* Sound driver */ +#define DIGI_ALSA AL_ID('A','L','S','A') +AL_VAR(DIGI_DRIVER, digi_alsa); + + +/* MIDI driver */ +#define MIDI_ALSA AL_ID('A','M','I','D') +AL_VAR(MIDI_DRIVER, midi_alsa); diff --git a/lib/allegro/include/allegro/platform/alqnxcfg.h b/lib/allegro/include/allegro/platform/alqnxcfg.h new file mode 100644 index 0000000..8d3d050 --- /dev/null +++ b/lib/allegro/include/allegro/platform/alqnxcfg.h @@ -0,0 +1,56 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with QNX. + * + * By Angelo Mottola. + * + * See readme.txt for copyright information. + */ + + +#ifndef SCAN_DEPEND + #include + #include + #include + #include +#endif + + +/* a static auto config */ +#define HAVE_INTTYPES_H /* TODO: check this */ +#define HAVE_STDINT_H /* TODO: check this */ +#define HAVE_STRICMP +#define HAVE_STRLWR +#define HAVE_STRUPR +#define HAVE_MEMCMP +#define HAVE_MKSTEMP +#define HAVE_UNISTD_H +#define HAVE_FCNTL_H +#define HAVE_LIMITS_H +#define HAVE_DIRENT_H +#define HAVE_SYS_DIR_H +#define HAVE_SYS_UTSNAME_H +#define HAVE_SYS_TIME_H +#define TIME_WITH_SYS_TIME +#define HAVE_LIBPTHREAD + +/* describe this platform */ +#define ALLEGRO_PLATFORM_STR "QNX" +#define ALLEGRO_LITTLE_ENDIAN +#define ALLEGRO_CONSOLE_OK +#define ALLEGRO_USE_SCHED_YIELD +#define ALLEGRO_USE_CONSTRUCTOR +#undef ALLEGRO_MULTITHREADED /* FIXME */ + +/* arrange for other headers to be included later on */ +#define ALLEGRO_EXTRA_HEADER "allegro/platform/alqnx.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintqnx.h" +#define ALLEGRO_ASMCAPA_HEADER "obj/qnx/asmcapa.h" diff --git a/lib/allegro/include/allegro/platform/alucfg.h b/lib/allegro/include/allegro/platform/alucfg.h new file mode 100644 index 0000000..a2ba36c --- /dev/null +++ b/lib/allegro/include/allegro/platform/alucfg.h @@ -0,0 +1,64 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use on Unix platforms. + * + * By Michael Bukin. + * + * See readme.txt for copyright information. + */ + + +#include +#include + +/* Describe this platform. */ +#define ALLEGRO_PLATFORM_STR "Unix" +#define ALLEGRO_CONSOLE_OK +#define ALLEGRO_VRAM_SINGLE_SURFACE + +#define ALLEGRO_EXTRA_HEADER "allegro/platform/alunix.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintunix.h" + +#ifndef O_BINARY +#define O_BINARY 0 +#define O_TEXT 0 +#endif + +/* These defines will be provided by configure script. */ +#undef ALLEGRO_COLOR8 +#undef ALLEGRO_COLOR16 +#undef ALLEGRO_COLOR24 +#undef ALLEGRO_COLOR32 + +/* Include configuration generated by configure script. */ +#include "alunixac.h" + +/* Enable multithreaded library */ +#ifdef HAVE_LIBPTHREAD +#define ALLEGRO_MULTITHREADED +#endif + +/* Provide implementations of missing functions. */ +#ifndef HAVE_STRICMP +#define ALLEGRO_NO_STRICMP +#endif + +#ifndef HAVE_STRLWR +#define ALLEGRO_NO_STRLWR +#endif + +#ifndef HAVE_STRUPR +#define ALLEGRO_NO_STRUPR +#endif + +#ifndef HAVE_MEMCMP +#define ALLEGRO_NO_MEMCMP +#endif diff --git a/lib/allegro/include/allegro/platform/alunix.h b/lib/allegro/include/allegro/platform/alunix.h new file mode 100644 index 0000000..a6c22d4 --- /dev/null +++ b/lib/allegro/include/allegro/platform/alunix.h @@ -0,0 +1,272 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Unix-specific header defines. + * + * By Michael Bukin. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_UNIX + #error bad include +#endif + + +/* magic to capture name of executable file */ +extern int __crt0_argc; +extern char **__crt0_argv; + +#ifdef ALLEGRO_WITH_MAGIC_MAIN + + #ifndef ALLEGRO_NO_MAGIC_MAIN + #define ALLEGRO_MAGIC_MAIN + #define main _mangled_main + #undef END_OF_MAIN + #define END_OF_MAIN() void *_mangled_main_address = (void*) _mangled_main; + #else + #undef END_OF_MAIN + #define END_OF_MAIN() void *_mangled_main_address; + #endif + +#endif + + + +/**************************************/ +/************ General Unix ************/ +/**************************************/ + +#define TIMERDRV_UNIX_PTHREADS AL_ID('P','T','H','R') +#define TIMERDRV_UNIX_SIGALRM AL_ID('A','L','R','M') + + +#ifdef HAVE_LIBPTHREAD +AL_VAR(TIMER_DRIVER, timerdrv_unix_pthreads); +#else +AL_VAR(TIMER_DRIVER, timerdrv_unix_sigalrm); +#endif + + + +/************************************/ +/*********** Sound drivers **********/ +/************************************/ + +#define DIGI_OSS AL_ID('O','S','S','D') +#define MIDI_OSS AL_ID('O','S','S','M') +#define DIGI_ESD AL_ID('E','S','D','D') +#define DIGI_ARTS AL_ID('A','R','T','S') +#define DIGI_SGIAL AL_ID('S','G','I','A') +#define DIGI_ALSA AL_ID('A','L','S','A') +#define MIDI_ALSA AL_ID('A','M','I','D') +#define DIGI_JACK AL_ID('J','A','C','K') + + +#ifdef ALLEGRO_WITH_OSSDIGI +AL_VAR(DIGI_DRIVER, digi_oss); +#define DIGI_DRIVER_OSS \ + { DIGI_OSS, &digi_oss, TRUE }, +#endif /* ALLEGRO_WITH_OSSDIGI */ + +#ifdef ALLEGRO_WITH_OSSMIDI +AL_VAR(MIDI_DRIVER, midi_oss); +#define MIDI_DRIVER_OSS \ + { MIDI_OSS, &midi_oss, TRUE }, +#endif /* ALLEGRO_WITH_OSSMIDI */ + +#ifndef ALLEGRO_WITH_MODULES + +#ifdef ALLEGRO_WITH_ESDDIGI +AL_VAR(DIGI_DRIVER, digi_esd); +#define DIGI_DRIVER_ESD \ + { DIGI_ESD, &digi_esd, TRUE }, +#endif /* ALLEGRO_WITH_ESDDIGI */ + +#ifdef ALLEGRO_WITH_ARTSDIGI +AL_VAR(DIGI_DRIVER, digi_arts); +#define DIGI_DRIVER_ARTS \ + { DIGI_ARTS, &digi_arts, TRUE }, +#endif /* ALLEGRO_WITH_ARTSDIGI */ + +#ifdef ALLEGRO_WITH_SGIALDIGI +AL_VAR(DIGI_DRIVER, digi_sgial); +#define DIGI_DRIVER_SGIAL \ + { DIGI_SGIAL, &digi_sgial, TRUE }, +#endif /* ALLEGRO_WITH_SGIALDIGI */ + +#ifdef ALLEGRO_WITH_ALSADIGI +AL_VAR(DIGI_DRIVER, digi_alsa); +#define DIGI_DRIVER_ALSA \ + { DIGI_ALSA, &digi_alsa, TRUE }, +#endif /* ALLEGRO_WITH_ALSADIGI */ + + +#ifdef ALLEGRO_WITH_ALSAMIDI +AL_VAR(MIDI_DRIVER, midi_alsa); +#define MIDI_DRIVER_ALSA \ + { MIDI_ALSA, &midi_alsa, TRUE }, +#endif /* ALLEGRO_WITH_ALSAMIDI */ + + +#ifdef ALLEGRO_WITH_JACKDIGI +AL_VAR(DIGI_DRIVER, digi_jack); +#define DIGI_DRIVER_JACK \ + { DIGI_JACK, &digi_jack, TRUE }, +#endif /* ALLEGRO_WITH_JACKDIGI */ + +#endif + + + +/************************************/ +/************ X-specific ************/ +/************************************/ + +#define SYSTEM_XWINDOWS AL_ID('X','W','I','N') + +#define KEYBOARD_XWINDOWS AL_ID('X','W','I','N') +#define MOUSE_XWINDOWS AL_ID('X','W','I','N') + +#define GFX_XWINDOWS AL_ID('X','W','I','N') +#define GFX_XWINDOWS_FULLSCREEN AL_ID('X','W','F','S') +#define GFX_XDGA AL_ID('X','D','G','A') +#define GFX_XDGA_FULLSCREEN AL_ID('X','D','F','S') +#define GFX_XDGA2 AL_ID('D','G','A','2') +#define GFX_XDGA2_SOFT AL_ID('D','G','A','S') + + +#ifdef ALLEGRO_WITH_XWINDOWS +AL_VAR(SYSTEM_DRIVER, system_xwin); + +#ifdef ALLEGRO_XWINDOWS_WITH_XF86DGA2 +#ifndef ALLEGRO_WITH_MODULES +AL_VAR(GFX_DRIVER, gfx_xdga2); +AL_VAR(GFX_DRIVER, gfx_xdga2_soft); +#endif +#endif + +#endif /* ALLEGRO_WITH_XWINDOWS */ + + + +/****************************************/ +/************ Linux-specific ************/ +/****************************************/ + +#define SYSTEM_LINUX AL_ID('L','N','X','C') + +#define GFX_VGA AL_ID('V','G','A',' ') +#define GFX_MODEX AL_ID('M','O','D','X') +#define GFX_FBCON AL_ID('F','B',' ',' ') +#define GFX_VBEAF AL_ID('V','B','A','F') +#define GFX_SVGALIB AL_ID('S','V','G','A') + +#define KEYDRV_LINUX AL_ID('L','N','X','C') + +#define MOUSEDRV_LINUX_PS2 AL_ID('L','P','S','2') +#define MOUSEDRV_LINUX_IPS2 AL_ID('L','I','P','S') +#define MOUSEDRV_LINUX_GPMDATA AL_ID('G','P','M','D') +#define MOUSEDRV_LINUX_MS AL_ID('M','S',' ',' ') +#define MOUSEDRV_LINUX_IMS AL_ID('I','M','S',' ') +#define MOUSEDRV_LINUX_EVDEV AL_ID('E','V',' ',' ') + +#define JOY_TYPE_LINUX_ANALOGUE AL_ID('L','N','X','A') + + +#ifdef ALLEGRO_LINUX + +AL_VAR(SYSTEM_DRIVER, system_linux); + +#ifdef ALLEGRO_LINUX_VGA + AL_VAR(GFX_DRIVER, gfx_vga); + AL_VAR(GFX_DRIVER, gfx_modex); + #define GFX_HAS_VGA +#endif + +#ifndef ALLEGRO_WITH_MODULES + +#ifdef ALLEGRO_LINUX_FBCON + AL_VAR(GFX_DRIVER, gfx_fbcon); +#endif +#ifdef ALLEGRO_LINUX_SVGALIB + AL_VAR(GFX_DRIVER, gfx_svgalib); +#endif + +#endif + +#ifdef ALLEGRO_LINUX_VBEAF + AL_VAR(GFX_DRIVER, gfx_vbeaf); + #define GFX_HAS_VBEAF +#endif + +AL_VAR(MOUSE_DRIVER, mousedrv_linux_ps2); +AL_VAR(MOUSE_DRIVER, mousedrv_linux_ips2); +AL_VAR(MOUSE_DRIVER, mousedrv_linux_gpmdata); +AL_VAR(MOUSE_DRIVER, mousedrv_linux_ms); +AL_VAR(MOUSE_DRIVER, mousedrv_linux_ims); +AL_VAR(MOUSE_DRIVER, mousedrv_linux_evdev); + +AL_FUNC_DEPRECATED(void, split_modex_screen, (int lyne)); + + +/* Port I/O functions -- maybe these should be internal */ + +#ifdef ALLEGRO_LINUX_VGA + +#ifdef __cplusplus +extern "C" { +#endif + +static INLINE void outportb(unsigned short port, unsigned char value) +{ + __asm__ volatile ("outb %0, %1" : : "a" (value), "d" (port)); +} + +static INLINE void outportw(unsigned short port, unsigned short value) +{ + __asm__ volatile ("outw %0, %1" : : "a" (value), "d" (port)); +} + +static INLINE void outportl(unsigned short port, unsigned long value) +{ + __asm__ volatile ("outl %0, %1" : : "a" (value), "d" (port)); +} + +static INLINE unsigned char inportb(unsigned short port) +{ + unsigned char value; + __asm__ volatile ("inb %1, %0" : "=a" (value) : "d" (port)); + return value; +} + +static INLINE unsigned short inportw(unsigned short port) +{ + unsigned short value; + __asm__ volatile ("inw %1, %0" : "=a" (value) : "d" (port)); + return value; +} + +static INLINE unsigned long inportl(unsigned short port) +{ + unsigned long value; + __asm__ volatile ("inl %1, %0" : "=a" (value) : "d" (port)); + return value; +} + +#ifdef __cplusplus +} +#endif + +#endif /* ALLEGRO_LINUX_VGA */ + + +#endif /* ALLEGRO_LINUX */ diff --git a/lib/allegro/include/allegro/platform/alunixac.hin b/lib/allegro/include/allegro/platform/alunixac.hin new file mode 100644 index 0000000..22a05ec --- /dev/null +++ b/lib/allegro/include/allegro/platform/alunixac.hin @@ -0,0 +1,284 @@ +/* include/allegro/platform/alunixac.hin. Generated from configure.in by autoheader. */ + +/* Define to the installed ALSA version. */ +#undef ALLEGRO_ALSA_VERSION + +/* Define if compiler prepends underscore to symbols. */ +#undef ALLEGRO_ASM_PREFIX + +/* Define if target machine is big endian. */ +#undef ALLEGRO_BIG_ENDIAN + +/* Define if you want support for 16 bpp modes. */ +#undef ALLEGRO_COLOR16 + +/* Define if you want support for 24 bpp modes. */ +#undef ALLEGRO_COLOR24 + +/* Define if you want support for 32 bpp modes. */ +#undef ALLEGRO_COLOR32 + +/* Define if you want support for 8 bpp modes. */ +#undef ALLEGRO_COLOR8 + +/* Define if target platform is Darwin. */ +#undef ALLEGRO_DARWIN + +/* Define to 1 if you have getexecname */ +#undef ALLEGRO_HAVE_GETEXECNAME + +/* Define to 1 if procfs reveals argc and argv */ +#undef ALLEGRO_HAVE_PROCFS_ARGCV + +/* Define to 1 if you have a System V sys/procfs.h */ +#undef ALLEGRO_HAVE_SV_PROCFS + +/* Define if target platform is linux. */ +#undef ALLEGRO_LINUX + +/* Define to enable Linux console fbcon driver. */ +#undef ALLEGRO_LINUX_FBCON + +/* Define to enable Linux console SVGAlib driver. */ +#undef ALLEGRO_LINUX_SVGALIB + +/* Define if SVGAlib driver can check vga_version. */ +#undef ALLEGRO_LINUX_SVGALIB_HAVE_VGA_VERSION + +/* Define to enable Linux console VBE/AF driver. */ +#undef ALLEGRO_LINUX_VBEAF + +/* Define to enable Linux console VGA driver. */ +#undef ALLEGRO_LINUX_VGA + +/* Define if target machine is little endian. */ +#undef ALLEGRO_LITTLE_ENDIAN + +/* Define if assembler supports MMX. */ +#undef ALLEGRO_MMX + +/* Define for Unix platforms, to use C convention for bank switching. */ +#undef ALLEGRO_NO_ASM + +/* Define if assembler supports SSE. */ +#undef ALLEGRO_SSE + +/* Define if constructor attribute is supported. */ +#undef ALLEGRO_USE_CONSTRUCTOR + +/* Define if sched_yield is provided by some library. */ +#undef ALLEGRO_USE_SCHED_YIELD + +/* Define if XIM extension is supported. */ +#undef ALLEGRO_USE_XIM + +/* Define if ALSA DIGI driver is supported. */ +#undef ALLEGRO_WITH_ALSADIGI + +/* Define if ALSA MIDI driver is supported. */ +#undef ALLEGRO_WITH_ALSAMIDI + +/* Define if aRts DIGI driver is supported. */ +#undef ALLEGRO_WITH_ARTSDIGI + +/* Define if ESD DIGI driver is supported. */ +#undef ALLEGRO_WITH_ESDDIGI + +/* Define if JACK DIGI driver is supported. */ +#undef ALLEGRO_WITH_JACKDIGI + +/* Define if you need to use a magic main. */ +#undef ALLEGRO_WITH_MAGIC_MAIN + +/* Define if dynamically loaded modules are supported. */ +#undef ALLEGRO_WITH_MODULES + +/* Define if OSS DIGI driver is supported. */ +#undef ALLEGRO_WITH_OSSDIGI + +/* Define if OSS MIDI driver is supported. */ +#undef ALLEGRO_WITH_OSSMIDI + +/* Define if SGI AL DIGI driver is supported. */ +#undef ALLEGRO_WITH_SGIALDIGI + +/* Define if you need support for X-Windows. */ +#undef ALLEGRO_WITH_XWINDOWS + +/* Define if MIT-SHM extension is supported. */ +#undef ALLEGRO_XWINDOWS_WITH_SHM + +/* Define if XCursor ARGB extension is available. */ +#undef ALLEGRO_XWINDOWS_WITH_XCURSOR + +/* Define if DGA version 2.0 or newer is supported */ +#undef ALLEGRO_XWINDOWS_WITH_XF86DGA2 + +/* Define if XF86VidMode extension is supported. */ +#undef ALLEGRO_XWINDOWS_WITH_XF86VIDMODE + +/* Define if xpm bitmap support is available. */ +#undef ALLEGRO_XWINDOWS_WITH_XPM + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `ossaudio' library (-lossaudio). */ +#undef HAVE_LIBOSSAUDIO + +/* Define if you have the pthread library. */ +#undef HAVE_LIBPTHREAD + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_AWE_VOICE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_INPUT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_JOYSTICK_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_SOUNDCARD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MACHINE_SOUNDCARD_H + +/* Define to 1 if you have the `memcmp' function. */ +#undef HAVE_MEMCMP + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mkstemp' function. */ +#undef HAVE_MKSTEMP + +/* Define to 1 if you have the `mmap' function. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the `mprotect' function. */ +#undef HAVE_MPROTECT + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SOUNDCARD_H + +/* Define to 1 if you have the `stat64' function. */ +#undef HAVE_STAT64 + +/* 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 `stricmp' function. */ +#undef HAVE_STRICMP + +/* 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 `strlwr' function. */ +#undef HAVE_STRLWR + +/* Define to 1 if you have the `strupr' function. */ +#undef HAVE_STRUPR + +/* Define to 1 if you have the `sysconf' function. */ +#undef HAVE_SYSCONF + +/* 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_IO_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_SOUNDCARD_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_SYS_UTSNAME_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 (void *)-1, if MAP_FAILED is not defined. */ +#undef MAP_FAILED + +/* 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 + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* 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 + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/lib/allegro/include/allegro/platform/alwatcom.h b/lib/allegro/include/allegro/platform/alwatcom.h new file mode 100644 index 0000000..1e33b0f --- /dev/null +++ b/lib/allegro/include/allegro/platform/alwatcom.h @@ -0,0 +1,195 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Configuration defines for use with Watcom. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + +#ifndef SCAN_DEPEND + #ifndef __SW_3S + #error Allegro only supports stack based calling convention + #endif + + #ifndef __SW_S + #error Stack overflow checking must be disabled + #endif + + #include + #include + #include + #include + #include + #include +#endif + + +#pragma disable_message (120 201 202) + + +/* these are available in OpenWatcom 1.3 (12.3) */ +#if __WATCOMC__ >= 1230 + #define HAVE_INTTYPES_H + #define HAVE_STDINT_H +#else + #define ALLEGRO_GUESS_INTTYPES_OK +#endif + + +/* describe this platform */ +#define ALLEGRO_PLATFORM_STR "Watcom" +#define ALLEGRO_DOS +#define ALLEGRO_I386 +#define ALLEGRO_LITTLE_ENDIAN +#define ALLEGRO_CONSOLE_OK +#define ALLEGRO_VRAM_SINGLE_SURFACE + +#define ALLEGRO_LFN 0 + +#define LONG_LONG long long +#ifdef ALLEGRO_GUESS_INTTYPES_OK + #define int64_t signed long long + #define uint64_t unsigned long long +#endif + +#if __WATCOMC__ >= 1100 + #define ALLEGRO_MMX +#endif + +#if __WATCOMC__ >= 1200 /* Open Watcom 1.0 */ + #define AL_CONST const +#endif + + +/* emulate some important djgpp routines */ +#define inportb(port) inp(port) +#define inportw(port) inpw(port) +#define outportb(port, val) outp(port, val) +#define outportw(port, val) outpw(port, val) + +#define ffblk find_t +#define ff_name name +#define ff_attrib attrib +#define ff_fsize size +#define ff_ftime wr_time +#define ff_fdate wr_date + +#define findfirst(name, dta, attrib) _dos_findfirst(name, attrib, dta) +#define findnext(dta) _dos_findnext(dta) + +#define random() rand() +#define srandom(n) srand(n) + +#define _dos_ds _default_ds() + +#define dosmemget(offset, length, buffer) memcpy(buffer, (void *)(offset), length) +#define dosmemput(buffer, length, offset) memcpy((void *)(offset), buffer, length) + +#define __djgpp_nearptr_enable() 1 +#define __djgpp_nearptr_disable() + +#define __djgpp_base_address 0 +#define __djgpp_conventional_base 0 + +#define _crt0_startup_flags 1 +#define _CRT0_FLAG_NEARPTR 1 + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union __dpmi_regs +{ + struct { + unsigned long edi, esi, ebp, res, ebx, edx, ecx, eax; + } d; + struct { + unsigned short di, di_hi, si, si_hi, bp, bp_hi, res, res_hi; + unsigned short bx, bx_hi, dx, dx_hi, cx, cx_hi, ax, ax_hi; + unsigned short flags, es, ds, fs, gs, ip, cs, sp, ss; + } x; + struct { + unsigned char edi[4], esi[4], ebp[4], res[4]; + unsigned char bl, bh, ebx_b2, ebx_b3, dl, dh, edx_b2, edx_b3; + unsigned char cl, ch, ecx_b2, ecx_b3, al, ah, eax_b2, eax_b3; + } h; +} __dpmi_regs; + + +typedef struct __dpmi_meminfo +{ + unsigned long handle; + unsigned long size; + unsigned long address; +} __dpmi_meminfo; + + +typedef struct __dpmi_free_mem_info +{ + unsigned long largest_available_free_block_in_bytes; + unsigned long maximum_unlocked_page_allocation_in_pages; + unsigned long maximum_locked_page_allocation_in_pages; + unsigned long linear_address_space_size_in_pages; + unsigned long total_number_of_unlocked_pages; + unsigned long total_number_of_free_pages; + unsigned long total_number_of_physical_pages; + unsigned long free_linear_address_space_in_pages; + unsigned long size_of_paging_file_partition_in_pages; + unsigned long reserved[3]; +} __dpmi_free_mem_info; + + +extern unsigned long __tb; + + +int __dpmi_int(int vector, __dpmi_regs *regs); +int __dpmi_allocate_dos_memory(int paragraphs, int *ret); +int __dpmi_free_dos_memory(int selector); +int __dpmi_physical_address_mapping(__dpmi_meminfo *info); +int __dpmi_free_physical_address_mapping(__dpmi_meminfo *info); +int __dpmi_lock_linear_region(__dpmi_meminfo *info); +int __dpmi_unlock_linear_region(__dpmi_meminfo *info); +int __dpmi_allocate_ldt_descriptors(int count); +int __dpmi_free_ldt_descriptor(int descriptor); +int __dpmi_get_segment_base_address(int selector, unsigned long *addr); +int __dpmi_set_segment_base_address(int selector, unsigned long address); +int __dpmi_set_segment_limit(int selector, unsigned long limit); +int __dpmi_get_free_memory_information(__dpmi_free_mem_info *info); +int __dpmi_simulate_real_mode_interrupt(int vector, __dpmi_regs *regs); +int __dpmi_simulate_real_mode_procedure_retf(__dpmi_regs *regs); +int _go32_dpmi_lock_data(void *lockaddr, unsigned long locksize); +int _go32_dpmi_lock_code(void *lockaddr, unsigned long locksize); + +long _allocate_real_mode_callback(void (*handler)(__dpmi_regs *r), __dpmi_regs *regs); + + +/* memory locking macros */ +void _unlock_dpmi_data(void *addr, int size); + +#ifdef __cplusplus +} +#endif + + +#define END_OF_FUNCTION(x) void x##_end(void) { } +#define END_OF_STATIC_FUNCTION(x) static void x##_end(void) { } +#define LOCK_DATA(d, s) _go32_dpmi_lock_data(d, s) +#define LOCK_CODE(c, s) _go32_dpmi_lock_code(c, s) +#define UNLOCK_DATA(d,s) _unlock_dpmi_data(d, s) +#define LOCK_VARIABLE(x) LOCK_DATA((void *)&x, sizeof(x)) +#define LOCK_FUNCTION(x) LOCK_CODE((void *)FP_OFF(x), (long)FP_OFF(x##_end) - (long)FP_OFF(x)) + + +/* arrange for other headers to be included later on */ +#define ALLEGRO_EXTRA_HEADER "allegro/platform/aldos.h" +#define ALLEGRO_INTERNAL_HEADER "allegro/platform/aintdos.h" diff --git a/lib/allegro/include/allegro/platform/alwin.h b/lib/allegro/include/allegro/platform/alwin.h new file mode 100644 index 0000000..14ee642 --- /dev/null +++ b/lib/allegro/include/allegro/platform/alwin.h @@ -0,0 +1,147 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Windows-specific header defines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_WINDOWS + #error bad include +#endif + + + +/*******************************************/ +/********** magic main emulation ***********/ +/*******************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +AL_FUNC(int, _WinMain, (void *_main, void *hInst, void *hPrev, char *Cmd, int nShow)); + +#ifdef __cplusplus +} +#endif + + +#if (!defined ALLEGRO_NO_MAGIC_MAIN) && (!defined ALLEGRO_SRC) + + #define ALLEGRO_MAGIC_MAIN + #define main _mangled_main + #undef END_OF_MAIN + + /* disable strict pointer typing because of the vague prototype below */ + #define NO_STRICT + + #ifdef __cplusplus + extern "C" int __stdcall WinMain(void *hInst, void *hPrev, char *Cmd, int nShow); + #endif + + #define END_OF_MAIN() \ + \ + int __stdcall WinMain(void *hInst, void *hPrev, char *Cmd, int nShow) \ + { \ + return _WinMain((void *)_mangled_main, hInst, hPrev, Cmd, nShow); \ + } + +#endif + + + +/*******************************************/ +/************* system drivers **************/ +/*******************************************/ +#define SYSTEM_DIRECTX AL_ID('D','X',' ',' ') + +AL_VAR(SYSTEM_DRIVER, system_directx); + + + +/*******************************************/ +/************** timer drivers **************/ +/*******************************************/ +#define TIMER_WIN32_HIGH_PERF AL_ID('W','3','2','H') +#define TIMER_WIN32_LOW_PERF AL_ID('W','3','2','L') + + + +/*******************************************/ +/************ keyboard drivers *************/ +/*******************************************/ +#define KEYBOARD_DIRECTX AL_ID('D','X',' ',' ') + + + +/*******************************************/ +/************* mouse drivers ***************/ +/*******************************************/ +#define MOUSE_DIRECTX AL_ID('D','X',' ',' ') + + + +/*******************************************/ +/*************** gfx drivers ***************/ +/*******************************************/ +#define GFX_DIRECTX AL_ID('D','X','A','C') +#define GFX_DIRECTX_ACCEL AL_ID('D','X','A','C') +#define GFX_DIRECTX_SAFE AL_ID('D','X','S','A') +#define GFX_DIRECTX_SOFT AL_ID('D','X','S','O') +#define GFX_DIRECTX_WIN AL_ID('D','X','W','N') +#define GFX_DIRECTX_OVL AL_ID('D','X','O','V') +#define GFX_GDI AL_ID('G','D','I','B') + +AL_VAR(GFX_DRIVER, gfx_directx_accel); +AL_VAR(GFX_DRIVER, gfx_directx_safe); +AL_VAR(GFX_DRIVER, gfx_directx_soft); +AL_VAR(GFX_DRIVER, gfx_directx_win); +AL_VAR(GFX_DRIVER, gfx_directx_ovl); +AL_VAR(GFX_DRIVER, gfx_gdi); + +#define GFX_DRIVER_DIRECTX \ + { GFX_DIRECTX_ACCEL, &gfx_directx_accel, TRUE }, \ + { GFX_DIRECTX_SOFT, &gfx_directx_soft, TRUE }, \ + { GFX_DIRECTX_SAFE, &gfx_directx_safe, TRUE }, \ + { GFX_DIRECTX_WIN, &gfx_directx_win, TRUE }, \ + { GFX_DIRECTX_OVL, &gfx_directx_ovl, TRUE }, \ + { GFX_GDI, &gfx_gdi, FALSE }, + + + +/********************************************/ +/*************** sound drivers **************/ +/********************************************/ +#define DIGI_DIRECTX(n) AL_ID('D','X','A'+(n),' ') +#define DIGI_DIRECTAMX(n) AL_ID('A','X','A'+(n),' ') +#define DIGI_WAVOUTID(n) AL_ID('W','O','A'+(n),' ') +#define MIDI_WIN32MAPPER AL_ID('W','3','2','M') +#define MIDI_WIN32(n) AL_ID('W','3','2','A'+(n)) +#define MIDI_WIN32_IN(n) AL_ID('W','3','2','A'+(n)) + + + +/*******************************************/ +/************ joystick drivers *************/ +/*******************************************/ +#define JOY_TYPE_DIRECTX AL_ID('D','X',' ',' ') +#define JOY_TYPE_WIN32 AL_ID('W','3','2',' ') + +AL_VAR(JOYSTICK_DRIVER, joystick_directx); +AL_VAR(JOYSTICK_DRIVER, joystick_win32); + +#define JOYSTICK_DRIVER_DIRECTX \ + { JOY_TYPE_DIRECTX, &joystick_directx, TRUE }, + +#define JOYSTICK_DRIVER_WIN32 \ + { JOY_TYPE_WIN32, &joystick_win32, TRUE }, diff --git a/lib/allegro/include/allegro/platform/astdint.h b/lib/allegro/include/allegro/platform/astdint.h new file mode 100644 index 0000000..91c2ae8 --- /dev/null +++ b/lib/allegro/include/allegro/platform/astdint.h @@ -0,0 +1,49 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * A header file to get definitions of uint*_t and int*_t. + * + * By Peter Wang. + * + * See readme.txt for copyright information. + */ + +#ifndef ASTDINT_H +#define ASTDINT_H + +/* Please only include this file from include/allegro/internal/alconfig.h + * and don't add more than inttypes.h/stdint.h emulation here. Thanks. + */ + + + +#if defined HAVE_INTTYPES_H + #include +#elif defined HAVE_STDINT_H + #include +#elif defined ALLEGRO_I386 && defined ALLEGRO_LITTLE_ENDIAN + #ifndef ALLEGRO_GUESS_INTTYPES_OK + #warning Guessing the definitions of fixed-width integer types. + #endif + #define int8_t signed char + #define uint8_t unsigned char + #define int16_t signed short + #define uint16_t unsigned short + #define int32_t signed int + #define uint32_t unsigned int + #define intptr_t int32_t + #define uintptr_t uint32_t +#else + #error I dunno how to get the definitions of fixed-width integer types on your platform. Please report this to your friendly Allegro developer. +#endif + + + +#endif /* ifndef ASTDINT_H */ diff --git a/lib/allegro/include/allegro/platform/macdef.h b/lib/allegro/include/allegro/platform/macdef.h new file mode 100644 index 0000000..22cfabe --- /dev/null +++ b/lib/allegro/include/allegro/platform/macdef.h @@ -0,0 +1,7 @@ +#define rmac_message 128 /*message window ID*/ +#define rerror_str 128 /*errors str*/ + +#define kprefsize 16384 /* kbytes */ +#define kminsize 10000 +#define kStackNeeded 2048*1024 /*unsual stack requeriment? but allegro need*/ +#define kHeapNeeded 8192*1024 /*it's a game OK*/ \ No newline at end of file diff --git a/lib/allegro/include/allegro/quat.h b/lib/allegro/include/allegro/quat.h new file mode 100644 index 0000000..82928b6 --- /dev/null +++ b/lib/allegro/include/allegro/quat.h @@ -0,0 +1,60 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Quaternion routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_QUAT_H +#define ALLEGRO_QUAT_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct QUAT +{ + float w, x, y, z; +} QUAT; + + +AL_VAR(QUAT, identity_quat); + +AL_FUNC(void, quat_mul, (AL_CONST QUAT *p, AL_CONST QUAT *q, QUAT *out)); +AL_FUNC(void, get_x_rotate_quat, (QUAT *q, float r)); +AL_FUNC(void, get_y_rotate_quat, (QUAT *q, float r)); +AL_FUNC(void, get_z_rotate_quat, (QUAT *q, float r)); +AL_FUNC(void, get_rotation_quat, (QUAT *q, float x, float y, float z)); +AL_FUNC(void, get_vector_rotation_quat, (QUAT *q, float x, float y, float z, float a)); + +AL_FUNC(void, apply_quat, (AL_CONST QUAT *q, float x, float y, float z, float *xout, float *yout, float *zout)); +AL_FUNC(void, quat_slerp, (AL_CONST QUAT *from, AL_CONST QUAT *to, float t, QUAT *out, int how)); + +#define QUAT_SHORT 0 +#define QUAT_LONG 1 +#define QUAT_CW 2 +#define QUAT_CCW 3 +#define QUAT_USER 4 + +#define quat_interpolate(from, to, t, out) quat_slerp((from), (to), (t), (out), QUAT_SHORT) + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_QUAT_H */ + + diff --git a/lib/allegro/include/allegro/rle.h b/lib/allegro/include/allegro/rle.h new file mode 100644 index 0000000..3159f1d --- /dev/null +++ b/lib/allegro/include/allegro/rle.h @@ -0,0 +1,49 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * RLE sprites. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_RLE_H +#define ALLEGRO_RLE_H + +#include "base.h" +#include "gfx.h" + +#ifdef __cplusplus + extern "C" { +#endif + +typedef struct RLE_SPRITE /* a RLE compressed sprite */ +{ + int w, h; /* width and height in pixels */ + int color_depth; /* color depth of the image */ + int size; /* size of sprite data in bytes */ + ZERO_SIZE_ARRAY(signed char, dat); +} RLE_SPRITE; + + +AL_FUNC(RLE_SPRITE *, get_rle_sprite, (struct BITMAP *bitmap)); +AL_FUNC(void, destroy_rle_sprite, (RLE_SPRITE *sprite)); + +#ifdef __cplusplus + } +#endif + +#include "inline/rle.inl" + +#endif /* ifndef ALLEGRO_RLE_H */ + + diff --git a/lib/allegro/include/allegro/sound.h b/lib/allegro/include/allegro/sound.h new file mode 100644 index 0000000..c7bb50c --- /dev/null +++ b/lib/allegro/include/allegro/sound.h @@ -0,0 +1,60 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Sound support routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_SOUND_H +#define ALLEGRO_SOUND_H + +#include "base.h" +#include "digi.h" +#include "stream.h" +#include "midi.h" + +#ifdef __cplusplus + extern "C" { +#endif + +AL_FUNC(void, reserve_voices, (int digi_voices, int midi_voices)); +AL_FUNC(void, set_volume_per_voice, (int scale)); + +AL_FUNC(int, install_sound, (int digi, int midi, AL_CONST char *cfg_path)); +AL_FUNC(void, remove_sound, (void)); + +AL_FUNC(int, install_sound_input, (int digi, int midi)); +AL_FUNC(void, remove_sound_input, (void)); + +AL_FUNC(void, set_volume, (int digi_volume, int midi_volume)); +AL_FUNC(void, set_hardware_volume, (int digi_volume, int midi_volume)); + +AL_FUNC(void, get_volume, (int *digi_volume, int *midi_volume)); +AL_FUNC(void, get_hardware_volume, (int *digi_volume, int *midi_volume)); + +AL_FUNC(void, set_mixer_quality, (int quality)); +AL_FUNC(int, get_mixer_quality, (void)); +AL_FUNC(int, get_mixer_frequency, (void)); +AL_FUNC(int, get_mixer_bits, (void)); +AL_FUNC(int, get_mixer_channels, (void)); +AL_FUNC(int, get_mixer_voices, (void)); +AL_FUNC(int, get_mixer_buffer_length, (void)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_SOUND_H */ + + diff --git a/lib/allegro/include/allegro/stream.h b/lib/allegro/include/allegro/stream.h new file mode 100644 index 0000000..54d3ac2 --- /dev/null +++ b/lib/allegro/include/allegro/stream.h @@ -0,0 +1,52 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Streaming sound routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_STREAM_H +#define ALLEGRO_STREAM_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct SAMPLE; + +typedef struct AUDIOSTREAM +{ + int voice; /* the voice we are playing on */ + struct SAMPLE *samp; /* the sample we are using */ + int len; /* buffer length */ + int bufcount; /* number of buffers per sample half */ + int bufnum; /* current refill buffer */ + int active; /* which half is currently playing */ + void *locked; /* the locked buffer */ +} AUDIOSTREAM; + +AL_FUNC(AUDIOSTREAM *, play_audio_stream, (int len, int bits, int stereo, int freq, int vol, int pan)); +AL_FUNC(void, stop_audio_stream, (AUDIOSTREAM *stream)); +AL_FUNC(void *, get_audio_stream_buffer, (AUDIOSTREAM *stream)); +AL_FUNC(void, free_audio_stream_buffer, (AUDIOSTREAM *stream)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_STREAM_H */ + + diff --git a/lib/allegro/include/allegro/system.h b/lib/allegro/include/allegro/system.h new file mode 100644 index 0000000..812fc41 --- /dev/null +++ b/lib/allegro/include/allegro/system.h @@ -0,0 +1,249 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * System level: initialization, cleanup, etc. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_SYSTEM_H +#define ALLEGRO_SYSTEM_H + +#include "base.h" +#include "unicode.h" +#include "config.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct RGB; +struct BITMAP; +struct GFX_VTABLE; +struct GFX_MODE; + +#define ALLEGRO_ERROR_SIZE 256 + +AL_ARRAY(char, allegro_id); +AL_ARRAY(char, allegro_error); + +#define OSTYPE_UNKNOWN 0 +#define OSTYPE_WIN3 AL_ID('W','I','N','3') +#define OSTYPE_WIN95 AL_ID('W','9','5',' ') +#define OSTYPE_WIN98 AL_ID('W','9','8',' ') +#define OSTYPE_WINME AL_ID('W','M','E',' ') +#define OSTYPE_WINNT AL_ID('W','N','T',' ') +#define OSTYPE_WIN2000 AL_ID('W','2','K',' ') +#define OSTYPE_WINXP AL_ID('W','X','P',' ') +#define OSTYPE_WIN2003 AL_ID('W','2','K','3') +#define OSTYPE_WINVISTA AL_ID('W','V','S','T') +#define OSTYPE_OS2 AL_ID('O','S','2',' ') +#define OSTYPE_WARP AL_ID('W','A','R','P') +#define OSTYPE_DOSEMU AL_ID('D','E','M','U') +#define OSTYPE_OPENDOS AL_ID('O','D','O','S') +#define OSTYPE_LINUX AL_ID('T','U','X',' ') +#define OSTYPE_SUNOS AL_ID('S','U','N',' ') +#define OSTYPE_FREEBSD AL_ID('F','B','S','D') +#define OSTYPE_NETBSD AL_ID('N','B','S','D') +#define OSTYPE_OPENBSD AL_ID('O','B','S','D') +#define OSTYPE_IRIX AL_ID('I','R','I','X') +#define OSTYPE_DARWIN AL_ID('D','A','R','W') +#define OSTYPE_QNX AL_ID('Q','N','X',' ') +#define OSTYPE_UNIX AL_ID('U','N','I','X') +#define OSTYPE_BEOS AL_ID('B','E','O','S') +#define OSTYPE_MACOS AL_ID('M','A','C',' ') +#define OSTYPE_MACOSX AL_ID('M','A','C','X') + +AL_VAR(int, os_type); +AL_VAR(int, os_version); +AL_VAR(int, os_revision); +AL_VAR(int, os_multitasking); + +#define SYSTEM_AUTODETECT 0 +#define SYSTEM_NONE AL_ID('N','O','N','E') + +#define MAKE_VERSION(a, b, c) (((a)<<16)|((b)<<8)|(c)) + +AL_FUNC(int, _install_allegro_version_check, (int system_id, int *errno_ptr, + AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void)))), int version)); + +AL_INLINE(int, install_allegro, (int system_id, int *errno_ptr, + AL_METHOD(int, atexit_ptr, (AL_METHOD(void, func, (void))))), +{ + return _install_allegro_version_check(system_id, errno_ptr, atexit_ptr, \ + MAKE_VERSION(ALLEGRO_VERSION, ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION)); +}) + +#define allegro_init() _install_allegro_version_check(SYSTEM_AUTODETECT, &errno, \ + (int (*)(void (*)(void)))atexit, \ + MAKE_VERSION(ALLEGRO_VERSION, ALLEGRO_SUB_VERSION, ALLEGRO_WIP_VERSION)) + +AL_FUNC(void, allegro_exit, (void)); + +AL_PRINTFUNC(void, allegro_message, (AL_CONST char *msg, ...), 1, 2); +AL_FUNC(void, get_executable_name, (char *output, int size)); +AL_FUNC(int, set_close_button_callback, (AL_METHOD(void, proc, (void)))); + + +AL_FUNC(void, check_cpu, (void)); + +/* CPU Capabilities flags for x86 capable chips */ +#define CPU_ID 0x0001 +#define CPU_FPU 0x0002 +#define CPU_MMX 0x0004 +#define CPU_MMXPLUS 0x0008 +#define CPU_SSE 0x0010 +#define CPU_SSE2 0x0020 +#define CPU_3DNOW 0x0040 +#define CPU_ENH3DNOW 0x0080 +#define CPU_CMOV 0x0100 +#define CPU_AMD64 0x0200 +#define CPU_IA64 0x0400 +#define CPU_SSE3 0x0800 + +/* CPU families - PC */ +#define CPU_FAMILY_UNKNOWN 0 +#define CPU_FAMILY_I386 3 +#define CPU_FAMILY_I486 4 +#define CPU_FAMILY_I586 5 +#define CPU_FAMILY_I686 6 +#define CPU_FAMILY_ITANIUM 7 +#define CPU_FAMILY_EXTENDED 15 +/* CPUID only returns 15 bits, we need extra information from the CPU */ +/* model to identify Pentium IV, Xeon and Athlon 64 processors. */ + +/* CPU families - Power PC */ +#define CPU_FAMILY_POWERPC 18 + +/* CPU models - PC */ +/* 486 */ +#define CPU_MODEL_I486DX 0 +#define CPU_MODEL_I486DX50 1 +#define CPU_MODEL_I486SX 2 +#define CPU_MODEL_I487SX 3 +#define CPU_MODEL_I486SL 4 +#define CPU_MODEL_I486SX2 5 +#define CPU_MODEL_I486DX2 7 +#define CPU_MODEL_I486DX4 8 + +/* Intel/586 */ +#define CPU_MODEL_PENTIUM 1 +#define CPU_MODEL_PENTIUMP54C 2 +#define CPU_MODEL_PENTIUMOVERDRIVE 3 +#define CPU_MODEL_PENTIUMOVERDRIVEDX4 4 +#define CPU_MODEL_CYRIX 14 +#define CPU_MODEL_UNKNOWN 15 + +/* AMD/586 */ +#define CPU_MODEL_K5 0 +#define CPU_MODEL_K6 6 + +/* Intel/686 */ +#define CPU_MODEL_PENTIUMPROA 0 +#define CPU_MODEL_PENTIUMPRO 1 +#define CPU_MODEL_PENTIUMIIKLAMATH 3 +#define CPU_MODEL_PENTIUMII 5 +#define CPU_MODEL_CELERON 6 +#define CPU_MODEL_PENTIUMIIIKATMAI 7 +#define CPU_MODEL_PENTIUMIIICOPPERMINE 8 +#define CPU_MODEL_PENTIUMIIIMOBILE 9 + +/* AMD/686 */ +#define CPU_MODEL_ATHLON 2 +#define CPU_MODEL_DURON 3 + + +/* Information when CPU_FAMILY is 15 */ +#define CPU_MODEL_PENTIUMIV 0 +#define CPU_MODEL_XEON 2 + +#define CPU_MODEL_ATHLON64 4 +#define CPU_MODEL_OPTERON 5 + +/* Information for Power PC processors */ +/* these defines are taken from */ +#define CPU_MODEL_POWERPC_601 1 +#define CPU_MODEL_POWERPC_602 2 +#define CPU_MODEL_POWERPC_603 3 +#define CPU_MODEL_POWERPC_603e 4 +#define CPU_MODEL_POWERPC_603ev 5 +#define CPU_MODEL_POWERPC_604 6 +#define CPU_MODEL_POWERPC_604e 7 +#define CPU_MODEL_POWERPC_620 8 +#define CPU_MODEL_POWERPC_750 9 +#define CPU_MODEL_POWERPC_7400 10 +#define CPU_MODEL_POWERPC_7450 11 + +AL_ARRAY(char, cpu_vendor); +AL_VAR(int, cpu_family); +AL_VAR(int, cpu_model); +AL_VAR(int, cpu_capabilities); + + +typedef struct SYSTEM_DRIVER +{ + int id; + AL_CONST char *name; + AL_CONST char *desc; + AL_CONST char *ascii_name; + AL_METHOD(int, init, (void)); + AL_METHOD(void, exit, (void)); + AL_METHOD(void, get_executable_name, (char *output, int size)); + AL_METHOD(int, find_resource, (char *dest, AL_CONST char *resource, int size)); + AL_METHOD(void, set_window_title, (AL_CONST char *name)); + AL_METHOD(int, set_close_button_callback, (AL_METHOD(void, proc, (void)))); + AL_METHOD(void, message, (AL_CONST char *msg)); + AL_METHOD(void, assert, (AL_CONST char *msg)); + AL_METHOD(void, save_console_state, (void)); + AL_METHOD(void, restore_console_state, (void)); + AL_METHOD(struct BITMAP *, create_bitmap, (int color_depth, int width, int height)); + AL_METHOD(void, created_bitmap, (struct BITMAP *bmp)); + AL_METHOD(struct BITMAP *, create_sub_bitmap, (struct BITMAP *parent, int x, int y, int width, int height)); + AL_METHOD(void, created_sub_bitmap, (struct BITMAP *bmp, struct BITMAP *parent)); + AL_METHOD(int, destroy_bitmap, (struct BITMAP *bitmap)); + AL_METHOD(void, read_hardware_palette, (void)); + AL_METHOD(void, set_palette_range, (AL_CONST struct RGB *p, int from, int to, int retracesync)); + AL_METHOD(struct GFX_VTABLE *, get_vtable, (int color_depth)); + AL_METHOD(int, set_display_switch_mode, (int mode)); + AL_METHOD(void, display_switch_lock, (int lock, int foreground)); + AL_METHOD(int, desktop_color_depth, (void)); + AL_METHOD(int, get_desktop_resolution, (int *width, int *height)); + AL_METHOD(void, get_gfx_safe_mode, (int *driver, struct GFX_MODE *mode)); + AL_METHOD(void, yield_timeslice, (void)); + AL_METHOD(void *, create_mutex, (void)); + AL_METHOD(void, destroy_mutex, (void *handle)); + AL_METHOD(void, lock_mutex, (void *handle)); + AL_METHOD(void, unlock_mutex, (void *handle)); + AL_METHOD(_DRIVER_INFO *, gfx_drivers, (void)); + AL_METHOD(_DRIVER_INFO *, digi_drivers, (void)); + AL_METHOD(_DRIVER_INFO *, midi_drivers, (void)); + AL_METHOD(_DRIVER_INFO *, keyboard_drivers, (void)); + AL_METHOD(_DRIVER_INFO *, mouse_drivers, (void)); + AL_METHOD(_DRIVER_INFO *, joystick_drivers, (void)); + AL_METHOD(_DRIVER_INFO *, timer_drivers, (void)); +} SYSTEM_DRIVER; + + +AL_VAR(SYSTEM_DRIVER, system_none); +AL_VAR(SYSTEM_DRIVER *, system_driver); +AL_ARRAY(_DRIVER_INFO, _system_driver_list); + +#ifdef __cplusplus + } +#endif + +#include "inline/system.inl" + +#endif /* ifndef ALLEGRO_SYSTEM_H */ + + diff --git a/lib/allegro/include/allegro/text.h b/lib/allegro/include/allegro/text.h new file mode 100644 index 0000000..feafc1d --- /dev/null +++ b/lib/allegro/include/allegro/text.h @@ -0,0 +1,54 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Text output routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_TEXT_H +#define ALLEGRO_TEXT_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +struct BITMAP; + +struct FONT_VTABLE; + +struct FONT; + +AL_VAR(struct FONT *, font); +AL_VAR(int, allegro_404_char); +AL_FUNC(void, textout_ex, (struct BITMAP *bmp, AL_CONST struct FONT *f, AL_CONST char *str, int x, int y, int color, int bg)); +AL_FUNC(void, textout_centre_ex, (struct BITMAP *bmp, AL_CONST struct FONT *f, AL_CONST char *str, int x, int y, int color, int bg)); +AL_FUNC(void, textout_right_ex, (struct BITMAP *bmp, AL_CONST struct FONT *f, AL_CONST char *str, int x, int y, int color, int bg)); +AL_FUNC(void, textout_justify_ex, (struct BITMAP *bmp, AL_CONST struct FONT *f, AL_CONST char *str, int x1, int x2, int y, int diff, int color, int bg)); +AL_PRINTFUNC(void, textprintf_ex, (struct BITMAP *bmp, AL_CONST struct FONT *f, int x, int y, int color, int bg, AL_CONST char *format, ...), 7, 8); +AL_PRINTFUNC(void, textprintf_centre_ex, (struct BITMAP *bmp, AL_CONST struct FONT *f, int x, int y, int color, int bg, AL_CONST char *format, ...), 7, 8); +AL_PRINTFUNC(void, textprintf_right_ex, (struct BITMAP *bmp, AL_CONST struct FONT *f, int x, int y, int color, int bg, AL_CONST char *format, ...), 7, 8); +AL_PRINTFUNC(void, textprintf_justify_ex, (struct BITMAP *bmp, AL_CONST struct FONT *f, int x1, int x2, int y, int diff, int color, int bg, AL_CONST char *format, ...), 9, 10); +AL_FUNC(int, text_length, (AL_CONST struct FONT *f, AL_CONST char *str)); +AL_FUNC(int, text_height, (AL_CONST struct FONT *f)); +AL_FUNC(void, destroy_font, (struct FONT *f)); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_TEXT_H */ + + diff --git a/lib/allegro/include/allegro/timer.h b/lib/allegro/include/allegro/timer.h new file mode 100644 index 0000000..1332919 --- /dev/null +++ b/lib/allegro/include/allegro/timer.h @@ -0,0 +1,76 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Timer routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_TIMER_H +#define ALLEGRO_TIMER_H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +#define TIMERS_PER_SECOND 1193181L +#define SECS_TO_TIMER(x) ((long)(x) * TIMERS_PER_SECOND) +#define MSEC_TO_TIMER(x) ((long)(x) * (TIMERS_PER_SECOND / 1000)) +#define BPS_TO_TIMER(x) (TIMERS_PER_SECOND / (long)(x)) +#define BPM_TO_TIMER(x) ((60 * TIMERS_PER_SECOND) / (long)(x)) + +typedef struct TIMER_DRIVER +{ + int id; + AL_CONST char *name; + AL_CONST char *desc; + AL_CONST char *ascii_name; + AL_METHOD(int, init, (void)); + AL_METHOD(void, exit, (void)); + AL_METHOD(int, install_int, (AL_METHOD(void, proc, (void)), long speed)); + AL_METHOD(void, remove_int, (AL_METHOD(void, proc, (void)))); + AL_METHOD(int, install_param_int, (AL_METHOD(void, proc, (void *param)), void *param, long speed)); + AL_METHOD(void, remove_param_int, (AL_METHOD(void, proc, (void *param)), void *param)); + AL_METHOD(int, can_simulate_retrace, (void)); + AL_METHOD(void, simulate_retrace, (int enable)); + AL_METHOD(void, rest, (unsigned int tyme, AL_METHOD(void, callback, (void)))); +} TIMER_DRIVER; + + +AL_VAR(TIMER_DRIVER *, timer_driver); +AL_ARRAY(_DRIVER_INFO, _timer_driver_list); + +AL_FUNC(int, install_timer, (void)); +AL_FUNC(void, remove_timer, (void)); + +AL_FUNC(int, install_int_ex, (AL_METHOD(void, proc, (void)), long speed)); +AL_FUNC(int, install_int, (AL_METHOD(void, proc, (void)), long speed)); +AL_FUNC(void, remove_int, (AL_METHOD(void, proc, (void)))); + +AL_FUNC(int, install_param_int_ex, (AL_METHOD(void, proc, (void *param)), void *param, long speed)); +AL_FUNC(int, install_param_int, (AL_METHOD(void, proc, (void *param)), void *param, long speed)); +AL_FUNC(void, remove_param_int, (AL_METHOD(void, proc, (void *param)), void *param)); + +AL_VAR(volatile int, retrace_count); + +AL_FUNC(void, rest, (unsigned int tyme)); +AL_FUNC(void, rest_callback, (unsigned int tyme, AL_METHOD(void, callback, (void)))); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_TIMER_H */ + diff --git a/lib/allegro/include/allegro/unicode.h b/lib/allegro/include/allegro/unicode.h new file mode 100644 index 0000000..f4d8b30 --- /dev/null +++ b/lib/allegro/include/allegro/unicode.h @@ -0,0 +1,116 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Unicode support routines. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef ALLEGRO_UNICODE__H +#define ALLEGRO_UNICODE__H + +#include "base.h" + +#ifdef __cplusplus + extern "C" { +#endif + +#define U_ASCII AL_ID('A','S','C','8') +#define U_ASCII_CP AL_ID('A','S','C','P') +#define U_UNICODE AL_ID('U','N','I','C') +#define U_UTF8 AL_ID('U','T','F','8') +#define U_CURRENT AL_ID('c','u','r','.') + +AL_FUNC(void, set_uformat, (int type)); +AL_FUNC(int, get_uformat, (void)); +AL_FUNC(void, register_uformat, (int type, AL_METHOD(int, u_getc, (AL_CONST char *s)), AL_METHOD(int, u_getx, (char **s)), AL_METHOD(int, u_setc, (char *s, int c)), AL_METHOD(int, u_width, (AL_CONST char *s)), AL_METHOD(int, u_cwidth, (int c)), AL_METHOD(int, u_isok, (int c)), int u_width_max)); +AL_FUNC(void, set_ucodepage, (AL_CONST unsigned short *table, AL_CONST unsigned short *extras)); + +AL_FUNC(int, need_uconvert, (AL_CONST char *s, int type, int newtype)); +AL_FUNC(int, uconvert_size, (AL_CONST char *s, int type, int newtype)); +AL_FUNC(void, do_uconvert, (AL_CONST char *s, int type, char *buf, int newtype, int size)); +AL_FUNC(char *, uconvert, (AL_CONST char *s, int type, char *buf, int newtype, int size)); +AL_FUNC(int, uwidth_max, (int type)); + +#define uconvert_ascii(s, buf) uconvert(s, U_ASCII, buf, U_CURRENT, sizeof(buf)) +#define uconvert_toascii(s, buf) uconvert(s, U_CURRENT, buf, U_ASCII, sizeof(buf)) + +#define EMPTY_STRING "\0\0\0" + +AL_ARRAY(char, empty_string); + +AL_FUNCPTR(int, ugetc, (AL_CONST char *s)); +AL_FUNCPTR(int, ugetx, (char **s)); +AL_FUNCPTR(int, ugetxc, (AL_CONST char **s)); +AL_FUNCPTR(int, usetc, (char *s, int c)); +AL_FUNCPTR(int, uwidth, (AL_CONST char *s)); +AL_FUNCPTR(int, ucwidth, (int c)); +AL_FUNCPTR(int, uisok, (int c)); +AL_FUNC(int, uoffset, (AL_CONST char *s, int idx)); +AL_FUNC(int, ugetat, (AL_CONST char *s, int idx)); +AL_FUNC(int, usetat, (char *s, int idx, int c)); +AL_FUNC(int, uinsert, (char *s, int idx, int c)); +AL_FUNC(int, uremove, (char *s, int idx)); +AL_FUNC(int, utolower, (int c)); +AL_FUNC(int, utoupper, (int c)); +AL_FUNC(int, uisspace, (int c)); +AL_FUNC(int, uisdigit, (int c)); +AL_FUNC(int, ustrsize, (AL_CONST char *s)); +AL_FUNC(int, ustrsizez, (AL_CONST char *s)); +AL_FUNC(char *, _ustrdup, (AL_CONST char *src, AL_METHOD(void *, malloc_func, (size_t)))); +AL_FUNC(char *, ustrzcpy, (char *dest, int size, AL_CONST char *src)); +AL_FUNC(char *, ustrzcat, (char *dest, int size, AL_CONST char *src)); +AL_FUNC(int, ustrlen, (AL_CONST char *s)); +AL_FUNC(int, ustrcmp, (AL_CONST char *s1, AL_CONST char *s2)); +AL_FUNC(char *, ustrzncpy, (char *dest, int size, AL_CONST char *src, int n)); +AL_FUNC(char *, ustrzncat, (char *dest, int size, AL_CONST char *src, int n)); +AL_FUNC(int, ustrncmp, (AL_CONST char *s1, AL_CONST char *s2, int n)); +AL_FUNC(int, ustricmp, (AL_CONST char *s1, AL_CONST char *s2)); +AL_FUNC(int, ustrnicmp, (AL_CONST char *s1, AL_CONST char *s2, int n)); +AL_FUNC(char *, ustrlwr, (char *s)); +AL_FUNC(char *, ustrupr, (char *s)); +AL_FUNC(char *, ustrchr, (AL_CONST char *s, int c)); +AL_FUNC(char *, ustrrchr, (AL_CONST char *s, int c)); +AL_FUNC(char *, ustrstr, (AL_CONST char *s1, AL_CONST char *s2)); +AL_FUNC(char *, ustrpbrk, (AL_CONST char *s, AL_CONST char *set)); +AL_FUNC(char *, ustrtok, (char *s, AL_CONST char *set)); +AL_FUNC(char *, ustrtok_r, (char *s, AL_CONST char *set, char **last)); +AL_FUNC(double, uatof, (AL_CONST char *s)); +AL_FUNC(long, ustrtol, (AL_CONST char *s, char **endp, int base)); +AL_FUNC(double, ustrtod, (AL_CONST char *s, char **endp)); +AL_FUNC(AL_CONST char *, ustrerror, (int err)); +AL_PRINTFUNC(int, uszprintf, (char *buf, int size, AL_CONST char *format, ...), 3, 4); +AL_FUNC(int, uvszprintf, (char *buf, int size, AL_CONST char *format, va_list args)); +AL_PRINTFUNC(int, usprintf, (char *buf, AL_CONST char *format, ...), 2, 3); + +#ifndef ustrdup + #ifdef FORTIFY + #define ustrdup(src) _ustrdup(src, Fortify_malloc) + #else + #define ustrdup(src) _ustrdup(src, malloc) + #endif +#endif + +#define ustrcpy(dest, src) ustrzcpy(dest, INT_MAX, src) +#define ustrcat(dest, src) ustrzcat(dest, INT_MAX, src) +#define ustrncpy(dest, src, n) ustrzncpy(dest, INT_MAX, src, n) +#define ustrncat(dest, src, n) ustrzncat(dest, INT_MAX, src, n) +#define uvsprintf(buf, format, args) uvszprintf(buf, INT_MAX, format, args) + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef ALLEGRO_UNICODE__H */ + + diff --git a/lib/allegro/include/bealleg.h b/lib/allegro/include/bealleg.h new file mode 100644 index 0000000..bc96c9e --- /dev/null +++ b/lib/allegro/include/bealleg.h @@ -0,0 +1,288 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * The Be Allegro Header File. + * + * Aren't you glad you used the BeOS header file? + * Don't you wish everybody did? + * + * By Jason Wilkins. + * + * See readme.txt for copyright information. + */ + +#ifndef BE_ALLEGRO_H +#define BE_ALLEGRO_H + +/* There is namespace cross-talk between the Be API and + Allegro, lets use my favorite namespace detergent. + "Kludge!" Now with 25% more hack. */ + +#ifdef __cplusplus +# define color_map al_color_map +# define drawing_mode al_drawing_mode +#endif + +#include "allegro.h" +#include "allegro/internal/aintern.h" + +#ifdef __cplusplus +# undef color_map +# undef drawing_mode +# undef MIN +# undef MAX +# undef TRACE +# undef ASSERT + +#ifdef DEBUGMODE +# define AL_ASSERT(condition) { if (!(condition)) al_assert(__FILE__, __LINE__); } +#else +# define AL_ASSERT(condition) +#endif + +#ifndef SCAN_DEPEND + #include +#endif + +#define BE_ALLEGRO_VIEW_DIRECT 1 +#define BE_ALLEGRO_VIEW_OVERLAY 2 + +#define LINE8_HOOK_NUM 3 +#define LINE16_HOOK_NUM 12 +#define LINE32_HOOK_NUM 4 +#define ARRAY8_HOOK_NUM 8 +#define ARRAY32_HOOK_NUM 9 +#define RECT8_HOOK_NUM 5 +#define RECT16_HOOK_NUM 16 +#define RECT32_HOOK_NUM 6 +#define INVERT_HOOK_NUM 11 +#define BLIT_HOOK_NUM 7 +#define SYNC_HOOK_NUM 10 + + + +typedef int32 (*LINE8_HOOK)(int32 startX, int32 endX, int32 startY, + int32 endY, uint8 colorIndex, bool clipToRect, int16 clipLeft, + int16 clipTop, int16 clipRight, int16 clipBottom); + +typedef int32 (*ARRAY8_HOOK)(indexed_color_line *array, + int32 numItems, bool clipToRect, int16 top, int16 right, + int16 bottom, int16 left); + +typedef int32 (*LINE16_HOOK)(int32 startX, int32 endX, int32 startY, + int32 endY, uint16 color, bool clipToRect, int16 clipLeft, + int16 clipTop, int16 clipRight, int16 clipBottom); + +typedef int32 (*LINE32_HOOK)(int32 startX, int32 endX, int32 startY, + int32 endY, uint32 color, bool clipToRect, int16 clipLeft, + int16 clipTop, int16 clipRight, int16 clipBottom); + +typedef int32 (*ARRAY32_HOOK)(rgb_color_line *array, + int32 numItems, bool clipToRect, int16 top, int16 right, + int16 bottom, int16 left); + +typedef int32 (*RECT8_HOOK)(int32 left, int32 top, int32 right, + int32 bottom, uint8 colorIndex); + +typedef int32 (*RECT16_HOOK)(int32 left, int32 top, int32 right, + int32 bottom, uint16 color); + +typedef int32 (*RECT32_HOOK)(int32 left, int32 top, int32 right, + int32 bottom, uint32 color); + +typedef int32 (*INVERT_HOOK)(int32 left, int32 top, int32 right, + int32 bottom); + +typedef int32 (*BLIT_HOOK)(int32 sourceX, int32 sourceY, + int32 destinationX, int32 destinationY, int32 width, + int32 height); + +typedef int32 (*SYNC_HOOK)(void); + + + +typedef struct HOOKS { + LINE8_HOOK draw_line_8; + LINE16_HOOK draw_line_16; + LINE32_HOOK draw_line_32; + ARRAY8_HOOK draw_array_8; + ARRAY32_HOOK draw_array_32; + RECT8_HOOK draw_rect_8; + RECT16_HOOK draw_rect_16; + RECT32_HOOK draw_rect_32; + INVERT_HOOK invert_rect; + BLIT_HOOK blit; + SYNC_HOOK sync; +} HOOKS; + + + +typedef struct { + int d, w, h; + uint32 mode; + uint32 space; +} BE_MODE_TABLE; + + + +class BeAllegroView + : public BView +{ + public: + BeAllegroView(BRect, const char *, uint32, uint32, int); + + void MessageReceived(BMessage *); + void Draw(BRect); + + private: + int flags; +}; + + + +class BeAllegroWindow + : public BWindow +{ + public: + BeAllegroWindow(BRect, const char *, window_look, window_feel, uint32, uint32, uint32, uint32, uint32); + ~BeAllegroWindow(); + + void MessageReceived(BMessage *); + bool QuitRequested(void); + void WindowActivated(bool); + + int screen_depth; + int screen_width; + int screen_height; + BBitmap *buffer; + BBitmap *aux_buffer; + bool dying; + thread_id drawing_thread_id; +}; + + + +class BeAllegroDirectWindow + : public BDirectWindow +{ + public: + BeAllegroDirectWindow(BRect, const char *, window_look, window_feel, uint32, uint32, uint32, uint32, uint32); + ~BeAllegroDirectWindow(); + + void DirectConnected(direct_buffer_info *); + void MessageReceived(BMessage *); + bool QuitRequested(void); + void WindowActivated(bool); + + void *screen_data; + uint32 screen_pitch; + uint32 screen_height; + uint32 screen_depth; + + void *display_data; + uint32 display_pitch; + uint32 display_depth; + + uint32 num_rects; + clipping_rect *rects; + clipping_rect window; + COLORCONV_BLITTER_FUNC *blitter; + + bool connected; + bool dying; + BLocker *locker; + thread_id drawing_thread_id; +}; + + + +class BeAllegroScreen + : public BWindowScreen +{ + public: + BeAllegroScreen(const char *title, uint32 space, status_t *error, bool debugging = false); + + void MessageReceived(BMessage *); + bool QuitRequested(void); + void ScreenConnected(bool connected); +}; + + + +class BeAllegroOverlay + : public BWindow +{ + public: + BeAllegroOverlay(BRect, const char *, window_look, window_feel, uint32, uint32, uint32, uint32, uint32); + ~BeAllegroOverlay(); + + void MessageReceived(BMessage *); + bool QuitRequested(void); + void WindowActivated(bool); + + BBitmap *buffer; + rgb_color color_key; +}; + + + +class BeAllegroApp + : public BApplication +{ + public: + BeAllegroApp(const char *signature); + + bool QuitRequested(void); + void ReadyToRun(void); +}; + + + +AL_VAR(BeAllegroApp, *_be_allegro_app); +AL_VAR(BeAllegroWindow, *_be_allegro_window); +AL_VAR(BeAllegroDirectWindow, *_be_allegro_direct_window); +AL_VAR(BeAllegroView, *_be_allegro_view); +AL_VAR(BeAllegroScreen, *_be_allegro_screen); +AL_VAR(BeAllegroOverlay, *_be_allegro_overlay); +AL_VAR(BWindow, *_be_window); +AL_VAR(BMidiSynth, *_be_midisynth); +AL_VAR(sem_id, _be_sound_stream_lock); +AL_VAR(sem_id, _be_fullscreen_lock); +AL_VAR(sem_id, _be_window_lock); +AL_VAR(sem_id, _be_mouse_view_attached); +AL_VAR(BWindow, *_be_mouse_window); +AL_VAR(BView, *_be_mouse_view); +AL_VAR(int, _be_mouse_z); +AL_VAR(bool, _be_mouse_window_mode); +AL_VAR(HOOKS, _be_hooks); +AL_VAR(int, _be_switch_mode); +AL_VAR(volatile int, _be_lock_count); +AL_VAR(volatile int, _be_focus_count); +AL_VAR(volatile bool, _be_gfx_initialized); +AL_VAR(int, *_be_dirty_lines); + +AL_ARRAY(AL_CONST BE_MODE_TABLE, _be_mode_table); + + +extern int32 (*_be_sync_func)(); +extern void (*_be_window_close_hook)(); + +void _be_terminate(thread_id caller, bool exit_caller); +void _be_gfx_set_truecolor_shifts(); +void _be_change_focus(bool active); +bool _be_handle_window_close(const char *title); + + + +#endif /* ifdef C++ */ + + + +#endif /* ifndef BE_ALLEGRO_H */ diff --git a/lib/allegro/include/linalleg.h b/lib/allegro/include/linalleg.h new file mode 100644 index 0000000..79373d6 --- /dev/null +++ b/lib/allegro/include/linalleg.h @@ -0,0 +1,29 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Linux header file for the Allegro library. + * + * This file no longer contains anything. At the moment, + * it exists only for backwards compatibility. + * + * See readme.txt for copyright information. + */ + + +#ifndef LIN_ALLEGRO_H +#define LIN_ALLEGRO_H + +/* + * THIS IS AN EX-PARROT!! + */ + +#endif /* ifndef LIN_ALLEGRO_H */ + + diff --git a/lib/allegro/include/macalleg.h b/lib/allegro/include/macalleg.h new file mode 100644 index 0000000..2c3b795 --- /dev/null +++ b/lib/allegro/include/macalleg.h @@ -0,0 +1,129 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * MacOs header file for the Allegro library. + * This should be included by everyone and everything. + * + * By Ronaldo Hideki Yamada. + * + * See readme.txt for copyright information. + */ + + +#ifndef MAC_ALLEGRO_H +#define MAC_ALLEGRO_H + +#ifndef ALLEGRO_H +#error Please include allegro.h before macalleg.h! +#endif + +#if (!defined SCAN_EXPORT) && (!defined SCAN_DEPEND) +#endif + +#include //theses includes aways are needed in normal mac programs +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "allegro/platform/macdef.h" + + +#ifdef __cplusplus + extern "C" { +#endif + +typedef BITMAP BITMAP; + +typedef struct{ + CGrafPtr cg; + long rowBytes; + unsigned char* first; + unsigned char* last; + long flags; + int cachealigned; + Ptr data; + }mac_bitmap; + +#define MEMORY_ALIGN 4 +#define GETMACBITMAP(bmp)((mac_bitmap*)(bmp->extra)) + +#pragma options align=mac68k +typedef struct mac_sample{ + short formatType; + short numberSyns; + short idFirstSynth; + long INIToptions; + short numCommands; + short command1; + short param1; + long param2; + SoundHeader s; + }mac_sample; +typedef mac_sample **hmac_sample; +#pragma options align=reset + +typedef struct mac_voice{ + SndChannelPtr channel; + SndListHandle sample; + short headsize; + long headeroff; + int loop; + int loop_start; + int loop_end; + int vol; + int pan; + int frequency; + SAMPLE * al_sample; + }mac_voice; + + +AL_VAR(QDGlobals , qd); +AL_VAR(GFX_VTABLE,__mac_sys_vtable8); +AL_VAR(GFX_VTABLE,__mac_sys_vtable15); +AL_VAR(GFX_VTABLE,__mac_sys_vtable24); + +extern void _mac_lock(void *address, unsigned long size); +extern void _mac_unlock(void *address, unsigned long size); + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef MAC_ALLEGRO_H */ + + diff --git a/lib/allegro/include/osxalleg.h b/lib/allegro/include/osxalleg.h new file mode 100644 index 0000000..15351a5 --- /dev/null +++ b/lib/allegro/include/osxalleg.h @@ -0,0 +1,38 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Main header file for the MacOS X Allegro library port. + * Any OS X Allegro specific function is declared here. + * + * By Angelo Mottola. + * + * See readme.txt for copyright information. + */ + + +#ifndef OSX_ALLEGRO_H +#define OSX_ALLEGRO_H + +#ifndef ALLEGRO_H +#error Please include allegro.h before osxalleg.h! +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/lib/allegro/include/qnxalleg.h b/lib/allegro/include/qnxalleg.h new file mode 100644 index 0000000..5b02cc9 --- /dev/null +++ b/lib/allegro/include/qnxalleg.h @@ -0,0 +1,41 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Header file for the QNX Allegro library port. + * + * This doesn't need to be included; it prototypes functions you + * can use to control the library more closely. + */ + + +#ifndef QNX_ALLEGRO_H +#define QNX_ALLEGRO_H + +#ifndef ALLEGRO_H +#error Please include allegro.h before qnxalleg.h! +#endif + +#ifndef SCAN_DEPEND + #include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +AL_FUNC(PtWidget_t *, qnx_get_window, (void)); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/allegro/include/winalleg.h b/lib/allegro/include/winalleg.h new file mode 100644 index 0000000..b422a84 --- /dev/null +++ b/lib/allegro/include/winalleg.h @@ -0,0 +1,117 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * Windows header file for the Allegro library. + * + * It must be included by Allegro programs that need to use + * direct Win32 API calls and by Win32 programs that need to + * interface with Allegro. + * + * By Shawn Hargreaves. + * + * See readme.txt for copyright information. + */ + + +#ifndef WIN_ALLEGRO_H +#define WIN_ALLEGRO_H + +#ifndef ALLEGRO_H + #error Please include allegro.h before winalleg.h! +#endif + +#ifdef ALLEGRO_SRC + #define WIN32_LEAN_AND_MEAN /* to save compilation time */ +#endif + + + +/* bodges to avoid conflicts between Allegro and Windows */ +#define BITMAP WINDOWS_BITMAP + +#if (!defined SCAN_EXPORT) && (!defined SCAN_DEPEND) + #ifdef ALLEGRO_AND_MFC + #ifdef DEBUGMODE + #define AL_ASSERT(condition) { if (!(condition)) al_assert(__FILE__, __LINE__); } + #define AL_TRACE al_trace + #else + #define AL_ASSERT(condition) + #define AL_TRACE 1 ? (void) 0 : al_trace + #endif + + #undef TRACE + #undef ASSERT + + #include + #else + #include + #endif +#endif + +#define WINDOWS_RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) + +#undef BITMAP +#undef RGB + + + +/* Allegro's Win32 specific interface */ +#ifdef __cplusplus + extern "C" { +#endif + + +/* external graphics driver support */ +typedef struct WIN_GFX_DRIVER { + int has_backing_store; + AL_METHOD(void, switch_in, (void)); + AL_METHOD(void, switch_out, (void)); + AL_METHOD(void, enter_sysmode, (void)); + AL_METHOD(void, exit_sysmode, (void)); + AL_METHOD(void, move, (int x, int y, int w, int h)); + AL_METHOD(void, iconify, (void)); + AL_METHOD(void, paint, (RECT *rect)); +} WIN_GFX_DRIVER; + +AL_VAR(WIN_GFX_DRIVER *, win_gfx_driver); + +AL_FUNC(void, win_grab_input, (void)); + + +/* external window support */ +AL_FUNC(HWND, win_get_window, (void)); +AL_FUNC(void, win_set_window, (HWND wnd)); +AL_FUNC(void, win_set_wnd_create_proc, (AL_METHOD(HWND, proc, (WNDPROC)))); + + +/* GDI to DirectDraw routines */ +AL_FUNC(HDC, win_get_dc, (BITMAP *bmp)); +AL_FUNC(void, win_release_dc, (BITMAP *bmp, HDC dc)); + + +/* GDI routines */ +AL_FUNC(void, set_gdi_color_format, (void)); +AL_FUNC(void, set_palette_to_hdc, (HDC dc, PALETTE pal)); +AL_FUNC(HPALETTE, convert_palette_to_hpalette, (PALETTE pal)); +AL_FUNC(void, convert_hpalette_to_palette, (HPALETTE hpal, PALETTE pal)); +AL_FUNC(HBITMAP, convert_bitmap_to_hbitmap, (BITMAP *bitmap)); +AL_FUNC(BITMAP *, convert_hbitmap_to_bitmap, (HBITMAP bitmap)); +AL_FUNC(void, draw_to_hdc, (HDC dc, BITMAP *bitmap, int x, int y)); +AL_FUNC(void, blit_to_hdc, (BITMAP *bitmap, HDC dc, int src_x, int src_y, int dest_x, int dest_y, int w, int h)); +AL_FUNC(void, stretch_blit_to_hdc, (BITMAP *bitmap, HDC dc, int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, int dest_w, int dest_h)); +AL_FUNC(void, blit_from_hdc, (HDC dc, BITMAP *bitmap, int src_x, int src_y, int dest_x, int dest_y, int w, int h)); +AL_FUNC(void, stretch_blit_from_hdc, (HDC hdc, BITMAP *bitmap, int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, int dest_w, int dest_h)); + + +#ifdef __cplusplus + } +#endif + +#endif /* ifndef WIN_ALLEGRO_H */ diff --git a/lib/allegro/include/xalleg.h b/lib/allegro/include/xalleg.h new file mode 100644 index 0000000..c45baa6 --- /dev/null +++ b/lib/allegro/include/xalleg.h @@ -0,0 +1,176 @@ +/* ______ ___ ___ + * /\ _ \ /\_ \ /\_ \ + * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ + * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ + * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ + * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ + * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ + * /\____/ + * \_/__/ + * + * X header file for the Allegro library. + * + * This prototypes some things which might be useful to + * the calling application, but you don't need it. + */ + + +#ifndef X_ALLEGRO_H +#define X_ALLEGRO_H + +#ifndef ALLEGRO_H +#error Please include allegro.h before xalleg.h! +#endif + + +#include "allegro/internal/aintern.h" +#include "allegro/platform/aintunix.h" + +#include +#include +#include +#include +#include + +#ifdef ALLEGRO_XWINDOWS_WITH_SHM +#include +#include +#include +#endif + +#ifdef ALLEGRO_XWINDOWS_WITH_XF86VIDMODE +#include +#endif + +#ifdef ALLEGRO_XWINDOWS_WITH_XCURSOR +#include +#endif + + + +#ifdef __cplusplus + extern "C" { +#endif + +/* X-Windows resources used by the library. */ +extern struct _xwin_type +{ + Display *display; + volatile int lock_count; + int screen; + Window window; + GC gc; + Visual *visual; + Colormap colormap; + XImage *ximage; +#ifdef ALLEGRO_XWINDOWS_WITH_XCURSOR + XcursorImage *xcursor_image; + XcursorBool support_argb_cursor; +#endif + Cursor cursor; + int cursor_shape; + int hw_cursor_ok; + + void (*screen_to_buffer)(int sx, int sy, int sw, int sh); + void (*set_colors)(AL_CONST PALETTE p, int from, int to); + + unsigned char *screen_data; + unsigned char **screen_line; + unsigned char **buffer_line; + + int scroll_x; + int scroll_y; + + int window_width; + int window_height; + int window_depth; + + int screen_width; + int screen_height; + int screen_depth; + + int virtual_width; + int virtual_height; + + int mouse_warped; + int keycode_to_scancode[256]; + + int matching_formats; + int fast_visual_depth; + int visual_is_truecolor; + + int rsize; + int gsize; + int bsize; + int rshift; + int gshift; + int bshift; + + unsigned long cmap[0x1000]; + unsigned long rmap[0x100]; + unsigned long gmap[0x100]; + unsigned long bmap[0x100]; + +#ifdef ALLEGRO_XWINDOWS_WITH_SHM + XShmSegmentInfo shminfo; +#endif + int use_shm; + + int in_dga_mode; /* 0=no, 2=DGA2 */ + + int keyboard_grabbed; + int mouse_grabbed; + +#ifdef ALLEGRO_XWINDOWS_WITH_XF86VIDMODE + XF86VidModeModeInfo **modesinfo; + int num_modes; + int mode_switched; /* only kept around and set for ABI compat */ + int override_redirected; /* no longer used, kept for ABI compat */ +#endif + + char window_title[1024]; + char application_name[1024]; + char application_class[1024]; + + int drawing_mode_ok; + +#ifdef ALLEGRO_MULTITHREADED + void *mutex; +#endif + + void (*close_button_callback)(void); + + /* These are at the end of the struct to maintain ABI compatibility with + * allegro-4.2.0 (if and only if compiled with the same configuration). + * Notice that IMHO apps really should not be using _xwin, but we export it, + * so its fair game. + */ +#ifdef ALLEGRO_XWINDOWS_WITH_XF86VIDMODE + XF86VidModeModeInfo *orig_modeinfo; +#endif + /* Separate fullscreen and managed window id's, see + * _xwin_private_create_windo* in src/x/xwin.c for more details. + */ + Window fs_window; + Window wm_window; +} _xwin; + + + +AL_FUNCPTR (int, _xwin_window_creator, (void)); +AL_FUNCPTR (void, _xwin_window_defaultor, (void)); +AL_FUNCPTR (void, _xwin_window_redrawer, (int, int, int, int)); +AL_FUNCPTR (void, _xwin_input_handler, (void)); + +AL_FUNCPTR (void, _xwin_keyboard_callback, (int, int)); + +AL_FUNC(void, xwin_set_window_name, (AL_CONST char *name, AL_CONST char *group)); + + + +#ifdef __cplusplus + } +#endif + +#endif + diff --git a/lib/allegro/lib/alld.lib b/lib/allegro/lib/alld.lib new file mode 100644 index 0000000..db68213 Binary files /dev/null and b/lib/allegro/lib/alld.lib differ diff --git a/lib/allegro/lib/alld42.pdb b/lib/allegro/lib/alld42.pdb new file mode 100644 index 0000000..d668321 Binary files /dev/null and b/lib/allegro/lib/alld42.pdb differ diff --git a/lib/allegro/lib/alld_s.lib b/lib/allegro/lib/alld_s.lib new file mode 100644 index 0000000..2e1a8a8 Binary files /dev/null and b/lib/allegro/lib/alld_s.lib differ diff --git a/lib/allegro/lib/alleg.lib b/lib/allegro/lib/alleg.lib new file mode 100644 index 0000000..654573f Binary files /dev/null and b/lib/allegro/lib/alleg.lib differ diff --git a/lib/allegro/lib/alleg_s.lib b/lib/allegro/lib/alleg_s.lib new file mode 100644 index 0000000..1a315ae Binary files /dev/null and b/lib/allegro/lib/alleg_s.lib differ diff --git a/lib/allegro/lib/alleg_s_crt.lib b/lib/allegro/lib/alleg_s_crt.lib new file mode 100644 index 0000000..2726770 Binary files /dev/null and b/lib/allegro/lib/alleg_s_crt.lib differ diff --git a/lib/allegro/lib/allp.lib b/lib/allegro/lib/allp.lib new file mode 100644 index 0000000..05440ec Binary files /dev/null and b/lib/allegro/lib/allp.lib differ diff --git a/lib/allegro/lib/allp_s.lib b/lib/allegro/lib/allp_s.lib new file mode 100644 index 0000000..8540442 Binary files /dev/null and b/lib/allegro/lib/allp_s.lib differ diff --git a/lib/allegro/readme.txt b/lib/allegro/readme.txt new file mode 100644 index 0000000..40a1be4 --- /dev/null +++ b/lib/allegro/readme.txt @@ -0,0 +1 @@ +Allegro Version: 4.2.1 diff --git a/lib/fmodapi375win/README.TXT b/lib/fmodapi375win/README.TXT new file mode 100644 index 0000000..2262f1d --- /dev/null +++ b/lib/fmodapi375win/README.TXT @@ -0,0 +1,100 @@ +---------------------------------------------------------------------------- + FMOD 3.75 + Copyright (c) Firelight Technologies Pty, Ltd, + 1994 - 2004 +---------------------------------------------------------------------------- + + http://www.fmod.org + + +---------------------------------------------------------------------------- +WIN32 specific issues. +---------------------------------------------------------------------------- + +Remember to use the correct import library! + +MSVC Users - use FMODVC.LIB +METROWERKS/CODEWARRIOR Users - use FMODVC.LIB +WATCOM Users - use FMODWC.LIB +BORLAND Users - use FMODBC.LIB +LCC-WIN32 Users - use FMODLCC.LIB +DEV-C++, MINGW AND CYGWIN Users - use LIBFMOD.A + +Linux users - link with libfmod-3.75.so (i.e. gcc file.c -lfmod-3.75) +Delphi Users - use FMOD.PAS +Visual Basic Users - use FMOD.BAS + +---------------------------------------------------------------------------- +ASIO Config +---------------------------------------------------------------------------- +FMOD ignores FSOUND_SetBufferSize in ASIO mode. It relies on settings +provided by the ASIO control panel supplied with the driver. In the tools +directory of the FMOD api, you will find an asioconfig.exe tool which allows +you to configure the ASIO driver by doubleclicking on the appropriate driver. + +---------------------------------------------------------------------------- +FMOD End User License Agreement +---------------------------------------------------------------------------- + +FMOD's names, sources, documentation and binaries contained within the +distributed archive are copyright © Firelight Technologies, Pty, Ltd. +1994-2004. + +The contents of the FMOD distribution archive may not be redistributed, +reproduced, modified, transmitted, broadcast, published or adapted in any +way, shape or form, without the prior written consent of the owner, +Firelight Technologies, be it by tangible or non tangible media. + +The fmod.dll file may be redistributed without the authors prior permission, +and must remain unmodified. The use of dll 'static linking' tools that aim +to hide the fmod library are forbidden. + +FMOD may not be used in a commercial product, or product that directly or +indirectly receives income with the aid of the FMOD sound library, without +a commercial license from Firelight Technologies. Releasing a product +without a commercial license in this instance is a breach of the FMOD EULA +and parties who violate this license will be prosecuted under the full +extent of the law. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------------- +Ogg Vorbis License +---------------------------------------------------------------------------- +Portions Copyright (c) 2001, Xiphophorus + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of the Xiphophorus nor the names of its contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/fmodapi375win/api/delphi/fmod.dcu b/lib/fmodapi375win/api/delphi/fmod.dcu new file mode 100644 index 0000000..30216cc Binary files /dev/null and b/lib/fmodapi375win/api/delphi/fmod.dcu differ diff --git a/lib/fmodapi375win/api/delphi/fmod.pas b/lib/fmodapi375win/api/delphi/fmod.pas new file mode 100644 index 0000000..93dbfc8 --- /dev/null +++ b/lib/fmodapi375win/api/delphi/fmod.pas @@ -0,0 +1,783 @@ +{ =============================================================================================== } +{ FMOD Main header file. Copyright (c), Firelight Technologies Pty, Ltd. 1999-2004. } +{ =============================================================================================== } +{ + NOTE: For the demos to run you must have either fmod.dll (in Windows) + or libfmod-3.75.so (in Linux) installed. + + In Windows, copy the fmod.dll file found in the api directory to either of + the following locations (in order of preference) + - your application directory + - Windows\System (95/98) or WinNT\System32 (NT/2000/XP) + + In Linux, make sure you are signed in as root and copy the libfmod-3.75.so + file from the api directory to your /usr/lib/ directory. + Then via a command line, navigate to the /usr/lib/ directory and create + a symbolic link between libfmod-3.75.so and libfmod.so. This is done with + the following command (assuming you are in /usr/lib/)... + ln -s libfmod-3.75.so libfmod.so. +} +{ =============================================================================================== } + +{$IFDEF FPC} + {$MODE DELPHI} + {$IFDEF WIN32} + {$DEFINE MSWINDOWS} + {$ENDIF} +{$ENDIF} + +unit fmod; + +interface + +uses +{$IFDEF MSWINDOWS} + Windows, +{$ENDIF} + fmodtypes; + +{ + Disable warning for unsafe types in Delphi 7 +} +{$IFDEF VER150} +{$WARN UNSAFE_TYPE OFF} +{$ENDIF} + +//=============================================================================================== +// FUNCTION PROTOTYPES +//=============================================================================================== + +{ ================================== } +{ Library load/unload functions. } +{ ================================== } + +{ + If no library name is passed to FMOD_Load, then the default library name + used. These are stub functions. +} + +function FMOD_Load(LibName: PChar): Boolean; +procedure FMOD_Unload; + +{ ================================== } +{ Initialization / Global functions. } +{ ================================== } + +{ + PRE - FSOUND_Init functions. These can't be called after FSOUND_Init is + called (they will fail). They set up FMOD system functionality. +} + +function FSOUND_SetOutput(OutputType: TFSoundOutputTypes): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetDriver(Driver: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetMixer(Mixer: TFSoundMixerTypes): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetBufferSize(LenMs: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetHWND(Hwnd: THandle): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetMinHardwareChannels(Min: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetMaxHardwareChannels(Max: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetMemorySystem(Pool: Pointer; PoolLen: Integer; + UserAlloc: TFSoundAllocCallback; + UserRealloc: TFSoundReallocCallback; + UserFree: TFSoundFreeCallback): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Main initialization / closedown functions. + Note : Use FSOUND_INIT_USEDEFAULTMIDISYNTH with FSOUND_Init for software override + with MIDI playback. + : Use FSOUND_INIT_GLOBALFOCUS with FSOUND_Init to make sound audible no matter + which window is in focus. (FSOUND_OUTPUT_DSOUND only) +} + +function FSOUND_Init(MixRate: Integer; MaxSoftwareChannels: Integer; Flags: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_Close; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Runtime system level functions +} + +procedure FSOUND_Update; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; // This is called to update 3d sound / non-realtime output + +procedure FSOUND_SetSpeakerMode(SpeakerMode: Cardinal); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_SetSFXMasterVolume(Volume: Integer); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_SetPanSeperation(PanSep: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_File_SetCallbacks(OpenCallback: TFSoundOpenCallback; + CloseCallback: TFSoundCloseCallback; + ReadCallback: TFSoundReadCallback; + SeekCallback: TFSoundSeekCallback; + TellCallback: TFSoundTellCallback); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + System information functions +} + +function FSOUND_GetError: TFModErrors; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetVersion: Single; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetOutput: TFSoundOutputTypes; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetOutputHandle: Pointer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetDriver: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetMixer: TFSoundMixerTypes; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetNumDrivers: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetDriverName(Id: Integer): PChar; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetDriverCaps(Id: Integer; var Caps: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetOutputRate: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetMaxChannels: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetMaxSamples: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetSpeakerMode: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetSFXMasterVolume: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetNumHWChannels(var num2d: Integer; var num3d: Integer; var total: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetChannelsPlaying: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetCPUUsage: Single; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_GetMemoryStats(var CurrentAlloced: Cardinal; var MaxAlloced: Cardinal); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ =================================== } +{ Sample management / load functions. } +{ =================================== } + +{ + Sample creation and management functions + Note : Use FSOUND_LOADMEMORY flag with FSOUND_Sample_Load to load from memory. + Use FSOUND_LOADRAW flag with FSOUND_Sample_Load to treat as as raw pcm data. +} + +function FSOUND_Sample_Load(Index: Integer; const NameOrData: PChar; Mode: Cardinal; Offset: Integer; Length: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_Alloc(Index: Integer; Length: Integer; Mode: Cardinal; DefFreq: Integer; DefVol: Integer; DefPan: Integer; DefPri: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_Sample_Free(Sptr: PFSoundSample); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_Upload(Sptr: PFSoundSample; SrcData: Pointer; Mode: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_Lock(Sptr: PFSoundSample; Offset: Integer; Length: Integer; var Ptr1: Pointer; var Ptr2: Pointer; var Len1: Cardinal; var Len2: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_Unlock(Sptr: PFSoundSample; Ptr1: Pointer; Ptr2: Pointer; Len1: Cardinal; Len2: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Sample control functions +} + +function FSOUND_Sample_SetMode(Sptr: PFSoundSample; Mode: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_SetLoopPoints(Sptr: PFSoundSample; LoopStart, LoopEnd: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_SetDefaults(Sptr: PFSoundSample; DefFreq, DefVol, DefPan, DefPri: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_SetDefaultsEx(Sptr: PFSoundSample; DefFreq, DefVol, DefPan, DefPri, VarFreq, VarVol, VarPan: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_SetMinMaxDistance(Sptr: PFSoundSample; Min, Max: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_SetMaxPlaybacks(Sptr: PFSoundSample; Max: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Sample information functions +} + +function FSOUND_Sample_Get(SampNo: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_GetName(Sptr: PFSoundSample): PCHAR; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_GetLength(Sptr: PFSoundSample): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_GetLoopPoints(Sptr: PFSoundSample; var LoopStart: Integer; var LoopEnd: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_GetDefaults(Sptr: PFSoundSample; var DefFreq: Integer; var DefVol: Integer; var DefPan: Integer; var DefPri: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_GetDefaultsEx(Sptr: PFSoundSample; var DefFreq: Integer; var DefVol: Integer; var DefPan: Integer; var DefPri: Integer;var VarFreq: Integer; var VarVol: Integer; var VarPan: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_GetMode(Sptr: PFSoundSample): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Sample_GetMinMaxDistance(Sptr: PFSoundSample; var Min: Single; var Max: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ============================ } +{ Channel control functions. } +{ ============================ } + +{ + Playing and stopping sounds. + Note : Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. + Use FSOUND_ALL as the 'channel' variable to control ALL channels with one function call! +} + +function FSOUND_PlaySound(Channel: Integer; Sptr: PFSoundSample): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_PlaySoundEx(Channel: Integer; Sptr: PFSoundSample; Dsp: PFSoundDSPUnit; StartPaused: ByteBool): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_StopSound(Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Functions to control playback of a channel. + Note : FSOUND_ALL can be used on most of these functions as a channel value. +} + +function FSOUND_SetFrequency(Channel: Integer; Freq: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetVolume(Channel: Integer; Vol: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetVolumeAbsolute(Channel: Integer; Vol: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetPan(Channel: Integer; Pan: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetSurround(Channel: Integer; Surround: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetMute(Channel: Integer; Mute: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetPriority(Channel: Integer; Priority: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetReserved(Channel: Integer; Reserved: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetPaused(Channel: Integer; Paused: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetLoopMode(Channel: Integer; LoopMode: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_SetCurrentPosition(Channel: Integer; Offset: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_3D_SetAttributes(Channel: Integer; Pos: PFSoundVector; Vel: PFSoundVector): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_3D_SetMinMaxDistance(Channel: Integer; Min: Single; Max: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Channel information functions +} + +function FSOUND_IsPlaying(Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetFrequency(Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetVolume(Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetAmplitude(Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetPan(Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetSurround(Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetMute(Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetPriority(Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetReserved(Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetPaused(Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetLoopMode(Channel: Integer): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetCurrentPosition(Channel: Integer): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetCurrentSample(Channel: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetCurrentLevels(Channel: Integer; l, r: PSingle): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetNumSubChannels(Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_GetSubChannel(Channel: Integer; SubChannel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_3D_GetAttributes(Channel: Integer; Pos: PFSoundVector; Vel: PFSoundVector): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_3D_GetMinMaxDistance(Channel: Integer; var Min: Single; var Max: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ =================== } +{ 3D sound functions. } +{ =================== } + +{ + See also 3d sample and channel based functions above. + Call FSOUND_Update once a frame to process 3d information. +} + +procedure FSOUND_3D_Listener_SetCurrent(current: Integer); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_3D_Listener_SetAttributes(Pos: PFSoundVector; Vel: PFSoundVector; + fx: Single; fy: Single; fz: Single; + tx: Single; ty: Single; tz: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_3D_Listener_GetAttributes(Pos: PFSoundVector; Vel: PFSoundVector; + fx: PSingle; fy: PSingle; fz: PSingle; + tx: PSingle; ty: PSingle; tz: PSingle); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_3D_SetDopplerFactor(Scale: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_3D_SetDistanceFactor(Scale: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_3D_SetRolloffFactor(Scale: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ =================== } +{ FX functions. } +{ =================== } + +{ + Functions to control DX8 only effects processing. + + - FX enabled samples can only be played once at a time, not multiple times at once. + - Sounds have to be created with FSOUND_HW2D or FSOUND_HW3D for this to work. + - FSOUND_INIT_ENABLESYSTEMCHANNELFX can be used to apply hardware effect processing to the + global mixed output of FMOD's software channels. + - FSOUND_FX_Enable returns an FX handle that you can use to alter fx parameters. + - FSOUND_FX_Enable can be called multiple times in a row, even on the same FX type, + it will return a unique handle for each FX. + - FSOUND_FX_Enable cannot be called if the sound is playing or locked. + - FSOUND_FX_Disable must be called to reset/clear the FX from a channel. +} + +function FSOUND_FX_Enable(Channel: Integer; Fx: TFSoundFXModes): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_Disable(Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_FX_SetChorus(FXId: Integer; WetDryMix, Depth, Feedback, Frequency: Single; Waveform: Integer; Delay: Single; Phase: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_SetCompressor(FXId: Integer; Gain, Attack, Release, Threshold, Ratio, Predelay: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_SetDistortion(FXId: Integer; Gain, Edge, PostEQCenterFrequency, PostEQBandwidth, PreLowpassCutoff: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_SetEcho(FXId: Integer; WetDryMix, Feedback, LeftDelay, RightDelay: Single; PanDelay: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_SetFlanger(FXId: Integer; WetDryMix, Depth, Feedback, Frequency: Single; Waveform: Integer; Delay: Single; Phase: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_SetGargle(FXId, RateHz, WaveShape: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_SetI3DL2Reverb(FXId, Room, RoomHF: Integer; RoomRolloffFactor, DecayTime, DecayHFRatio: Single; Reflections: Integer; ReflectionsDelay: Single; Reverb: Integer; ReverbDelay, Diffusion, Density, HFReference: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_SetParamEQ(FXId: Integer; Center, Bandwidth, Gain: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_FX_SetWavesReverb(FXId: Integer; InGain, ReverbMix, ReverbTime, HighFreqRTRatio: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ========================= } +{ File Streaming functions. } +{ ========================= } + +{ + Note : Use FSOUND_LOADMEMORY flag with FSOUND_Stream_Open to stream from memory. + Use FSOUND_LOADRAW flag with FSOUND_Stream_Open to treat stream as raw pcm data. + Use FSOUND_MPEGACCURATE flag with FSOUND_Stream_Open to open mpegs in 'accurate mode' for settime/gettime/getlengthms. + Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. +} + +function FSOUND_Stream_SetBufferSize(Ms: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_Stream_Open(const name_or_data: PChar; Mode: Cardinal; Offset: Integer; Length: Integer): PFSoundStream; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_Create(Callback: TFSoundStreamCallback; Length: Integer; Mode: Cardinal; SampleRate: Integer; UserData: Integer): PFSoundStream; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_Close(Stream: PFSoundStream): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_Stream_Play(Channel: Integer; Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_PlayEx(Channel: Integer; Stream: PFSoundStream; Dsp: PFSoundDSPUnit; StartPaused: ByteBool): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_Stop(Stream: PFSoundStream): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_Stream_SetPosition(Stream: PFSoundStream; Position: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetPosition(Stream: PFSoundStream): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_SetTime(Stream: PFSoundStream; Ms: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetTime(Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetLength(Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetLengthMs(Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_Stream_SetMode(Stream: PFSoundStream; mode: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetMode(Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_SetLoopPoints(Stream: PFSoundStream; LoopStartPCM, LoopEndPCM: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_SetLoopCount(Stream: PFSoundStream; Count: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetOpenState(Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetSample(Stream: PFSoundStream): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_CreateDSP(Stream: PFSoundStream; Callback: TFSoundDSPCallback; Priority: Integer; Param: Integer): PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_Stream_SetEndCallback(Stream: PFSoundStream; Callback: TFSoundStreamCallback; UserData: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_SetSyncCallback(Stream: PFSoundStream; Callback: TFSoundStreamCallback; UserData: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_Stream_AddSyncPoint(Stream: PFSoundStream; PCMOffset: Cardinal; Name: PChar): PFSyncPoint; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_DeleteSyncPoint(Point: PFSyncPoint): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetNumSyncPoints(Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetSyncPoint(Stream: PFSoundStream; Index: Integer): PFSyncPoint; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetSyncPointInfo(Point: PFSyncPoint; var PCMOffset: Cardinal): PCHAR; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_Stream_SetSubStream(Stream: PFSoundStream; Index: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetNumSubStreams(Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_SetSubStreamSentence(Stream: PFSoundStream; var SentenceList: Cardinal; NumItems: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_Stream_GetNumTagFields(Stream: PFSoundStream; var Num: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_GetTagField(Stream: PFSoundStream; Num: Integer; var TagType: TFSoundTagFieldType; var Name: PChar; var Value: Pointer; var Length: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_FindTagField(Stream: PFSoundStream; TagType: TFSoundTagFieldType; Name: PChar; var Value: Pointer; var Length: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Internet streaming functions +} + +function FSOUND_Stream_Net_SetProxy(Proxy: PChar): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_Net_GetLastServerStatus(): PChar; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_Net_SetBufferProperties(BufferSize: Integer; PreBuffer_Percent: Integer; ReBuffer_Percent: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_Net_GetBufferProperties(var Buffersize: Integer; var PreBuffer_Percent: Integer; var ReBuffer_Percent: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_Net_SetMetadataCallback(Stream: PFSoundStream; Callback: TFMetaDataCallback; UserData: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Stream_Net_GetStatus(Stream: PFSoundStream; var Status: TFSoundStreamNetStatus; var BufferPercentUsed: Integer; var BitRate: Integer; var Flags: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ =================== } +{ CD audio functions. } +{ =================== } + +{ + Note : 0 = default cdrom. Otherwise specify the drive letter, for example. 'D'. +} + +function FSOUND_CD_Play(Drive: Byte; Track: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_CD_SetPlayMode(Drive: Byte; Mode: Integer); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_Stop(Drive: Byte): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_SetPaused(Drive: Byte; Paused: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_SetVolume(Drive: Byte; Volume: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_SetTrackTime(Drive: Byte; ms: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_OpenTray(Drive: Byte; Open: Byte): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FSOUND_CD_GetPaused(Drive: Byte): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_GetTrack(Drive: Byte): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_GetNumTracks(Drive: Byte): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_GetVolume(Drive: Byte): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_GetTrackLength(Drive: Byte; Track: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_CD_GetTrackTime(Drive: Byte): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ============== } +{ DSP functions. } +{ ============== } + + +{ + DSP Unit control and information functions. +} + +function FSOUND_DSP_Create(Callback: TFSoundDSPCallback; Priority: Integer; Param: Integer): PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_DSP_Free(DSPUnit: PFSoundDSPUnit); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_DSP_SetPriority(DSPUnit: PFSoundDSPUnit; Priority: Integer); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_DSP_GetPriority(DSPUnit: PFSoundDSPUnit): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_DSP_SetActive(DSPUnit: PFSoundDSPUnit; Active: ByteBool); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_DSP_GetActive(DSPUnit: PFSoundDSPUnit): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Functions to get hold of FSOUND 'system DSP unit' handles. +} + +function FSOUND_DSP_GetClearUnit: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_DSP_GetSFXUnit: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_DSP_GetMusicUnit: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_DSP_GetFFTUnit: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_DSP_GetClipAndCopyUnit: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Miscellaneous DSP functions + Note for the spectrum analysis function to work, you have to enable the FFT DSP unit with + the following code FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE); + It is off by default to save cpu usage. +} + +function FSOUND_DSP_MixBuffers(DestBuffer: Pointer; SrcBuffer: Pointer; Len: Integer; Freq: Integer; Vol: Integer; Pan: Integer; Mode: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FSOUND_DSP_ClearMixBuffer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_DSP_GetBufferLength: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; { Length of each DSP update } +function FSOUND_DSP_GetBufferLengthTotal: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; { Total buffer length due to FSOUND_SetBufferSize } +function FSOUND_DSP_GetSpectrum: PSingle; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; { Array of 512 floats - call FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE)) for this to work. } + +{ ========================================================================== } +{ Reverb functions. (eax2/3 reverb) (NOT SUPPORTED IN LINUX/CE) } +{ ========================================================================== } + +{ + See structures above for definitions and information on the reverb parameters. +} + +function FSOUND_Reverb_SetProperties(var Prop: TFSoundReverbProperties): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Reverb_GetProperties(var Prop: TFSoundReverbProperties): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Reverb_SetChannelProperties(Channel: Integer; var Prop: TFSoundReverbChannelProperties): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Reverb_GetChannelProperties(Channel: Integer; var Prop: TFSoundReverbChannelProperties): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ================================================ } +{ Recording functions (NOT SUPPORTED IN LINUX/MAC) } +{ ================================================ } + +{ + Recording initialization functions +} + +function FSOUND_Record_SetDriver(OutputType: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Record_GetNumDrivers: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Record_GetDriverName(Id: Integer): PChar; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Record_GetDriver: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Recording functionality. Only one recording session will work at a time. +} + +function FSOUND_Record_StartSample(Sptr: PFSoundSample; Loop: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Record_Stop: ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FSOUND_Record_GetPosition: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ============================================================================================= } +{ FMUSIC API (MOD,S3M,XM,IT,MIDI PLAYBACK) } +{ ============================================================================================= } + +{ + Song management / playback functions. +} + +function FMUSIC_LoadSong(const Name: PChar): PFMusicModule; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_LoadSongEx(Name_Or_Data: Pointer; Offset: Integer; Length: Integer; Mode: Cardinal; var SampleList: Integer; SampleListNum: Integer): PFMusicModule; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetOpenState(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_FreeSong(Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_PlaySong(Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_StopSong(Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +procedure FMUSIC_StopAllSongs; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FMUSIC_SetZxxCallback(Module: PFMusicModule; Callback: TFMusicCallback): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetRowCallback(Module: PFMusicModule; Callback: TFMusicCallback; RowStep: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetOrderCallback(Module: PFMusicModule; Callback: TFMusicCallback; OrderStep: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetInstCallback(Module: PFMusicModule; Callback: TFMusicCallback; Instrument: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +function FMUSIC_SetSample(Module: PFMusicModule; SampNo: Integer; Sptr: PFSoundSample): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetUserData(Module: PFMusicModule; userdata: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_OptimizeChannels(Module: PFMusicModule; MaxChannels: Integer; MinVolume: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Runtime song functions. +} + +function FMUSIC_SetReverb(Reverb: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetLooping(Module: PFMusicModule; Looping: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetOrder(Module: PFMusicModule; Order: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetPaused(Module: PFMusicModule; Pause: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetMasterVolume(Module: PFMusicModule; Volume: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetMasterSpeed(Module: PFMusicModule; speed: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_SetPanSeperation(Module: PFMusicModule; PanSep: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Static song information functions. +} + +function FMUSIC_GetName(Module: PFMusicModule): PCHAR; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetType(Module: PFMusicModule): TFMusicTypes; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetNumOrders(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetNumPatterns(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetNumInstruments(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetNumSamples(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetNumChannels(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetSample(Module: PFMusicModule; SampNo: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetPatternLength(Module: PFMusicModule; OrderNo: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Runtime song information. +} + +function FMUSIC_IsFinished(Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_IsPlaying(Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetMasterVolume(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetGlobalVolume(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetOrder(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetPattern(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetSpeed(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetBPM(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetRow(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetPaused(Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetTime(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetRealChannel(Module: PFMusicModule; modchannel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; +function FMUSIC_GetUserData(Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +implementation + +const +{$IFDEF LINUX} + FMOD_DLL = 'libfmod.so'; +{$ELSE} +{$IFDEF MSWINDOWS} + FMOD_DLL = 'fmod.dll'; +{$ENDIF} +{$ENDIF} + +{ + Stub functions to allow applications to swap between static and dynamic with + no code changes at all. +} +function FMOD_Load(LibName: PChar): Boolean; +begin + Result := True; +end; + +procedure FMOD_Unload; +begin +end; + +function FSOUND_SetOutput; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetOutput@4' {$ENDIF}; +function FSOUND_SetDriver; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetDriver@4' {$ENDIF}; +function FSOUND_SetMixer; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetMixer@4' {$ENDIF}; +function FSOUND_SetBufferSize; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetBufferSize@4' {$ENDIF}; +function FSOUND_SetHWND; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetHWND@4' {$ENDIF}; +function FSOUND_SetMinHardwareChannels; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetMinHardwareChannels@4' {$ENDIF}; +function FSOUND_SetMaxHardwareChannels; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetMaxHardwareChannels@4' {$ENDIF}; +function FSOUND_SetMemorySystem; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetMemorySystem@20' {$ENDIF}; +function FSOUND_Init; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Init@12' {$ENDIF}; +procedure FSOUND_Close; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Close@0' {$ENDIF}; +procedure FSOUND_Update; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Update@0' {$ENDIF}; +procedure FSOUND_SetSpeakerMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetSpeakerMode@4' {$ENDIF}; +procedure FSOUND_SetSFXMasterVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetSFXMasterVolume@4' {$ENDIF}; +procedure FSOUND_SetPanSeperation; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetPanSeperation@4' {$ENDIF}; +function FSOUND_GetError; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetError@0' {$ENDIF}; +function FSOUND_GetVersion; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetVersion@0' {$ENDIF}; +function FSOUND_GetOutput; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetOutput@0' {$ENDIF}; +function FSOUND_GetOutputHandle; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetOutputHandle@0' {$ENDIF}; +function FSOUND_GetDriver; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetDriver@0' {$ENDIF}; +function FSOUND_GetMixer; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetMixer@0' {$ENDIF}; +function FSOUND_GetNumDrivers; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetNumDrivers@0' {$ENDIF}; +function FSOUND_GetDriverName; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetDriverName@4' {$ENDIF}; +function FSOUND_GetDriverCaps; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetDriverCaps@8' {$ENDIF}; +function FSOUND_GetOutputRate; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetOutputRate@0' {$ENDIF}; +function FSOUND_GetMaxChannels; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetMaxChannels@0' {$ENDIF}; +function FSOUND_GetMaxSamples; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetMaxSamples@0' {$ENDIF}; +function FSOUND_GetSpeakerMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetSpeakerMode@0' {$ENDIF}; +function FSOUND_GetSFXMasterVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetSFXMasterVolume@0' {$ENDIF}; +function FSOUND_GetNumHWChannels; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetNumHWChannels@12' {$ENDIF}; +function FSOUND_GetChannelsPlaying; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetChannelsPlaying@0' {$ENDIF}; +function FSOUND_GetCPUUsage; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetCPUUsage@0' {$ENDIF}; +procedure FSOUND_GetMemoryStats; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetMemoryStats@8' {$ENDIF}; +function FSOUND_Sample_Load; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_Load@20' {$ENDIF}; +function FSOUND_Sample_Alloc; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_Alloc@28' {$ENDIF}; +procedure FSOUND_Sample_Free; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_Free@4' {$ENDIF}; +function FSOUND_Sample_Upload; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_Upload@12' {$ENDIF}; +function FSOUND_Sample_Lock; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_Lock@28' {$ENDIF}; +function FSOUND_Sample_Unlock; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_Unlock@20' {$ENDIF}; +function FSOUND_Sample_SetMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_SetMode@8' {$ENDIF}; +function FSOUND_Sample_SetLoopPoints; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_SetLoopPoints@12' {$ENDIF}; +function FSOUND_Sample_SetDefaults; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_SetDefaults@20' {$ENDIF}; +function FSOUND_Sample_SetDefaultsEx; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_SetDefaultsEx@32' {$ENDIF}; +function FSOUND_Sample_SetMinMaxDistance; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_SetMinMaxDistance@12' {$ENDIF}; +function FSOUND_Sample_SetMaxPlaybacks; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_SetMaxPlaybacks@8' {$ENDIF}; +function FSOUND_Sample_Get; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_Get@4' {$ENDIF}; +function FSOUND_Sample_GetName; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_GetName@4' {$ENDIF}; +function FSOUND_Sample_GetLength; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_GetLength@4' {$ENDIF}; +function FSOUND_Sample_GetLoopPoints; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_GetLoopPoints@12' {$ENDIF}; +function FSOUND_Sample_GetDefaults; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_GetDefaults@20' {$ENDIF}; +function FSOUND_Sample_GetDefaultsEx; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_GetDefaultsEx@32' {$ENDIF}; +function FSOUND_Sample_GetMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_GetMode@4' {$ENDIF}; +function FSOUND_Sample_GetMinMaxDistance; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Sample_GetMinMaxDistance@12' {$ENDIF}; +function FSOUND_PlaySound; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_PlaySound@8' {$ENDIF}; +function FSOUND_PlaySoundEx; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_PlaySoundEx@16' {$ENDIF}; +function FSOUND_StopSound; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_StopSound@4' {$ENDIF}; +function FSOUND_SetFrequency; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetFrequency@8' {$ENDIF}; +function FSOUND_SetVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetVolume@8' {$ENDIF}; +function FSOUND_SetVolumeAbsolute; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetVolumeAbsolute@8' {$ENDIF}; +function FSOUND_SetPan; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetPan@8' {$ENDIF}; +function FSOUND_SetSurround; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetSurround@8' {$ENDIF}; +function FSOUND_SetMute; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetMute@8' {$ENDIF}; +function FSOUND_SetPriority; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetPriority@8' {$ENDIF}; +function FSOUND_SetReserved; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetReserved@8' {$ENDIF}; +function FSOUND_SetPaused; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetPaused@8' {$ENDIF}; +function FSOUND_SetLoopMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetLoopMode@8' {$ENDIF}; +function FSOUND_SetCurrentPosition; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_SetCurrentPosition@8' {$ENDIF}; +function FSOUND_3D_SetAttributes; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_SetAttributes@12' {$ENDIF}; +function FSOUND_3D_SetMinMaxDistance; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_SetMinMaxDistance@12' {$ENDIF}; +function FSOUND_IsPlaying; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_IsPlaying@4' {$ENDIF}; +function FSOUND_GetFrequency; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetFrequency@4' {$ENDIF}; +function FSOUND_GetVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetVolume@4' {$ENDIF}; +function FSOUND_GetAmplitude; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetAmplitude@4' {$ENDIF}; +function FSOUND_GetPan; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetPan@4' {$ENDIF}; +function FSOUND_GetSurround; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetSurround@4' {$ENDIF}; +function FSOUND_GetMute; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetMute@4' {$ENDIF}; +function FSOUND_GetPriority; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetPriority@4' {$ENDIF}; +function FSOUND_GetReserved; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetReserved@4' {$ENDIF}; +function FSOUND_GetPaused; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetPaused@4' {$ENDIF}; +function FSOUND_GetLoopMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetLoopMode@4' {$ENDIF}; +function FSOUND_GetCurrentPosition; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetCurrentPosition@4' {$ENDIF}; +function FSOUND_GetCurrentSample; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetCurrentSample@4' {$ENDIF}; +function FSOUND_GetCurrentLevels; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetCurrentLevels@12' {$ENDIF}; +function FSOUND_GetNumSubChannels; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetNumSubChannels@4' {$ENDIF}; +function FSOUND_GetSubChannel; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_GetSubChannel@8' {$ENDIF}; +function FSOUND_3D_GetAttributes; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_GetAttributes@12' {$ENDIF}; +function FSOUND_3D_GetMinMaxDistance; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_GetMinMaxDistance@12' {$ENDIF}; +procedure FSOUND_3D_Listener_SetCurrent; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_Listener_SetCurrent@8' {$ENDIF}; +procedure FSOUND_3D_Listener_SetAttributes; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_Listener_SetAttributes@32' {$ENDIF}; +procedure FSOUND_3D_Listener_GetAttributes; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_Listener_GetAttributes@32' {$ENDIF}; +procedure FSOUND_3D_SetDopplerFactor; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_SetDopplerFactor@4' {$ENDIF}; +procedure FSOUND_3D_SetDistanceFactor; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_SetDistanceFactor@4' {$ENDIF}; +procedure FSOUND_3D_SetRolloffFactor; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_3D_SetRolloffFactor@4' {$ENDIF}; +function FSOUND_FX_Enable; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_Enable@8' {$ENDIF}; +function FSOUND_FX_Disable; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_Disable@4' {$ENDIF}; +function FSOUND_FX_SetChorus; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetChorus@32' {$ENDIF}; +function FSOUND_FX_SetCompressor; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetCompressor@28' {$ENDIF}; +function FSOUND_FX_SetDistortion; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetDistortion@24' {$ENDIF}; +function FSOUND_FX_SetEcho; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetEcho@24' {$ENDIF}; +function FSOUND_FX_SetFlanger; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetFlanger@32' {$ENDIF}; +function FSOUND_FX_SetGargle; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetGargle@12' {$ENDIF}; +function FSOUND_FX_SetI3DL2Reverb; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetI3DL2Reverb@52' {$ENDIF}; +function FSOUND_FX_SetParamEQ; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetParamEQ@16' {$ENDIF}; +function FSOUND_FX_SetWavesReverb; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_FX_SetWavesReverb@20' {$ENDIF}; +function FSOUND_Stream_Open; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Open@16' {$ENDIF}; +function FSOUND_Stream_Create; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Create@20' {$ENDIF}; +function FSOUND_Stream_Play; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Play@8' {$ENDIF}; +function FSOUND_Stream_PlayEx; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_PlayEx@16' {$ENDIF}; +function FSOUND_Stream_Stop; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Stop@4' {$ENDIF}; +function FSOUND_Stream_Close; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Close@4' {$ENDIF}; +function FSOUND_Stream_SetEndCallback; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetEndCallback@12' {$ENDIF}; +function FSOUND_Stream_SetSyncCallback; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetSyncCallback@12' {$ENDIF}; +function FSOUND_Stream_GetSample; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetSample@4' {$ENDIF}; +function FSOUND_Stream_CreateDSP; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_CreateDSP@16' {$ENDIF}; +function FSOUND_Stream_SetBufferSize; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetBufferSize@4' {$ENDIF}; +function FSOUND_Stream_SetPosition; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetPosition@8' {$ENDIF}; +function FSOUND_Stream_GetPosition; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetPosition@4' {$ENDIF}; +function FSOUND_Stream_SetTime; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetTime@8' {$ENDIF}; +function FSOUND_Stream_GetTime; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetTime@4' {$ENDIF}; +function FSOUND_Stream_GetLength; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetLength@4' {$ENDIF}; +function FSOUND_Stream_GetLengthMs; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetLengthMs@4' {$ENDIF}; +function FSOUND_Stream_SetMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetMode@8' {$ENDIF}; +function FSOUND_Stream_GetMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetMode@4' {$ENDIF}; +function FSOUND_Stream_SetLoopPoints; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetLoopPoints@12' {$ENDIF}; +function FSOUND_Stream_SetLoopCount; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetLoopCount@8' {$ENDIF}; +function FSOUND_Stream_AddSyncPoint; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_AddSyncPoint@12' {$ENDIF}; +function FSOUND_Stream_DeleteSyncPoint; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_DeleteSyncPoint@4' {$ENDIF}; +function FSOUND_Stream_GetNumSyncPoints; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetNumSyncPoints@4' {$ENDIF}; +function FSOUND_Stream_GetSyncPoint; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetSyncPoint@8' {$ENDIF}; +function FSOUND_Stream_GetSyncPointInfo; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetSyncPointInfo@8' {$ENDIF}; +function FSOUND_Stream_GetOpenState; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetOpenState@4' {$ENDIF}; +function FSOUND_Stream_SetSubStream; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetSubStream@8' {$ENDIF}; +function FSOUND_Stream_GetNumSubStreams; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetNumSubStreams@4' {$ENDIF}; +function FSOUND_Stream_SetSubStreamSentence; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_SetSubStreamSentence@12' {$ENDIF}; +function FSOUND_Stream_GetNumTagFields; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetNumTagFields@8' {$ENDIF}; +function FSOUND_Stream_GetTagField; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_GetTagField@24' {$ENDIF}; +function FSOUND_Stream_FindTagField; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_FindTagField@20' {$ENDIF}; +function FSOUND_Stream_Net_SetProxy; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Net_SetProxy@4' {$ENDIF}; +function FSOUND_Stream_Net_GetLastServerStatus; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Net_GetLastServerStatus@0' {$ENDIF}; +function FSOUND_Stream_Net_SetBufferProperties; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Net_SetBufferProperties@12' {$ENDIF}; +function FSOUND_Stream_Net_GetBufferProperties; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Net_GetBufferProperties@12' {$ENDIF}; +function FSOUND_Stream_Net_SetMetadataCallback; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Net_SetMetadataCallback@12' {$ENDIF}; +function FSOUND_Stream_Net_GetStatus; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Stream_Net_GetStatus@20' {$ENDIF}; +function FSOUND_CD_Play; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_Play@8' {$ENDIF}; +procedure FSOUND_CD_SetPlayMode; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_SetPlayMode@8' {$ENDIF}; +function FSOUND_CD_Stop; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_Stop@4' {$ENDIF}; +function FSOUND_CD_SetPaused; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_SetPaused@8' {$ENDIF}; +function FSOUND_CD_SetVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_SetVolume@8' {$ENDIF}; +function FSOUND_CD_SetTrackTime; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_SetTrackTime@8' {$ENDIF}; +function FSOUND_CD_OpenTray; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_OpenTray@8' {$ENDIF}; +function FSOUND_CD_GetPaused; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_GetPaused@4' {$ENDIF}; +function FSOUND_CD_GetTrack; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_GetTrack@4' {$ENDIF}; +function FSOUND_CD_GetNumTracks; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_GetNumTracks@4' {$ENDIF}; +function FSOUND_CD_GetVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_GetVolume@4' {$ENDIF}; +function FSOUND_CD_GetTrackLength; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_GetTrackLength@8' {$ENDIF}; +function FSOUND_CD_GetTrackTime; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_CD_GetTrackTime@4' {$ENDIF}; +function FSOUND_DSP_Create; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_Create@12' {$ENDIF}; +procedure FSOUND_DSP_Free; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_Free@4' {$ENDIF}; +procedure FSOUND_DSP_SetPriority; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_SetPriority@8' {$ENDIF}; +function FSOUND_DSP_GetPriority; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetPriority@4' {$ENDIF}; +procedure FSOUND_DSP_SetActive; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_SetActive@8' {$ENDIF}; +function FSOUND_DSP_GetActive; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetActive@4' {$ENDIF}; +function FSOUND_DSP_GetClearUnit; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetClearUnit@0' {$ENDIF}; +function FSOUND_DSP_GetSFXUnit; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetSFXUnit@0' {$ENDIF}; +function FSOUND_DSP_GetMusicUnit; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetMusicUnit@0' {$ENDIF}; +function FSOUND_DSP_GetClipAndCopyUnit; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetClipAndCopyUnit@0' {$ENDIF}; +function FSOUND_DSP_GetFFTUnit; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetFFTUnit@0' {$ENDIF}; +function FSOUND_DSP_MixBuffers; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_MixBuffers@28' {$ENDIF}; +procedure FSOUND_DSP_ClearMixBuffer; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_ClearMixBuffer@0' {$ENDIF}; +function FSOUND_DSP_GetBufferLength; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetBufferLength@0' {$ENDIF}; +function FSOUND_DSP_GetBufferLengthTotal; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetBufferLengthTotal@0' {$ENDIF}; +function FSOUND_DSP_GetSpectrum; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_DSP_GetSpectrum@0' {$ENDIF}; +function FSOUND_Reverb_SetProperties; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Reverb_SetProperties@4' {$ENDIF}; +function FSOUND_Reverb_GetProperties; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Reverb_GetProperties@4' {$ENDIF}; +function FSOUND_Reverb_SetChannelProperties; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Reverb_SetChannelProperties@8' {$ENDIF}; +function FSOUND_Reverb_GetChannelProperties; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Reverb_GetChannelProperties@8' {$ENDIF}; +function FSOUND_Record_SetDriver; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Record_SetDriver@4' {$ENDIF}; +function FSOUND_Record_GetNumDrivers; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Record_GetNumDrivers@0' {$ENDIF}; +function FSOUND_Record_GetDriverName; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Record_GetDriverName@4' {$ENDIF}; +function FSOUND_Record_GetDriver; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Record_GetDriver@0' {$ENDIF}; +function FSOUND_Record_StartSample; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Record_StartSample@8' {$ENDIF}; +function FSOUND_Record_Stop; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Record_Stop@0' {$ENDIF}; +function FSOUND_Record_GetPosition; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_Record_GetPosition@0' {$ENDIF}; +procedure FSOUND_File_SetCallbacks; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FSOUND_File_SetCallbacks@20' {$ENDIF}; +function FMUSIC_LoadSong; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_LoadSong@4' {$ENDIF}; +function FMUSIC_LoadSongEx; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_LoadSongEx@24' {$ENDIF}; +function FMUSIC_GetOpenState; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetOpenState@4' {$ENDIF}; +function FMUSIC_FreeSong; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_FreeSong@4' {$ENDIF}; +function FMUSIC_PlaySong; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_PlaySong@4' {$ENDIF}; +function FMUSIC_StopSong; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_StopSong@4' {$ENDIF}; +procedure FMUSIC_StopAllSongs; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_StopAllSongs@0' {$ENDIF}; +function FMUSIC_SetZxxCallback; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetZxxCallback@8' {$ENDIF}; +function FMUSIC_SetRowCallback; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetRowCallback@12' {$ENDIF}; +function FMUSIC_SetOrderCallback; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetOrderCallback@12' {$ENDIF}; +function FMUSIC_SetInstCallback; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetInstCallback@12' {$ENDIF}; +function FMUSIC_SetSample; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetSample@12' {$ENDIF}; +function FMUSIC_SetUserData; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetUserData@8' {$ENDIF}; +function FMUSIC_OptimizeChannels; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_OptimizeChannels@12' {$ENDIF}; +function FMUSIC_SetReverb; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetReverb@4' {$ENDIF}; +function FMUSIC_SetLooping; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetLooping@8' {$ENDIF}; +function FMUSIC_SetOrder; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetOrder@8' {$ENDIF}; +function FMUSIC_SetPaused; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetPaused@8' {$ENDIF}; +function FMUSIC_SetMasterVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetMasterVolume@8' {$ENDIF}; +function FMUSIC_SetMasterSpeed; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetMasterSpeed@8' {$ENDIF}; +function FMUSIC_SetPanSeperation; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_SetPanSeperation@8' {$ENDIF}; +function FMUSIC_GetName; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetName@4' {$ENDIF}; +function FMUSIC_GetType; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetType@4' {$ENDIF}; +function FMUSIC_GetNumOrders; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetNumOrders@4' {$ENDIF}; +function FMUSIC_GetNumPatterns; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetNumPatterns@4' {$ENDIF}; +function FMUSIC_GetNumInstruments; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetNumInstruments@4' {$ENDIF}; +function FMUSIC_GetNumSamples; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetNumSamples@4' {$ENDIF}; +function FMUSIC_GetNumChannels; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetNumChannels@4' {$ENDIF}; +function FMUSIC_GetSample; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetSample@8' {$ENDIF}; +function FMUSIC_GetPatternLength; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetPatternLength@8' {$ENDIF}; +function FMUSIC_IsFinished; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_IsFinished@4' {$ENDIF}; +function FMUSIC_IsPlaying; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_IsPlaying@4' {$ENDIF}; +function FMUSIC_GetMasterVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetMasterVolume@4' {$ENDIF}; +function FMUSIC_GetGlobalVolume; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetGlobalVolume@4' {$ENDIF}; +function FMUSIC_GetOrder; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetOrder@4' {$ENDIF}; +function FMUSIC_GetPattern; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetPattern@4' {$ENDIF}; +function FMUSIC_GetSpeed; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetSpeed@4' {$ENDIF}; +function FMUSIC_GetBPM; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetBPM@4' {$ENDIF}; +function FMUSIC_GetRow; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetRow@4' {$ENDIF}; +function FMUSIC_GetPaused; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetPaused@4' {$ENDIF}; +function FMUSIC_GetTime; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetTime@4' {$ENDIF}; +function FMUSIC_GetRealChannel; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetRealChannel@8' {$ENDIF}; +function FMUSIC_GetUserData; external FMOD_DLL {$IFDEF MSWINDOWS} name '_FMUSIC_GetUserData@4' {$ENDIF}; + +var + Saved8087CW: Word; + +{$ifdef FPC} //FPC do not have this function in its RTL +const + Default8087CW = $1332; //according to the FPC site it's the value used in the + //startup code. +procedure Set8087CW( value :word ); Assembler; +asm + FLDCW value +end; +{$endif} + + +initialization + { Save the current FPU state and then disable FPU exceptions } + Saved8087CW := Default8087CW; + Set8087CW($133f); { Disable all fpu exceptions } + +finalization + { Reset the FPU to the previous state } + Set8087CW(Saved8087CW); + +end. diff --git a/lib/fmodapi375win/api/delphi/fmoddyn.pas b/lib/fmodapi375win/api/delphi/fmoddyn.pas new file mode 100644 index 0000000..9fbede2 --- /dev/null +++ b/lib/fmodapi375win/api/delphi/fmoddyn.pas @@ -0,0 +1,864 @@ +{============================================================================================ } +{ FMOD Main header file. Copyright (c), FireLight Technologies Pty, Ltd. 1999-2003. } +{ =========================================================================================== } +{ + NOTE: For the demos to run you must have either fmod.dll (in Windows) + or libfmod-3.75.so (in Linux) installed. + + In Windows, copy the fmod.dll file found in the api directory to either of + the following locations (in order of preference) + - your application directory + - Windows\System (95/98) or WinNT\System32 (NT/2000/XP) + + In Linux, make sure you are signed in as root and copy the libfmod-3.75.so + file from the api directory to your /usr/lib/ directory. + Then via a command line, navigate to the /usr/lib/ directory and create + a symbolic link between libfmod-3.75.so and libfmod.so. This is done with + the following command (assuming you are in /usr/lib/)... + ln -s libfmod-3.75.so libfmod.so. +} +{ =============================================================================================== } + +unit fmoddyn; + +{ + Disable assertions by changing the following compiler directive to OFF. + Assertions are used to check the functions are correctly loaded when using + dynamic loading. +} +{$ASSERTIONS ON} + +interface + +uses +{$IFDEF MSWINDOWS} + Windows, +{$ENDIF} + fmodtypes; + +{ + Disable warning for unsafe types in Delphi 7 +} +{$IFDEF VER150} +{$WARN UNSAFE_TYPE OFF} +{$ENDIF} + +//=============================================================================================== +// FUNCTION PROTOTYPES +//=============================================================================================== + +{ ================================== } +{ Library load/unload functions. } +{ ================================== } + +{ + If no library name is passed to FMOD_Load, then the default library name + used. +} + +function FMOD_Load(LibName: PChar {$ifndef FPC}= nil{$endif}): Boolean; +procedure FMOD_Unload; + +{ ================================== } +{ Initialization / Global functions. } +{ ================================== } + +{ + Pre FSOUND_Init functions. These can't be called after FSOUND_Init is + called (they will fail). They set up FMOD system functionality. +} + +var + FSOUND_SetOutput: function (OutputType: TFSoundOutputTypes): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetDriver: function (Driver: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetMixer: function (Mixer: TFSoundMixerTypes): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetBufferSize: function (LenMs: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetHWND: function (Hwnd: THandle): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetMinHardwareChannels: function (Min: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetMaxHardwareChannels: function (Max: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetMemorySystem: function (Pool: Pointer; + PoolLen: Integer; + UserAlloc: TFSoundAllocCallback; + UserRealloc: TFSoundReallocCallback; + UserFree: TFSoundFreeCallback): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Main initialization / closedown functions + Note : Use FSOUND_INIT_USEDEFAULTMIDISYNTH with FSOUND_Init for software override with MIDI playback. + : Use FSOUND_INIT_GLOBALFOCUS with FSOUND_Init to make sound audible + no matter which window is in focus. (FSOUND_OUTPUT_DSOUND only) +} + +var + FSOUND_Init: function (MixRate: Integer; MaxSoftwareChannels: Integer; Flags: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Close: procedure; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Runtime system level functions +} + +var + FSOUND_Update: procedure; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; // This is called to update 3d sound / non-realtime output + FSOUND_SetSpeakerMode: procedure (SpeakerMode: Cardinal); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetSFXMasterVolume: procedure (Volume: Integer); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetPanSeperation: procedure (PanSep: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_File_SetCallbacks: procedure (OpenCallback: TFSoundOpenCallback; + CloseCallback: TFSoundCloseCallback; + ReadCallback: TFSoundReadCallback; + SeekCallback: TFSoundSeekCallback; + TellCallback: TFSoundTellCallback); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + System information functions +} + +var + FSOUND_GetError: function: TFModErrors; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetVersion: function: Single; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetOutput: function: TFSoundOutputTypes; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetOutputHandle: function: Pointer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetDriver: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetMixer: function: TFSoundMixerTypes; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetNumDrivers: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetDriverName: function (Id: Integer): PChar; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetDriverCaps: function (Id: Integer; var Caps: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +var + FSOUND_GetOutputRate: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetMaxChannels: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetMaxSamples: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetSpeakerMode: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetSFXMasterVolume: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetNumHWChannels: function (var Num2D: Integer; var Num3D: Integer; var Total: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetChannelsPlaying: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetCPUUsage: function: Single; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetMemoryStats: Procedure (var CurrentAlloced: Cardinal; var MaxAlloced: Cardinal); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ =================================== } +{ Sample management / load functions. } +{ =================================== } + +{ + Sample creation and management functions + Note : Use FSOUND_LOADMEMORY flag with FSOUND_Sample_Load to load from memory. + Use FSOUND_LOADRAW flag with FSOUND_Sample_Load to treat as as raw pcm data. +} + +var + FSOUND_Sample_Load: function (Index: Integer; const NameOrData: PChar; Mode: Cardinal; Offset: Integer; Length: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_Alloc: function (Index: Integer; Length: Integer; Mode: Cardinal; DefFreq: Integer; DefVol: Integer; DefPan: Integer; DefPri: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_Free: procedure (Sptr: PFSoundSample); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_Upload: function (Sptr: PFSoundSample; SrcData: Pointer; Mode: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_Lock: function (Sptr: PFSoundSample; Offset: Integer; Length: Integer; var Ptr1: Pointer; var Ptr2: Pointer; var Len1: Cardinal; var Len2: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_Unlock: function (Sptr: PFSoundSample; Ptr1: Pointer; Ptr2: Pointer; Len1: Cardinal; Len2: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Sample control functions +} + +var + FSOUND_Sample_SetMode: function (Sptr: PFSoundSample; Mode: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_SetLoopPoints: function (Sptr: PFSoundSample; LoopStart, LoopEnd: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_SetDefaults: function (Sptr: PFSoundSample; DefFreq, DefVol, DefPan, DefPri: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_SetDefaultsEx: function (Sptr: PFSoundSample; DefFreq, DefVol, DefPan, DefPri, VarFreq, VarVol, VarPan: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_SetMinMaxDistance: function (Sptr: PFSoundSample; Min, Max: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_SetMaxPlaybacks: function (Sptr: PFSoundSample; Max: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Sample information functions +} + +var + FSOUND_Sample_Get: function (SampNo: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_GetName: function (Sptr: PFSoundSample): PCHAR; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_GetLength: function (Sptr: PFSoundSample): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_GetLoopPoints: function (Sptr: PFSoundSample; var LoopStart: Integer; var LoopEnd: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_GetDefaults: function (Sptr: PFSoundSample; var DefFreq: Integer; var DefVol: Integer; var DefPan: Integer; var DefPri: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_GetDefaultsEx: function (Sptr: PFSoundSample; var DefFreq: Integer; var DefVol: Integer; var DefPan: Integer; var DefPri: Integer; var VarFreq: Integer; var VarVol: Integer; var VarPan): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_GetMode: function (Sptr: PFSoundSample): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Sample_GetMinMaxDistance: function (Sptr: PFSoundSample; var Min: Single; var Max: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ============================ } +{ Channel control functions. } +{ ============================ } + +{ + Playing and stopping sounds. + Note : Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. + Use FSOUND_ALL as the 'channel' variable to control ALL channels with one function call! +} + +var + FSOUND_PlaySound: function (Channel: Integer; Sptr: PFSoundSample): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_PlaySoundEx: function (Channel: Integer; Sptr: PFSoundSample; Dsp: PFSoundDSPUnit; StartPaused: ByteBool): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_StopSound: function (Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Functions to control playback of a channel. +} + +var + FSOUND_SetFrequency: function (Channel: Integer; Freq: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetVolume: function (Channel: Integer; Vol: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetVolumeAbsolute: function (Channel: Integer; Vol: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetPan: function (Channel: Integer; Pan: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetSurround: function (Channel: Integer; Surround: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetMute: function (Channel: Integer; Mute: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetPriority: function (Channel: Integer; Priority: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetReserved: function (Channel: Integer; Reserved: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetPaused: function (Channel: Integer; Paused: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetLoopMode: function (Channel: Integer; LoopMode: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_SetCurrentPosition: function (Channel: Integer; Offset: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_SetAttributes: function (Channel: Integer; Pos: PFSoundVector; Vel: PFSoundVector): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_SetMinMaxDistance: function (Channel: Integer; Min: Single; Max: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Channel information functions +} + +var + FSOUND_IsPlaying: function (Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetFrequency: function (Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetVolume: function (Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetAmplitude: function (Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetPan: function (Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetSurround: function (Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetMute: function (Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetPriority: function (Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetReserved: function (Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetPaused: function (Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetLoopMode: function (Channel: Integer): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetCurrentPosition: function (Channel: Integer): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetCurrentSample: function (Channel: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetCurrentLevels: function (Channel: Integer; L, R: PSingle): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetNumSubChannels: function (Channel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_GetSubChannel: function (Channel: Integer; SubChannel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_GetAttributes: function (Channel: Integer; Pos: PFSoundVector; Vel: PFSoundVector): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_GetMinMaxDistance: function (Channel: Integer; var Min: Single; var Max: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ =================== } +{ 3D sound functions. } +{ =================== } + +{ + See also 3d sample and channel based functions above. + Call FSOUND_Update once a frame to process 3d information. +} + +var + FSOUND_3D_Listener_SetCurrent: procedure (current: Integer); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_Listener_SetAttributes: procedure (Pos: PFSoundVector; Vel: PFSoundVector; + fx: Single; fy: Single; fz: Single; + tx: Single; ty: Single; tz: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_Listener_GetAttributes: procedure (Pos: PFSoundVector; Vel: PFSoundVector; + fx: PSingle; fy: PSingle; fz: PSingle; + tx: PSingle; ty: PSingle; tz: PSingle); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_SetDopplerFactor: procedure (Scale: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_SetDistanceFactor: procedure (Scale: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_3D_SetRolloffFactor: procedure (Scale: Single); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ =================== } +{ FX functions. } +{ =================== } + +{ + Functions to control DX8 only effects processing. + + - FX enabled samples can only be played once at a time, not multiple times at once. + - Sounds have to be created with FSOUND_HW2D or FSOUND_HW3D for this to work. + - FSOUND_INIT_ENABLESYSTEMCHANNELFX can be used to apply hardware effect processing to the + global mixed output of FMOD's software channels. + - FSOUND_FX_Enable returns an FX handle that you can use to alter fx parameters. + - FSOUND_FX_Enable can be called multiple times in a row, even on the same FX type, + it will return a unique handle for each FX. + - FSOUND_FX_Enable cannot be called if the sound is playing or locked. + - Stopping or starting a sound resets all FX and they must be re-enabled each time + if this happens. +} + +var + FSOUND_FX_Enable: function (Channel: Integer; Fx: TFSoundFXModes): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; { Set bits to enable following fx } + FSOUND_FX_Disable: function (Channel: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_FX_SetChorus: function (FXId: Integer; WetDryMix, Depth, Feedback, Frequency: Single; Waveform: Integer; Delay: Single; Phase: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_FX_SetCompressor: function (FXId: Integer; Gain, Attack, Release, Threshold, Ratio, Predelay: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_FX_SetDistortion: function (FXId: Integer; Gain, Edge, PostEQCenterFrequency, PostEQBandwidth, PreLowpassCutoff: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_FX_SetEcho: function (FXId: Integer; WetDryMix, Feedback, LeftDelay, RightDelay: Single; PanDelay: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_FX_SetFlanger: function (FXId: Integer; WetDryMix, Depth, Feedback, Frequency: Single; Waveform: Integer; Delay: Single; Phase: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_FX_SetGargle: function (FXId, RateHz, WaveShape: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_FX_SetI3DL2Reverb: function (FXId, Room, RoomHF: Integer; RoomRolloffFactor, DecayTime, DecayHFRatio: Single; Reflections: Integer; ReflectionsDelay: Single; Reverb: Integer; ReverbDelay, Diffusion, Density, HFReference: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_FX_SetParamEQ: function (FXId: Integer; Center, Bandwidth, Gain: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_FX_SetWavesReverb: function (FXId: Integer; InGain, ReverbMix, ReverbTime, HighFreqRTRatio: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ========================= } +{ File Streaming functions. } +{ ========================= } + +{ + Note : Use FSOUND_LOADMEMORY flag with FSOUND_Stream_Open to stream from memory. + Use FSOUND_LOADRAW flag with FSOUND_Stream_Open to treat stream as raw pcm data. + Use FSOUND_MPEGACCURATE flag with FSOUND_Stream_Open to open mpegs in 'accurate mode' for settime/gettime/getlengthms. + Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. +} + +var + // call this before opening streams, not after + FSOUND_Stream_SetBufferSize: function (Ms: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_Open: function(const name_or_data: PChar; Mode: Cardinal; Offset: Integer; Length: Integer): PFSoundStream; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_Create: function (Callback: TFSoundStreamCallback; Length: Integer; Mode: Cardinal; SampleRate: Integer; UserData: Integer): PFSoundStream; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_Close: function(Stream: PFSoundStream): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_Play: function(Channel: Integer; Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_PlayEx: function (Channel: Integer; Stream: PFSoundStream; Dsp: PFSoundDSPUnit; StartPaused: ByteBool): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_Stop: function(Stream: PFSoundStream): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_SetPosition: function (Stream: PFSoundStream; Position: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetPosition: function (Stream: PFSoundStream): Cardinal; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_SetTime: function (Stream: PFSoundStream; Ms: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetTime: function (Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetLength: function (Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetLengthMs: function (Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_SetMode: function (Stream: PFSoundStream; mode: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetMode: function (Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_SetLoopPoints: function (Stream: PFSoundStream; LoopStartPCM, LoopEndPCM: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_SetLoopCount: function (Stream: PFSoundStream; Count: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetOpenState: function (Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetSample: function (Stream: PFSoundStream): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; { Every stream contains a sample to play back on } + FSOUND_Stream_CreateDSP: function (Stream: PFSoundStream; Callback: TFSoundDSPCallback; Priority: Integer; Param: Integer): PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_SetEndCallback: function (Stream: PFSoundStream; Callback: TFSoundStreamCallback; UserData: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_SetSyncCallback: function (Stream: PFSoundStream; Callback: TFSoundStreamCallback; UserData: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_AddSyncPoint: function (Stream: PFSoundStream; PCMOffset: Cardinal; Name: PChar): PFSyncPoint; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_DeleteSyncPoint: function (Point: PFSyncPoint): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetNumSyncPoints: function (Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetSyncPoint: function (Stream: PFSoundStream; Index: Integer): PFSyncPoint; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetSyncPointInfo: function (Point: PFSyncPoint; var PCMOffset: Cardinal): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_SetSubStream: function (Stream: PFSoundStream; Index: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetNumSubStreams: function (Stream: PFSoundStream): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_SetSubStreamSentence: function (Stream: PFSoundStream; var sentencelist: Cardinal; numitems: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_GetNumTagFields: function (Stream: PFSoundStream; var Num: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_GetTagField: function (Stream: PFSoundStream; Num: Integer; var _Type: TFSoundTagFieldType; var Name: PCHAR; var Value: Pointer; var Length: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_FindTagField: function (Stream: PFSoundStream; _Type: TFSoundTagFieldType; Name: PChar; var Value: Pointer; var Length: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + + FSOUND_Stream_Net_SetProxy: function (Proxy: PChar): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_Net_GetLastServerStatus: function: PChar; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_Net_SetBufferProperties: function (BufferSize: Integer; PreBuffer_Percent: Integer; ReBuffer_Percent: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_Net_GetBufferProperties: function (var Buffersize: Integer; var PreBuffer_Percent: Integer; var ReBuffer_Percent: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_Net_SetMetadataCallback: function (Stream: PFSoundStream; Callback: TFMetaDataCallback; UserData: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Stream_Net_GetStatus: function (Stream: PFSoundStream; var Status: TFSoundStreamNetStatus; var BufferPercentUsed: Integer; var BitRate: Integer; var Flags: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ =================== } +{ CD audio functions. } +{ =================== } + +{ + Note : 0 = default cdrom. Otherwise specify the drive letter, for example. 'D'. +} + +var + FSOUND_CD_Play: function (Drive: Byte; Track: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_SetPlayMode: procedure (Drive: Byte; Mode: Integer); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_Stop: function (Drive: Byte): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_SetPaused: function (Drive: Byte; Paused: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_SetVolume: function (Drive: Byte; Volume: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_SetTrackTime: function (Drive: Byte; ms: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_OpenTray: function (Drive: Byte; Open: Byte): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +var + FSOUND_CD_GetPaused: function (Drive: Byte): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_GetTrack: function (Drive: Byte): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_GetNumTracks: function (Drive: Byte): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_GetVolume: function (Drive: Byte): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_GetTrackLength: function (Drive: Byte; Track: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_CD_GetTrackTime: function (Drive: Byte): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ============== } +{ DSP functions. } +{ ============== } + +{ + DSP Unit control and information functions. +} + +var + FSOUND_DSP_Create: function (Callback: TFSoundDSPCallback; Priority: Integer; Param: Integer): PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_Free: procedure (DSPUnit: PFSoundDSPUnit); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_SetPriority: procedure (DSPUnit: PFSoundDSPUnit; Priority: Integer); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_GetPriority: function (DSPUnit: PFSoundDSPUnit): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_SetActive: procedure (DSPUnit: PFSoundDSPUnit; Active: ByteBool); {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_GetActive: function (DSPUnit: PFSoundDSPUnit): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Functions to get hold of FSOUND 'system DSP unit' handles. +} + +var + FSOUND_DSP_GetClearUnit: function: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_GetSFXUnit: function: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_GetMusicUnit: function: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_GetClipAndCopyUnit: function: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_GetFFTUnit: function: PFSoundDSPUnit; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Miscellaneous DSP functions + Note for the spectrum analysis function to work, you have to enable the FFT DSP unit with + the following code FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE); + It is off by default to save cpu usage. +} + +var + FSOUND_DSP_MixBuffers: function (DestBuffer: Pointer; SrcBuffer: Pointer; Len: Integer; Freq: Integer; Vol: Integer; Pan: Integer; Mode: Cardinal): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_ClearMixBuffer: procedure; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_DSP_GetBufferLength: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; { Length of each DSP update } + FSOUND_DSP_GetBufferLengthTotal: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; { Total buffer length due to FSOUND_SetBufferSize } + FSOUND_DSP_GetSpectrum: function: PSingle; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; { Array of 512 floats - call FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE)) for this to work. } + +{ ========================================================================== } +{ Reverb functions. (eax2/eax3 reverb) (NOT SUPPORTED IN LINUX/CE) } +{ ========================================================================== } + +{ + See structures above for definitions and information on the reverb parameters. +} + +var + FSOUND_Reverb_SetProperties: function (const Prop: TFSoundReverbProperties): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Reverb_GetProperties: function (var Prop: TFSoundReverbProperties): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Reverb_SetChannelProperties: function (Channel: Integer; var Prop: TFSoundReverbChannelProperties): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Reverb_GetChannelProperties: function (Channel: Integer; var Prop: TFSoundReverbChannelProperties): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ================================================ } +{ Recording functions (NOT SUPPORTED IN LINUX/MAC) } +{ ================================================ } + +{ + Recording initialization functions +} + +var + FSOUND_Record_SetDriver: function (OutputType: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Record_GetNumDrivers: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Record_GetDriverName: function (Id: Integer): PChar; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Record_GetDriver: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Recording functionality. Only one recording session will work at a time. +} + +var + FSOUND_Record_StartSample: function (Sptr: PFSoundSample; Loop: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Record_Stop: function: ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FSOUND_Record_GetPosition: function: Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ ============================================================================================= } +{ FMUSIC API (MOD,S3M,XM,IT,MIDI PLAYBACK) } +{ ============================================================================================= } + +{ + Song management / playback functions. +} + +var + FMUSIC_LoadSong: function (const Name: PChar): PFMusicModule; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_LoadSongEx: function (Name_Or_Data: Pointer; Offset: Integer; Length: Integer; Mode: Cardinal; var SampleList: Integer; SampleListNum: Integer): PFMusicModule; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetOpenState: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_FreeSong: function (Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_PlaySong: function (Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_StopSong: function (Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_StopAllSongs: procedure; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +var + FMUSIC_SetZxxCallback: function (Module: PFMusicModule; Callback: TFMusicCallback): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetRowCallback: function (Module: PFMusicModule; Callback: TFMusicCallback; RowStep: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetOrderCallback: function (Module: PFMusicModule; Callback: TFMusicCallback; OrderStep: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetInstCallback: function (Module: PFMusicModule; Callback: TFMusicCallback; Instrument: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +var + FMUSIC_SetSample: function (Module: PFMusicModule; SampNo: Integer; Sptr: PFSoundSample): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetUserData: function (Module: PFMusicModule; userdata: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_OptimizeChannels: function (Module: PFMusicModule; MaxChannels: Integer; MinVolume: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Runtime song functions. +} + +var + FMUSIC_SetReverb: function (Reverb: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetLooping: function (Module: PFMusicModule; Looping: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetOrder: function (Module: PFMusicModule; Order: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetPaused: function (Module: PFMusicModule; Pause: ByteBool): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetMasterVolume: function (Module: PFMusicModule; Volume: Integer): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetMasterSpeed: function (Module: PFMusicModule; Speed: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_SetPanSeperation: function (Module: PFMusicModule; PanSep: Single): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Static song information functions. +} + +var + FMUSIC_GetName: function (Module: PFMusicModule): PCHAR; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetType: function (Module: PFMusicModule): TFMusicTypes; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetNumOrders: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetNumPatterns: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetNumInstruments: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetNumSamples: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetNumChannels: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetSample: function (Module: PFMusicModule; SampNo: Integer): PFSoundSample; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetPatternLength: function (Module: PFMusicModule; OrderNo: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +{ + Runtime song information. +} + +var + FMUSIC_IsFinished: function (Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_IsPlaying: function (Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetMasterVolume: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetGlobalVolume: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetOrder: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetPattern: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetSpeed: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetBPM: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetRow: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetPaused: function (Module: PFMusicModule): ByteBool; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetTime: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetRealChannel: function (Module: PFMusicModule; ModChannel: Integer): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + FMUSIC_GetUserData: function (Module: PFMusicModule): Integer; {$IFDEF LINUX} cdecl {$ELSE} stdcall {$ENDIF}; + +implementation + +{$IFDEF LINUX} +uses + Libc; +{$ENDIF} + +const +{$IFDEF LINUX} + FMOD_DLL = 'libfmod.so'; +{$ELSE} +{$IFDEF MSWINDOWS} + FMOD_DLL = 'fmod.dll'; +{$ENDIF} +{$ENDIF} + +type +{$IFDEF LINUX} + TFMODModuleHandle = Pointer; +{$ELSE} + TFMODModuleHandle = HINST; +{$ENDIF} + +const +{$IFDEF LINUX} + INVALID_MODULEHANDLE_VALUE = TFMODModuleHandle(nil); +{$ELSE} + INVALID_MODULEHANDLE_VALUE = TFMODModuleHandle(0); +{$ENDIF} + +var + FMODHandle: TFMODModuleHandle; + +function GetAddress(Handle: TFMODModuleHandle; FuncName: PChar): Pointer; +begin +{$IFDEF MSWINDOWS} + Result := GetProcAddress(Handle, FuncName); +{$ELSE} + Result := dlsym(Handle, FuncName); +{$ENDIF} + Assert(Result <> nil, 'Failed to find ' + FuncName + ' in ' + FMOD_DLL); +end; + +function FMOD_Load(LibName: PChar): Boolean; +begin + Result := False; + + { Make sure the previous library is unloaded } + FMOD_Unload; + + { If no library name given, use the default library names } + if LibName = nil then + LibName := FMOD_DLL; + + { Load the library } +{$IFDEF MSWINDOWS} + FMODHandle := LoadLibrary(LibName); +{$ELSE} + FMODHandle := dlopen(LibName, RTLD_NOW); +{$ENDIF} + if FMODHandle = INVALID_MODULEHANDLE_VALUE then + Exit; + + { Get all the function addresses from the library } + FSOUND_SetOutput := GetAddress(FMODHandle, '_FSOUND_SetOutput@4'); + FSOUND_SetDriver := GetAddress(FMODHandle, '_FSOUND_SetDriver@4'); + FSOUND_SetMixer := GetAddress(FMODHandle, '_FSOUND_SetMixer@4'); + FSOUND_SetBufferSize := GetAddress(FMODHandle, '_FSOUND_SetBufferSize@4'); + FSOUND_SetHWND := GetAddress(FMODHandle, '_FSOUND_SetHWND@4'); + FSOUND_SetMinHardwareChannels := GetAddress(FMODHandle, '_FSOUND_SetMinHardwareChannels@4'); + FSOUND_SetMaxHardwareChannels := GetAddress(FMODHandle, '_FSOUND_SetMaxHardwareChannels@4'); + FSOUND_SetMemorySystem := GetAddress(FMODHandle, '_FSOUND_SetMemorySystem@20'); + FSOUND_Init := GetAddress(FMODHandle, '_FSOUND_Init@12'); + FSOUND_Close := GetAddress(FMODHandle, '_FSOUND_Close@0'); + FSOUND_Update := GetAddress(FMODHandle, '_FSOUND_Update@0'); + FSOUND_SetSpeakerMode := GetAddress(FMODHandle, '_FSOUND_SetSpeakerMode@4'); + FSOUND_SetSFXMasterVolume := GetAddress(FMODHandle, '_FSOUND_SetSFXMasterVolume@4'); + FSOUND_SetPanSeperation := GetAddress(FMODHandle, '_FSOUND_SetPanSeperation@4'); + FSOUND_GetError := GetAddress(FMODHandle, '_FSOUND_GetError@0'); + FSOUND_GetVersion := GetAddress(FMODHandle, '_FSOUND_GetVersion@0'); + FSOUND_GetOutput := GetAddress(FMODHandle, '_FSOUND_GetOutput@0'); + FSOUND_GetOutputHandle := GetAddress(FMODHandle, '_FSOUND_GetOutputHandle@0'); + FSOUND_GetDriver := GetAddress(FMODHandle, '_FSOUND_GetDriver@0'); + FSOUND_GetMixer := GetAddress(FMODHandle, '_FSOUND_GetMixer@0'); + FSOUND_GetNumDrivers := GetAddress(FMODHandle, '_FSOUND_GetNumDrivers@0'); + FSOUND_GetDriverName := GetAddress(FMODHandle, '_FSOUND_GetDriverName@4'); + FSOUND_GetDriverCaps := GetAddress(FMODHandle, '_FSOUND_GetDriverCaps@8'); + FSOUND_GetOutputRate := GetAddress(FMODHandle, '_FSOUND_GetOutputRate@0'); + FSOUND_GetMaxChannels := GetAddress(FMODHandle, '_FSOUND_GetMaxChannels@0'); + FSOUND_GetMaxSamples := GetAddress(FMODHandle, '_FSOUND_GetMaxSamples@0'); + FSOUND_GetSpeakerMode := GetAddress(FMODHandle, '_FSOUND_GetSpeakerMode@0'); + FSOUND_GetSFXMasterVolume := GetAddress(FMODHandle, '_FSOUND_GetSFXMasterVolume@0'); + FSOUND_GetNumHWChannels := GetAddress(FMODHandle, '_FSOUND_GetNumHWChannels@12'); + FSOUND_GetChannelsPlaying := GetAddress(FMODHandle, '_FSOUND_GetChannelsPlaying@0'); + FSOUND_GetCPUUsage := GetAddress(FMODHandle, '_FSOUND_GetCPUUsage@0'); + FSOUND_GetMemoryStats := GetAddress(FMODHandle, '_FSOUND_GetMemoryStats@8'); + FSOUND_Sample_Load := GetAddress(FMODHandle, '_FSOUND_Sample_Load@20'); + FSOUND_Sample_Alloc := GetAddress(FMODHandle, '_FSOUND_Sample_Alloc@28'); + FSOUND_Sample_Free := GetAddress(FMODHandle, '_FSOUND_Sample_Free@4'); + FSOUND_Sample_Upload := GetAddress(FMODHandle, '_FSOUND_Sample_Upload@12'); + FSOUND_Sample_Lock := GetAddress(FMODHandle, '_FSOUND_Sample_Lock@28'); + FSOUND_Sample_Unlock := GetAddress(FMODHandle, '_FSOUND_Sample_Unlock@20'); + FSOUND_Sample_SetMode := GetAddress(FMODHandle, '_FSOUND_Sample_SetMode@8'); + FSOUND_Sample_SetLoopPoints := GetAddress(FMODHandle, '_FSOUND_Sample_SetLoopPoints@12'); + FSOUND_Sample_SetDefaults := GetAddress(FMODHandle, '_FSOUND_Sample_SetDefaults@20'); + FSOUND_Sample_SetDefaultsEx := GetAddress(FMODHandle, '_FSOUND_Sample_SetDefaultsEx@32'); + FSOUND_Sample_SetMinMaxDistance := GetAddress(FMODHandle, '_FSOUND_Sample_SetMinMaxDistance@12'); + FSOUND_Sample_SetMaxPlaybacks := GetAddress(FMODHandle, '_FSOUND_Sample_SetMaxPlaybacks@8'); + FSOUND_Sample_Get := GetAddress(FMODHandle, '_FSOUND_Sample_Get@4'); + FSOUND_Sample_GetName := GetAddress(FMODHandle, '_FSOUND_Sample_GetName@4'); + FSOUND_Sample_GetLength := GetAddress(FMODHandle, '_FSOUND_Sample_GetLength@4'); + FSOUND_Sample_GetLoopPoints := GetAddress(FMODHandle, '_FSOUND_Sample_GetLoopPoints@12'); + FSOUND_Sample_GetDefaults := GetAddress(FMODHandle, '_FSOUND_Sample_GetDefaults@20'); + FSOUND_Sample_GetDefaultsEx := GetAddress(FMODHandle, '_FSOUND_Sample_GetDefaultsEx@32'); + FSOUND_Sample_GetMode := GetAddress(FMODHandle, '_FSOUND_Sample_GetMode@4'); + FSOUND_Sample_GetMinMaxDistance := GetAddress(FMODHandle, '_FSOUND_Sample_GetMinMaxDistance@12'); + FSOUND_PlaySound := GetAddress(FMODHandle, '_FSOUND_PlaySound@8'); + FSOUND_PlaySoundEx := GetAddress(FMODHandle, '_FSOUND_PlaySoundEx@16'); + FSOUND_StopSound := GetAddress(FMODHandle, '_FSOUND_StopSound@4'); + FSOUND_SetFrequency := GetAddress(FMODHandle, '_FSOUND_SetFrequency@8'); + FSOUND_SetVolume := GetAddress(FMODHandle, '_FSOUND_SetVolume@8'); + FSOUND_SetVolumeAbsolute := GetAddress(FMODHandle, '_FSOUND_SetVolumeAbsolute@8'); + FSOUND_SetPan := GetAddress(FMODHandle, '_FSOUND_SetPan@8'); + FSOUND_SetSurround := GetAddress(FMODHandle, '_FSOUND_SetSurround@8'); + FSOUND_SetMute := GetAddress(FMODHandle, '_FSOUND_SetMute@8'); + FSOUND_SetPriority := GetAddress(FMODHandle, '_FSOUND_SetPriority@8'); + FSOUND_SetReserved := GetAddress(FMODHandle, '_FSOUND_SetReserved@8'); + FSOUND_SetPaused := GetAddress(FMODHandle, '_FSOUND_SetPaused@8'); + FSOUND_SetLoopMode := GetAddress(FMODHandle, '_FSOUND_SetLoopMode@8'); + FSOUND_SetCurrentPosition := GetAddress(FMODHandle, '_FSOUND_SetCurrentPosition@8'); + FSOUND_3D_SetAttributes := GetAddress(FMODHandle, '_FSOUND_3D_SetAttributes@12'); + FSOUND_3D_SetMinMaxDistance := GetAddress(FMODHandle, '_FSOUND_3D_SetMinMaxDistance@12'); + FSOUND_IsPlaying := GetAddress(FMODHandle, '_FSOUND_IsPlaying@4'); + FSOUND_GetFrequency := GetAddress(FMODHandle, '_FSOUND_GetFrequency@4'); + FSOUND_GetVolume := GetAddress(FMODHandle, '_FSOUND_GetVolume@4'); + FSOUND_GetAmplitude := GetAddress(FMODHandle, '_FSOUND_GetAmplitude@4'); + FSOUND_GetPan := GetAddress(FMODHandle, '_FSOUND_GetPan@4'); + FSOUND_GetSurround := GetAddress(FMODHandle, '_FSOUND_GetSurround@4'); + FSOUND_GetMute := GetAddress(FMODHandle, '_FSOUND_GetMute@4'); + FSOUND_GetPriority := GetAddress(FMODHandle, '_FSOUND_GetPriority@4'); + FSOUND_GetReserved := GetAddress(FMODHandle, '_FSOUND_GetReserved@4'); + FSOUND_GetPaused := GetAddress(FMODHandle, '_FSOUND_GetPaused@4'); + FSOUND_GetLoopMode := GetAddress(FMODHandle, '_FSOUND_GetLoopMode@4'); + FSOUND_GetCurrentPosition := GetAddress(FMODHandle, '_FSOUND_GetCurrentPosition@4'); + FSOUND_GetCurrentSample := GetAddress(FMODHandle, '_FSOUND_GetCurrentSample@4'); + FSOUND_GetCurrentLevels := GetAddress(FMODHandle, '_FSOUND_GetCurrentLevels@12'); + FSOUND_GetNumSubChannels := GetAddress(FMODHandle, '_FSOUND_GetNumSubChannels@4'); + FSOUND_GetSubChannel := GetAddress(FMODHandle, '_FSOUND_GetSubChannel@8'); + FSOUND_3D_GetAttributes := GetAddress(FMODHandle, '_FSOUND_3D_GetAttributes@12'); + FSOUND_3D_GetMinMaxDistance := GetAddress(FMODHandle, '_FSOUND_3D_GetMinMaxDistance@12'); + FSOUND_3D_Listener_SetCurrent := GetAddress(FMODHandle, '_FSOUND_3D_Listener_SetCurrent@8'); + FSOUND_3D_Listener_SetAttributes := GetAddress(FMODHandle, '_FSOUND_3D_Listener_SetAttributes@32'); + FSOUND_3D_Listener_GetAttributes := GetAddress(FMODHandle, '_FSOUND_3D_Listener_GetAttributes@32'); + FSOUND_3D_SetDopplerFactor := GetAddress(FMODHandle, '_FSOUND_3D_SetDopplerFactor@4'); + FSOUND_3D_SetDistanceFactor := GetAddress(FMODHandle, '_FSOUND_3D_SetDistanceFactor@4'); + FSOUND_3D_SetRolloffFactor := GetAddress(FMODHandle, '_FSOUND_3D_SetRolloffFactor@4'); + FSOUND_FX_Enable := GetAddress(FMODHandle, '_FSOUND_FX_Enable@8'); + FSOUND_FX_SetChorus := GetAddress(FMODHandle, '_FSOUND_FX_SetChorus@32'); + FSOUND_FX_SetCompressor := GetAddress(FMODHandle, '_FSOUND_FX_SetCompressor@28'); + FSOUND_FX_SetDistortion := GetAddress(FMODHandle, '_FSOUND_FX_SetDistortion@24'); + FSOUND_FX_SetEcho := GetAddress(FMODHandle, '_FSOUND_FX_SetEcho@24'); + FSOUND_FX_SetFlanger := GetAddress(FMODHandle, '_FSOUND_FX_SetFlanger@32'); + FSOUND_FX_SetGargle := GetAddress(FMODHandle, '_FSOUND_FX_SetGargle@12'); + FSOUND_FX_SetI3DL2Reverb := GetAddress(FMODHandle, '_FSOUND_FX_SetI3DL2Reverb@52'); + FSOUND_FX_SetParamEQ := GetAddress(FMODHandle, '_FSOUND_FX_SetParamEQ@16'); + FSOUND_FX_SetWavesReverb := GetAddress(FMODHandle, '_FSOUND_FX_SetWavesReverb@20'); + FSOUND_Stream_Open := GetAddress(FMODHandle, '_FSOUND_Stream_Open@16'); + FSOUND_Stream_Create := GetAddress(FMODHandle, '_FSOUND_Stream_Create@20'); + FSOUND_Stream_Close := GetAddress(FMODHandle, '_FSOUND_Stream_Close@4'); + FSOUND_Stream_Play := GetAddress(FMODHandle, '_FSOUND_Stream_Play@8'); + FSOUND_Stream_PlayEx := GetAddress(FMODHandle, '_FSOUND_Stream_PlayEx@16'); + FSOUND_Stream_Stop := GetAddress(FMODHandle, '_FSOUND_Stream_Stop@4'); + FSOUND_Stream_SetEndCallback := GetAddress(FMODHandle, '_FSOUND_Stream_SetEndCallback@12'); + FSOUND_Stream_SetSyncCallback := GetAddress(FMODHandle, '_FSOUND_Stream_SetSyncCallback@12'); + FSOUND_Stream_GetSample := GetAddress(FMODHandle, '_FSOUND_Stream_GetSample@4'); + FSOUND_Stream_CreateDSP := GetAddress(FMODHandle, '_FSOUND_Stream_CreateDSP@16'); + FSOUND_Stream_SetBufferSize := GetAddress(FMODHandle, '_FSOUND_Stream_SetBufferSize@4'); + FSOUND_Stream_SetPosition := GetAddress(FMODHandle, '_FSOUND_Stream_SetPosition@8'); + FSOUND_Stream_GetPosition := GetAddress(FMODHandle, '_FSOUND_Stream_GetPosition@4'); + FSOUND_Stream_SetTime := GetAddress(FMODHandle, '_FSOUND_Stream_SetTime@8'); + FSOUND_Stream_GetTime := GetAddress(FMODHandle, '_FSOUND_Stream_GetTime@4'); + FSOUND_Stream_GetLength := GetAddress(FMODHandle, '_FSOUND_Stream_GetLength@4'); + FSOUND_Stream_GetLengthMs := GetAddress(FMODHandle, '_FSOUND_Stream_GetLengthMs@4'); + FSOUND_Stream_SetMode := GetAddress(FMODHandle, '_FSOUND_Stream_SetMode@8'); + FSOUND_Stream_GetMode := GetAddress(FMODHandle, '_FSOUND_Stream_GetMode@4'); + FSOUND_Stream_SetLoopPoints := GetAddress(FMODHandle, '_FSOUND_Stream_SetLoopPoints@12'); + FSOUND_Stream_SetLoopCount := GetAddress(FMODHandle, '_FSOUND_Stream_SetLoopCount@8'); + FSOUND_Stream_GetOpenState := GetAddress(FMODHandle, '_FSOUND_Stream_GetOpenState@4'); + FSOUND_Stream_AddSyncPoint := GetAddress(FMODHandle, '_FSOUND_Stream_AddSyncPoint@12'); + FSOUND_Stream_DeleteSyncPoint := GetAddress(FMODHandle, '_FSOUND_Stream_DeleteSyncPoint@4'); + FSOUND_Stream_GetNumSyncPoints := GetAddress(FMODHandle, '_FSOUND_Stream_GetNumSyncPoints@4'); + FSOUND_Stream_GetSyncPoint := GetAddress(FMODHandle, '_FSOUND_Stream_GetSyncPoint@8'); + FSOUND_Stream_GetSyncPointInfo := GetAddress(FMODHandle, '_FSOUND_Stream_GetSyncPointInfo@8'); + FSOUND_Stream_SetSubStream := GetAddress(FMODHandle, '_FSOUND_Stream_SetSubStream@8'); + FSOUND_Stream_GetNumSubStreams := GetAddress(FMODHandle, '_FSOUND_Stream_GetNumSubStreams@4'); + FSOUND_Stream_SetSubStreamSentence := GetAddress(FMODHandle, '_FSOUND_Stream_SetSubStreamSentence@12'); + FSOUND_Stream_GetNumTagFields := GetAddress(FMODHandle, '_FSOUND_Stream_GetNumTagFields@8'); + FSOUND_Stream_GetTagField := GetAddress(FMODHandle, '_FSOUND_Stream_GetTagField@24'); + FSOUND_Stream_FindTagField := GetAddress(FMODHandle, '_FSOUND_Stream_FindTagField@20'); + FSOUND_Stream_Net_SetProxy := GetAddress(FMODHandle, '_FSOUND_Stream_Net_SetProxy@4'); + FSOUND_Stream_Net_GetLastServerStatus := GetAddress(FMODHandle, '_FSOUND_Stream_Net_GetLastServerStatus@0'); + FSOUND_Stream_Net_SetBufferProperties := GetAddress(FMODHandle, '_FSOUND_Stream_Net_SetBufferProperties@12'); + FSOUND_Stream_Net_GetBufferProperties := GetAddress(FMODHandle, '_FSOUND_Stream_Net_GetBufferProperties@12'); + FSOUND_Stream_Net_SetMetadataCallback := GetAddress(FMODHandle, '_FSOUND_Stream_Net_SetMetadataCallback@12'); + FSOUND_Stream_Net_GetStatus := GetAddress(FMODHandle, '_FSOUND_Stream_Net_GetStatus@20'); + FSOUND_CD_Play := GetAddress(FMODHandle, '_FSOUND_CD_Play@8'); + FSOUND_CD_SetPlayMode := GetAddress(FMODHandle, '_FSOUND_CD_SetPlayMode@8'); + FSOUND_CD_Stop := GetAddress(FMODHandle, '_FSOUND_CD_Stop@4'); + FSOUND_CD_SetPaused := GetAddress(FMODHandle, '_FSOUND_CD_SetPaused@8'); + FSOUND_CD_SetVolume := GetAddress(FMODHandle, '_FSOUND_CD_SetVolume@8'); + FSOUND_CD_SetTrackTime := GetAddress(FMODHandle, '_FSOUND_CD_SetTrackTime@8'); + FSOUND_CD_OpenTray := GetAddress(FMODHandle, '_FSOUND_CD_OpenTray@8'); + FSOUND_CD_GetPaused := GetAddress(FMODHandle, '_FSOUND_CD_GetPaused@4'); + FSOUND_CD_GetTrack := GetAddress(FMODHandle, '_FSOUND_CD_GetTrack@4'); + FSOUND_CD_GetNumTracks := GetAddress(FMODHandle, '_FSOUND_CD_GetNumTracks@4'); + FSOUND_CD_GetVolume := GetAddress(FMODHandle, '_FSOUND_CD_GetVolume@4'); + FSOUND_CD_GetTrackLength := GetAddress(FMODHandle, '_FSOUND_CD_GetTrackLength@8'); + FSOUND_CD_GetTrackTime := GetAddress(FMODHandle, '_FSOUND_CD_GetTrackTime@4'); + FSOUND_DSP_Create := GetAddress(FMODHandle, '_FSOUND_DSP_Create@12'); + FSOUND_DSP_Free := GetAddress(FMODHandle, '_FSOUND_DSP_Free@4'); + FSOUND_DSP_SetPriority := GetAddress(FMODHandle, '_FSOUND_DSP_SetPriority@8'); + FSOUND_DSP_GetPriority := GetAddress(FMODHandle, '_FSOUND_DSP_GetPriority@4'); + FSOUND_DSP_SetActive := GetAddress(FMODHandle, '_FSOUND_DSP_SetActive@8'); + FSOUND_DSP_GetActive := GetAddress(FMODHandle, '_FSOUND_DSP_GetActive@4'); + FSOUND_DSP_GetClearUnit := GetAddress(FMODHandle, '_FSOUND_DSP_GetClearUnit@0'); + FSOUND_DSP_GetSFXUnit := GetAddress(FMODHandle, '_FSOUND_DSP_GetSFXUnit@0'); + FSOUND_DSP_GetMusicUnit := GetAddress(FMODHandle, '_FSOUND_DSP_GetMusicUnit@0'); + FSOUND_DSP_GetClipAndCopyUnit := GetAddress(FMODHandle, '_FSOUND_DSP_GetClipAndCopyUnit@0'); + FSOUND_DSP_GetFFTUnit := GetAddress(FMODHandle, '_FSOUND_DSP_GetFFTUnit@0'); + FSOUND_DSP_MixBuffers := GetAddress(FMODHandle, '_FSOUND_DSP_MixBuffers@28'); + FSOUND_DSP_ClearMixBuffer := GetAddress(FMODHandle, '_FSOUND_DSP_ClearMixBuffer@0'); + FSOUND_DSP_GetBufferLength := GetAddress(FMODHandle, '_FSOUND_DSP_GetBufferLength@0'); + FSOUND_DSP_GetBufferLengthTotal := GetAddress(FMODHandle, '_FSOUND_DSP_GetBufferLengthTotal@0'); + FSOUND_DSP_GetSpectrum := GetAddress(FMODHandle, '_FSOUND_DSP_GetSpectrum@0'); + FSOUND_Reverb_SetProperties := GetAddress(FMODHandle, '_FSOUND_Reverb_SetProperties@4'); + FSOUND_Reverb_GetProperties := GetAddress(FMODHandle, '_FSOUND_Reverb_GetProperties@4'); + FSOUND_Reverb_SetChannelProperties := GetAddress(FMODHandle, '_FSOUND_Reverb_SetChannelProperties@8'); + FSOUND_Reverb_GetChannelProperties := GetAddress(FMODHandle, '_FSOUND_Reverb_GetChannelProperties@8'); + FSOUND_Record_SetDriver := GetAddress(FMODHandle, '_FSOUND_Record_SetDriver@4'); + FSOUND_Record_GetNumDrivers := GetAddress(FMODHandle, '_FSOUND_Record_GetNumDrivers@0'); + FSOUND_Record_GetDriverName := GetAddress(FMODHandle, '_FSOUND_Record_GetDriverName@4'); + FSOUND_Record_GetDriver := GetAddress(FMODHandle, '_FSOUND_Record_GetDriver@0'); + FSOUND_Record_StartSample := GetAddress(FMODHandle, '_FSOUND_Record_StartSample@8'); + FSOUND_Record_Stop := GetAddress(FMODHandle, '_FSOUND_Record_Stop@0'); + FSOUND_Record_GetPosition := GetAddress(FMODHandle, '_FSOUND_Record_GetPosition@0'); + FSOUND_File_SetCallbacks := GetAddress(FMODHandle, '_FSOUND_File_SetCallbacks@20'); + FMUSIC_LoadSong := GetAddress(FMODHandle, '_FMUSIC_LoadSong@4'); + FMUSIC_LoadSongEx := GetAddress(FMODHandle, '_FMUSIC_LoadSongEx@24'); + FMUSIC_GetOpenState := GetAddress(FMODHandle, '_FMUSIC_GetOpenState@4'); + FMUSIC_FreeSong := GetAddress(FMODHandle, '_FMUSIC_FreeSong@4'); + FMUSIC_PlaySong := GetAddress(FMODHandle, '_FMUSIC_PlaySong@4'); + FMUSIC_StopSong := GetAddress(FMODHandle, '_FMUSIC_StopSong@4'); + FMUSIC_StopAllSongs := GetAddress(FMODHandle, '_FMUSIC_StopAllSongs@0'); + FMUSIC_SetZxxCallback := GetAddress(FMODHandle, '_FMUSIC_SetZxxCallback@8'); + FMUSIC_SetRowCallback := GetAddress(FMODHandle, '_FMUSIC_SetRowCallback@12'); + FMUSIC_SetOrderCallback := GetAddress(FMODHandle, '_FMUSIC_SetOrderCallback@12'); + FMUSIC_SetInstCallback := GetAddress(FMODHandle, '_FMUSIC_SetInstCallback@12'); + FMUSIC_SetSample := GetAddress(FMODHandle, '_FMUSIC_SetSample@12'); + FMUSIC_SetUserData := GetAddress(FMODHandle, '_FMUSIC_SetUserData@8'); + FMUSIC_OptimizeChannels := GetAddress(FMODHandle, '_FMUSIC_OptimizeChannels@12'); + FMUSIC_SetReverb := GetAddress(FMODHandle, '_FMUSIC_SetReverb@4'); + FMUSIC_SetLooping := GetAddress(FMODHandle, '_FMUSIC_SetLooping@8'); + FMUSIC_SetOrder := GetAddress(FMODHandle, '_FMUSIC_SetOrder@8'); + FMUSIC_SetPaused := GetAddress(FMODHandle, '_FMUSIC_SetPaused@8'); + FMUSIC_SetMasterVolume := GetAddress(FMODHandle, '_FMUSIC_SetMasterVolume@8'); + FMUSIC_SetMasterSpeed := GetAddress(FMODHandle, '_FMUSIC_SetMasterSpeed@8'); + FMUSIC_SetPanSeperation := GetAddress(FMODHandle, '_FMUSIC_SetPanSeperation@8'); + FMUSIC_GetName := GetAddress(FMODHandle, '_FMUSIC_GetName@4'); + FMUSIC_GetType := GetAddress(FMODHandle, '_FMUSIC_GetType@4'); + FMUSIC_GetNumOrders := GetAddress(FMODHandle, '_FMUSIC_GetNumOrders@4'); + FMUSIC_GetNumPatterns := GetAddress(FMODHandle, '_FMUSIC_GetNumPatterns@4'); + FMUSIC_GetNumInstruments := GetAddress(FMODHandle, '_FMUSIC_GetNumInstruments@4'); + FMUSIC_GetNumSamples := GetAddress(FMODHandle, '_FMUSIC_GetNumSamples@4'); + FMUSIC_GetNumChannels := GetAddress(FMODHandle, '_FMUSIC_GetNumChannels@4'); + FMUSIC_GetSample := GetAddress(FMODHandle, '_FMUSIC_GetSample@8'); + FMUSIC_GetPatternLength := GetAddress(FMODHandle, '_FMUSIC_GetPatternLength@8'); + FMUSIC_IsFinished := GetAddress(FMODHandle, '_FMUSIC_IsFinished@4'); + FMUSIC_IsPlaying := GetAddress(FMODHandle, '_FMUSIC_IsPlaying@4'); + FMUSIC_GetMasterVolume := GetAddress(FMODHandle, '_FMUSIC_GetMasterVolume@4'); + FMUSIC_GetGlobalVolume := GetAddress(FMODHandle, '_FMUSIC_GetGlobalVolume@4'); + FMUSIC_GetOrder := GetAddress(FMODHandle, '_FMUSIC_GetOrder@4'); + FMUSIC_GetPattern := GetAddress(FMODHandle, '_FMUSIC_GetPattern@4'); + FMUSIC_GetSpeed := GetAddress(FMODHandle, '_FMUSIC_GetSpeed@4'); + FMUSIC_GetBPM := GetAddress(FMODHandle, '_FMUSIC_GetBPM@4'); + FMUSIC_GetRow := GetAddress(FMODHandle, '_FMUSIC_GetRow@4'); + FMUSIC_GetPaused := GetAddress(FMODHandle, '_FMUSIC_GetPaused@4'); + FMUSIC_GetTime := GetAddress(FMODHandle, '_FMUSIC_GetTime@4'); + FMUSIC_GetRealChannel := GetAddress(FMODHandle, '_FMUSIC_GetRealChannel@8'); + FMUSIC_GetUserData := GetAddress(FMODHandle, '_FMUSIC_GetUserData@4'); + + Result := True; +end; + +procedure FMOD_Unload; +begin + { Only free the library if it was already loaded } + if FMODHandle <> INVALID_MODULEHANDLE_VALUE then +{$IFDEF MSWINDOWS} + FreeLibrary(FMODHandle); +{$ELSE} + dlclose(FMODHandle); +{$ENDIF} + FMODHandle := INVALID_MODULEHANDLE_VALUE; +end; + +var + Saved8087CW: Word; + +{$ifdef FPC} //FPC do not have this function in its RTL +const + Default8087CW = $1332; //according to the FPC site it's the value used in the + //startup code. +procedure Set8087CW( value :word ); Assembler; +asm + FLDCW value +end; +{$endif} + +initialization + FMODHandle := INVALID_MODULEHANDLE_VALUE; + + { Save the current FPU state and then disable FPU exceptions } + Saved8087CW := Default8087CW; + Set8087CW($133f); { Disable all fpu exceptions } + +finalization + { Make sure the library is unloaded } + FMOD_Unload; + + { Reset the FPU to the previous state } + Set8087CW(Saved8087CW); +end. \ No newline at end of file diff --git a/lib/fmodapi375win/api/delphi/fmoderrors.dcu b/lib/fmodapi375win/api/delphi/fmoderrors.dcu new file mode 100644 index 0000000..3ac25d6 Binary files /dev/null and b/lib/fmodapi375win/api/delphi/fmoderrors.dcu differ diff --git a/lib/fmodapi375win/api/delphi/fmoderrors.pas b/lib/fmodapi375win/api/delphi/fmoderrors.pas new file mode 100644 index 0000000..91f7352 --- /dev/null +++ b/lib/fmodapi375win/api/delphi/fmoderrors.pas @@ -0,0 +1,67 @@ +{ =============================================================================================== } +{ FMOD Main header file. Copyright (c), Firelight Technologies Pty, Ltd. 1999-2004. } +{ =============================================================================================== } +{ + NOTE: For the demos to run you must have either fmod.dll (in Windows) + or libfmod-3.75.so (in Linux) installed. + + In Windows, copy the fmod.dll file found in the api directory to either of + the following locations (in order of preference) + - your application directory + - Windows\System (95/98) or WinNT\System32 (NT/2000/XP) + + In Linux, make sure you are signed in as root and copy the libfmod-3.75.so + file from the api directory to your /usr/lib/ directory. + Then via a command line, navigate to the /usr/lib/ directory and create + a symbolic link between libfmod-3.75.so and libfmod.so. This is done with + the following command (assuming you are in /usr/lib/)... + ln -s libfmod-3.75.so libfmod.so. +} +{ =============================================================================================== } + +unit fmoderrors; + +interface + +uses + fmodtypes; + +{ + Disable warning for unsafe types in Delphi 7 +} +{$IFDEF VER150} +{$WARN UNSAFE_TYPE OFF} +{$ENDIF} + +function FMOD_ErrorString(ErrorCode: TFModErrors): PChar; + +implementation + +function FMOD_ErrorString(ErrorCode: TFModErrors): PChar; +begin + case ErrorCode of + FMOD_ERR_NONE: Result := 'No errors'; + FMOD_ERR_BUSY: Result := 'Cannot call this command after FSOUND_Init. Call FSOUND_Close first'; + FMOD_ERR_UNINITIALIZED: Result := 'This command failed because FSOUND_Init was not called'; + FMOD_ERR_PLAY: Result := 'Playing the sound failed'; + FMOD_ERR_INIT: Result := 'Error initializing output device'; + FMOD_ERR_ALLOCATED: Result := 'The output device is already in use and cannot be reused'; + FMOD_ERR_OUTPUT_FORMAT: Result := 'Soundcard does not support the features needed for this soundsystem (16bit stereo output)'; + FMOD_ERR_COOPERATIVELEVEL: Result := 'Error setting cooperative level for hardware'; + FMOD_ERR_CREATEBUFFER: Result := 'Error creating hardware sound buffer'; + FMOD_ERR_FILE_NOTFOUND: Result := 'File not found'; + FMOD_ERR_FILE_FORMAT: Result := 'Unknown file format'; + FMOD_ERR_FILE_BAD: Result := 'Error loading file'; + FMOD_ERR_MEMORY: Result := 'Not enough memory or resources'; + FMOD_ERR_VERSION: Result := 'The version number of this file format is not supported'; + FMOD_ERR_INVALID_PARAM: Result := 'An invalid parameter was passed to this function'; + FMOD_ERR_NO_EAX: Result := 'Tried to use an EAX command on a non EAX enabled channel or output'; + FMOD_ERR_CHANNEL_ALLOC: Result := 'Failed to allocate a new channel'; + FMOD_ERR_RECORD: Result := 'Recording is not supported on this machine'; + FMOD_ERR_MEDIAPLAYER: Result := 'Required Mediaplayer codec is not installed'; + else + Result := 'Unknown error'; + end; +end; + +end. diff --git a/lib/fmodapi375win/api/delphi/fmodpresets.pas b/lib/fmodapi375win/api/delphi/fmodpresets.pas new file mode 100644 index 0000000..0120458 --- /dev/null +++ b/lib/fmodapi375win/api/delphi/fmodpresets.pas @@ -0,0 +1,95 @@ +{ =============================================================================================== } +{ FMOD presets header file. Copyright (c), FireLight Technologies Pty, Ltd. 1999-2004. } +{ =============================================================================================== } +{ + NOTE: For the demos to run you must have either fmod.dll (in Windows) + or libfmod-3.75.so (in Linux) installed. + + In Windows, copy the fmod.dll file found in the api directory to either of + the following locations (in order of preference) + - your application directory + - Windows\System (95/98) or WinNT\System32 (NT/2000/XP) + + In Linux, make sure you are signed in as root and copy the libfmod-3.75.so + file from the api directory to your /usr/lib/ directory. + Then via a command line, navigate to the /usr/lib/ directory and create + a symbolic link between libfmod-3.5.so and libfmod.so. This is done with + the following command (assuming you are in /usr/lib/)... + ln -s libfmod-3.75.so libfmod.so. +} + +unit fmodpresets; + +interface + +uses + fmodtypes; + +{$IFDEF VER140} +{$DEFINE COMPILER6_UP} +{$ELSE} + {$IFDEF VER150} + {$DEFINE COMPILER6_UP} + {$ENDIF} +{$ENDIF} + +(* +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_PRESETS + + [DESCRIPTION] + A set of predefined environment PARAMETERS, created by Creative Labs + These are used to initialize an FSOUND_REVERB_PROPERTIES structure statically. + ie + FSOUND_REVERB_PROPERTIES prop = FSOUND_PRESET_GENERIC; + + [SEE_ALSO] + FSOUND_Reverb_SetProperties +] +*) + +{$IFDEF COMPILER6_UP}{$J+}{$ENDIF} +const + FSOUND_PRESET_OFF: TFSoundReverbProperties = (Environment: 0; EnvSize: 7.5; EnvDiffusion: 1.00; Room: -10000; RoomHF: -10000; RoomLF: 0; DecayTime: 1.00; DecayHFRatio: 1.00; DecayLFRatio: 1.0; Reflections: -2602; ReflectionsDelay: 0.007; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 200; ReverbDelay: 0.011; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 0.0; Density: 0.0; Flags: $33f); + FSOUND_PRESET_GENERIC: TFSoundReverbProperties = (Environment: 0; EnvSize: 7.5; EnvDiffusion: 1.00; Room: -1000; RoomHF: -100; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.83; DecayLFRatio: 1.0; Reflections: -2602; ReflectionsDelay: 0.007; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 200; ReverbDelay: 0.011; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_PADDEDCELL: TFSoundReverbProperties = (Environment: 1; EnvSize: 1.4; EnvDiffusion: 1.00; Room: -1000; RoomHF: -6000; RoomLF: 0; DecayTime: 0.17; DecayHFRatio: 0.10; DecayLFRatio: 1.0; Reflections: -1204; ReflectionsDelay: 0.001; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 207; ReverbDelay: 0.002; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_ROOM: TFSoundReverbProperties = (Environment: 2; EnvSize: 1.9; EnvDiffusion: 1.00; Room: -1000; RoomHF: -454; RoomLF: 0; DecayTime: 0.40; DecayHFRatio: 0.83; DecayLFRatio: 1.0; Reflections: -1646; ReflectionsDelay: 0.002; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 53; ReverbDelay: 0.003; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_BATHROOM: TFSoundReverbProperties = (Environment: 3; EnvSize: 1.4; EnvDiffusion: 1.00; Room: -1000; RoomHF: -1200; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.54; DecayLFRatio: 1.0; Reflections: -370; ReflectionsDelay: 0.007; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 1030; ReverbDelay: 0.011; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 60.0; Flags: $3f); + FSOUND_PRESET_LIVINGROOM: TFSoundReverbProperties = (Environment: 4; EnvSize: 2.5; EnvDiffusion: 1.00; Room: -1000; RoomHF: -6000; RoomLF: 0; DecayTime: 0.50; DecayHFRatio: 0.10; DecayLFRatio: 1.0; Reflections: -1376; ReflectionsDelay: 0.003; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-1104; ReverbDelay: 0.004; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_STONEROOM: TFSoundReverbProperties = (Environment: 5; EnvSize: 11.6; EnvDiffusion: 1.00; Room: -1000; RoomHF: -300; RoomLF: 0; DecayTime: 2.31; DecayHFRatio: 0.64; DecayLFRatio: 1.0; Reflections: -711; ReflectionsDelay: 0.012; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 83; ReverbDelay: 0.017; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_AUDITORIUM: TFSoundReverbProperties = (Environment: 6; EnvSize: 21.6; EnvDiffusion: 1.00; Room: -1000; RoomHF: -476; RoomLF: 0; DecayTime: 4.32; DecayHFRatio: 0.59; DecayLFRatio: 1.0; Reflections: -789; ReflectionsDelay: 0.020; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-289; ReverbDelay: 0.030; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_CONCERTHALL: TFSoundReverbProperties = (Environment: 7; EnvSize: 19.6; EnvDiffusion: 1.00; Room: -1000; RoomHF: -500; RoomLF: 0; DecayTime: 3.92; DecayHFRatio: 0.70; DecayLFRatio: 1.0; Reflections: -1230; ReflectionsDelay: 0.020; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-2; ReverbDelay: 0.029; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_CAVE: TFSoundReverbProperties = (Environment: 8; EnvSize: 14.6; EnvDiffusion: 1.00; Room: -1000; RoomHF: 0; RoomLF: 0; DecayTime: 2.91; DecayHFRatio: 1.30; DecayLFRatio: 1.0; Reflections: -602; ReflectionsDelay: 0.015; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-302; ReverbDelay: 0.022; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $1f); + FSOUND_PRESET_ARENA: TFSoundReverbProperties = (Environment: 9; EnvSize: 36.2; EnvDiffusion: 1.00; Room: -1000; RoomHF: -698; RoomLF: 0; DecayTime: 7.24; DecayHFRatio: 0.33; DecayLFRatio: 1.0; Reflections: -1166; ReflectionsDelay: 0.020; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 16; ReverbDelay: 0.030; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_HANGAR: TFSoundReverbProperties = (Environment: 10; EnvSize: 50.3; EnvDiffusion: 1.00; Room: -1000; RoomHF: -1000; RoomLF: 0; DecayTime: 10.05; DecayHFRatio: 0.23; DecayLFRatio: 1.0; Reflections: -602; ReflectionsDelay: 0.020; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 198; ReverbDelay: 0.030; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_CARPETTEDHALLWAY: TFSoundReverbProperties = (Environment: 11; EnvSize: 1.9; EnvDiffusion: 1.00; Room: -1000; RoomHF: -4000; RoomLF: 0; DecayTime: 0.30; DecayHFRatio: 0.10; DecayLFRatio: 1.0; Reflections: -1831; ReflectionsDelay: 0.002; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-1630; ReverbDelay: 0.030; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_HALLWAY: TFSoundReverbProperties = (Environment: 12; EnvSize: 1.8; EnvDiffusion: 1.00; Room: -1000; RoomHF: -300; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.59; DecayLFRatio: 1.0; Reflections: -1219; ReflectionsDelay: 0.007; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 441; ReverbDelay: 0.011; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_STONECORRIDOR: TFSoundReverbProperties = (Environment: 13; EnvSize: 13.5; EnvDiffusion: 1.00; Room: -1000; RoomHF: -237; RoomLF: 0; DecayTime: 2.70; DecayHFRatio: 0.79; DecayLFRatio: 1.0; Reflections: -1214; ReflectionsDelay: 0.013; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 395; ReverbDelay: 0.020; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_ALLEY: TFSoundReverbProperties = (Environment: 14; EnvSize: 7.5; EnvDiffusion: 0.30; Room: -1000; RoomHF: -270; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.86; DecayLFRatio: 1.0; Reflections: -1204; ReflectionsDelay: 0.007; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-4; ReverbDelay: 0.011; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.125; EchoDepth: 0.95; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_FOREST: TFSoundReverbProperties = (Environment: 15; EnvSize: 38.0; EnvDiffusion: 0.30; Room: -1000; RoomHF: -3300; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.54; DecayLFRatio: 1.0; Reflections: -2560; ReflectionsDelay: 0.162; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-229; ReverbDelay: 0.088; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.125; EchoDepth: 1.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 79.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_CITY: TFSoundReverbProperties = (Environment: 16; EnvSize: 7.5; EnvDiffusion: 0.50; Room: -1000; RoomHF: -800; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.67; DecayLFRatio: 1.0; Reflections: -2273; ReflectionsDelay: 0.007; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-1691; ReverbDelay: 0.011; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 50.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_MOUNTAINS: TFSoundReverbProperties = (Environment: 17; EnvSize: 100.0; EnvDiffusion: 0.27; Room: -1000; RoomHF: -2500; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.21; DecayLFRatio: 1.0; Reflections: -2780; ReflectionsDelay: 0.300; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-1434; ReverbDelay: 0.100; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 1.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 27.0; Density: 100.0; Flags: $1f); + FSOUND_PRESET_QUARRY: TFSoundReverbProperties = (Environment: 18; EnvSize: 17.5; EnvDiffusion: 1.00; Room: -1000; RoomHF: -1000; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.83; DecayLFRatio: 1.0; Reflections: -10000;ReflectionsDelay: 0.061; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 500; ReverbDelay: 0.025; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.125; EchoDepth: 0.70; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_PLAIN: TFSoundReverbProperties = (Environment: 19; EnvSize: 42.5; EnvDiffusion: 0.21; Room: -1000; RoomHF: -2000; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.50; DecayLFRatio: 1.0; Reflections: -2466; ReflectionsDelay: 0.179; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-1926; ReverbDelay: 0.100; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 1.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 21.0; Density: 100.0; Flags: $3f); + FSOUND_PRESET_PARKINGLOT: TFSoundReverbProperties = (Environment: 20; EnvSize: 8.3; EnvDiffusion: 1.00; Room: -1000; RoomHF: 0; RoomLF: 0; DecayTime: 1.65; DecayHFRatio: 1.50; DecayLFRatio: 1.0; Reflections: -1363; ReflectionsDelay: 0.008; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-1153; ReverbDelay: 0.012; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $1f); + FSOUND_PRESET_SEWERPIPE: TFSoundReverbProperties = (Environment: 21; EnvSize: 1.7; EnvDiffusion: 0.80; Room: -1000; RoomHF: -1000; RoomLF: 0; DecayTime: 2.81; DecayHFRatio: 0.14; DecayLFRatio: 1.0; Reflections: 429; ReflectionsDelay: 0.014; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 1023; ReverbDelay: 0.021; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 0.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 80.0; Density: 60.0; Flags: $3f); + FSOUND_PRESET_UNDERWATER: TFSoundReverbProperties = (Environment: 22; EnvSize: 1.8; EnvDiffusion: 1.00; Room: -1000; RoomHF: -4000; RoomLF: 0; DecayTime: 1.49; DecayHFRatio: 0.10; DecayLFRatio: 1.0; Reflections: -449; ReflectionsDelay: 0.007; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 1700; ReverbDelay: 0.011; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 1.18; ModulationDepth: 0.348; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $3f); + +(* Non I3DL2 presets *) + + FSOUND_PRESET_DRUGGED: TFSoundReverbProperties = (Environment: 23; EnvSize: 1.9; EnvDiffusion: 0.50; Room: -1000; RoomHF: 0; RoomLF: 0; DecayTime: 8.39; DecayHFRatio: 1.39; DecayLFRatio: 1.0; Reflections: -115; ReflectionsDelay: 0.002; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 985; ReverbDelay: 0.030; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 0.25; ModulationDepth: 1.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $1f); + FSOUND_PRESET_DIZZY: TFSoundReverbProperties = (Environment: 24; EnvSize: 1.8; EnvDiffusion: 0.60; Room: -1000; RoomHF: -400; RoomLF: 0; DecayTime: 17.23; DecayHFRatio: 0.56; DecayLFRatio: 1.0; Reflections: -1713; ReflectionsDelay: 0.020; ReflectionsPan: (0.0, 0.0, 0.0); Reverb:-613; ReverbDelay: 0.030; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 1.00; ModulationTime: 0.81; ModulationDepth: 0.310; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $1f); + FSOUND_PRESET_PSYCHOTIC: TFSoundReverbProperties = (Environment: 25; EnvSize: 1.0; EnvDiffusion: 0.50; Room: -1000; RoomHF: -151; RoomLF: 0; DecayTime: 7.56; DecayHFRatio: 0.91; DecayLFRatio: 1.0; Reflections: -626; ReflectionsDelay: 0.020; ReflectionsPan: (0.0, 0.0, 0.0); Reverb: 774; ReverbDelay: 0.030; ReverbPan: (0.0, 0.0, 0.0); EchoTime: 0.250; EchoDepth: 0.00; ModulationTime: 4.00; ModulationDepth: 1.000; AirAbsorptionHF: -5.0; HFReference: 5000.0; LFReference: 250.0; RoomRolloffFactor: 0.0; Diffusion: 100.0; Density: 100.0; Flags: $1f); + +(* PlayStation 2 Only presets *) +(* Delphi/Kylix cannot create PlayStation 2 executables, so there is no need to + convert the PlayStation 2 presets. *) +{$IFDEF COMPILER6_UP}{$J-}{$ENDIF} + +(* [DEFINE_END] *) + +implementation + +end. diff --git a/lib/fmodapi375win/api/delphi/fmodtypes.dcu b/lib/fmodapi375win/api/delphi/fmodtypes.dcu new file mode 100644 index 0000000..3af0e6a Binary files /dev/null and b/lib/fmodapi375win/api/delphi/fmodtypes.dcu differ diff --git a/lib/fmodapi375win/api/delphi/fmodtypes.pas b/lib/fmodapi375win/api/delphi/fmodtypes.pas new file mode 100644 index 0000000..9a9c015 --- /dev/null +++ b/lib/fmodapi375win/api/delphi/fmodtypes.pas @@ -0,0 +1,821 @@ +{================================================================================================ } +{ FMOD Types header file. Copyright (c), Firelight Technologies Pty, Ltd. 1999-2004. } +{ =============================================================================================== } +{ + NOTE: For the demos to run you must have either fmod.dll (in Windows) + or libfmod-3.75.so (in Linux) installed. + + In Windows, copy the fmod.dll file found in the api directory to either of + the following locations (in order of preference) + - your application directory + - Windows\System (95/98) or WinNT\System32 (NT/2000/XP) + + In Linux, make sure you are signed in as root and copy the libfmod-3.75.so + file from the api directory to your /usr/lib/ directory. + Then via a command line, navigate to the /usr/lib/ directory and create + a symbolic link between libfmod-3.75.so and libfmod.so. This is done with + the following command (assuming you are in /usr/lib/)... + ln -s libfmod-3.75.so libfmod.so. +} +{ =============================================================================================== } + +unit fmodtypes; + +{$IFDEF FPC} + {$MODE DELPHI} + {$IFDEF WIN32} + {$DEFINE MSWINDOWS} + {$ENDIF} + {$PACKRECORDS C} +{$ENDIF} + +{$IFDEF VER110} + {$DEFINE DELPHI_5_OR_LOWER} +{$ELSE} + {$IFDEF VER120} + {$DEFINE DELPHI_5_OR_LOWER} + {$ELSE} + {$IFDEF VER130} + {$DEFINE DELPHI_5_OR_LOWER} + {$ENDIF} + {$ENDIF} +{$ENDIF} + +interface + +{$IFDEF MSWINDOWS} +uses + Windows; +{$ENDIF} + +{ =============================================================================================== } +{ DEFINITIONS } +{ =============================================================================================== } + +{ + Force four-byte enums +} +{$Z4} + +{ + Disable warning for unsafe types in Delphi 7 +} +{$IFDEF VER150} +{$WARN UNSAFE_TYPE OFF} +{$ENDIF} + +{$IFDEF DELPHI_5_OR_LOWER} +type + PSingle = ^Single; + THandle = Cardinal; +{$ENDIF} + +const + FMOD_VERSION: Single = 3.75; + +{ + FMOD defined types +} + +type + PFSoundSample = Pointer; + PFSoundStream = Pointer; + PFSoundDSPUnit = Pointer; + PFMusicModule = Pointer; + PFSyncPoint = Pointer; + + PFSoundVector = ^TFSoundVector; + TFSoundVector = record + x: Single; + y: Single; + z: Single; + end; + + { + Callback types + } + + TFSoundStreamCallback = function (Stream: PFSoundStream; Buff: Pointer; Length, Param: Integer): ByteBool; stdcall; + TFSoundDSPCallback = function (OriginalBuffer: Pointer; NewBuffer: Pointer; Length, Param: Integer): Pointer; stdcall; + TFMusicCallback = procedure (Module: PFMusicModule; Param: Byte); stdcall; + + TFSoundOpenCallback = function (Name: PChar): Cardinal; stdcall; + TFSoundCloseCallback = procedure (Handle: Cardinal); stdcall; + TFSoundReadCallback = function (Buffer: Pointer; Size: Cardinal; Handle: Cardinal): Cardinal; stdcall; + TFSoundSeekCallback = procedure (Handle: Cardinal; Pos: Cardinal; Mode: Byte); stdcall; + TFSoundTellCallback = function (Handle: Cardinal): Cardinal; stdcall; + + TFSoundAllocCallback = function(Size: Cardinal): Pointer; stdcall; + TFSoundReallocCallback = function(Ptr: Pointer; Size: Cardinal): Pointer; stdcall; + TFSoundFreeCallback = procedure(Ptr: Pointer); stdcall; + + TFMetaDataCallback = function(Name: PChar; Value: PChar; userdata: Integer): ByteBool; stdcall; + +{ +[ENUM] +[ + [DESCRIPTION] + On failure of commands in FMOD, use FSOUND_GetError to attain what happened. + + [SEE_ALSO] + FSOUND_GetError +] +} + +type + TFModErrors = ( + FMOD_ERR_NONE, // No errors + FMOD_ERR_BUSY, // Cannot call this command after FSOUND_Init. Call FSOUND_Close first. + FMOD_ERR_UNINITIALIZED, // This command failed because FSOUND_Init was not called + FMOD_ERR_INIT, // Error initializing output device. + FMOD_ERR_ALLOCATED, // Error initializing output device, but more specifically, the output device is already in use and cannot be reused. + FMOD_ERR_PLAY, // Playing the sound failed. + FMOD_ERR_OUTPUT_FORMAT, // Soundcard does not support the features needed for this soundsystem (16bit stereo output) + FMOD_ERR_COOPERATIVELEVEL, // Error setting cooperative level for hardware. + FMOD_ERR_CREATEBUFFER, // Error creating hardware sound buffer. + FMOD_ERR_FILE_NOTFOUND, // File not found + FMOD_ERR_FILE_FORMAT, // Unknown file format + FMOD_ERR_FILE_BAD, // Error loading file + FMOD_ERR_MEMORY, // Not enough memory or resources + FMOD_ERR_VERSION, // The version number of this file format is not supported + FMOD_ERR_INVALID_PARAM, // An invalid parameter was passed to this function + FMOD_ERR_NO_EAX, // Tried to use an EAX command on a non EAX enabled channel or output. + FMOD_ERR_CHANNEL_ALLOC, // Failed to allocate a new channel + FMOD_ERR_RECORD, // Recording is not supported on this machine + FMOD_ERR_MEDIAPLAYER, // Windows Media Player not installed so cannot play wma or use internet streaming. */ + FMOD_ERR_CDDEVICE // An error occured trying to open the specified CD device + ); + +{ +[ENUM] +[ + [DESCRIPTION] + These output types are used with FSOUND_SetOutput, to choose which output driver to use. + + FSOUND_OUTPUT_DSOUND will not support hardware 3d acceleration if the sound card driver + does not support DirectX 6 Voice Manager Extensions. + + FSOUND_OUTPUT_WINMM is recommended for NT and CE. + + [SEE_ALSO] + FSOUND_SetOutput + FSOUND_GetOutput +] +} + +type + TFSoundOutputTypes = ( + FSOUND_OUTPUT_NOSOUND, // NoSound driver, all calls to this succeed but do nothing. + FSOUND_OUTPUT_WINMM, // Windows Multimedia driver. + FSOUND_OUTPUT_DSOUND, // DirectSound driver. You need this to get EAX2 or EAX3 support, or FX api support. + FSOUND_OUTPUT_A3D, // A3D driver. + + FSOUND_OUTPUT_OSS, // Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers. + FSOUND_OUTPUT_ESD, // Linux/Unix ESD (Enlightment Sound Daemon) driver. + FSOUND_OUTPUT_ALSA, // Linux Alsa driver. + + FSOUND_OUTPUT_ASIO, // Low latency ASIO driver. + FSOUND_OUTPUT_XBOX, // Xbox driver. + FSOUND_OUTPUT_PS2, // PlayStation 2 driver. + FSOUND_OUTPUT_MAC, // Mac SoundMager driver. + FSOUND_OUTPUT_GC, // Gamecube driver. + FSOUND_OUTPUT_PSP, // PlayStation Portable driver. + + FSOUND_OUTPUT_NOSOUND_NONREALTIME // This is the same as nosound, but the sound generation is driven by FSOUND_Update + ); + + +{ +[ENUM] +[ + [DESCRIPTION] + These mixer types are used with FSOUND_SetMixer, to choose which mixer to use, or to act + upon for other reasons using FSOUND_GetMixer. + It is not necessary to set the mixer. FMOD will autodetect the best mixer for you. + + [SEE_ALSO] + FSOUND_SetMixer + FSOUND_GetMixer +] +} +type + TFSoundMixerTypes = ( + FSOUND_MIXER_AUTODETECT, // CE/PS2/GC Only - Non interpolating/low quality mixer. + FSOUND_MIXER_BLENDMODE, // Removed / obsolete + FSOUND_MIXER_MMXP5, // Removed / obsolete + FSOUND_MIXER_MMXP6, // Removed / obsolete + + FSOUND_MIXER_QUALITY_AUTODETECT,// All platforms - Autodetect the fastest quality mixer based on your cpu. + FSOUND_MIXER_QUALITY_FPU, // Win32/Linux only - Interpolating/volume ramping FPU mixer. + FSOUND_MIXER_QUALITY_MMXP5, // Win32/Linux only - Interpolating/volume ramping P5 MMX mixer. + FSOUND_MIXER_QUALITY_MMXP6, // Win32/Linux only - Interpolating/volume ramping ppro+ MMX mixer. + + FSOUND_MIXER_MONO, // CE/PS2/GC only - MONO non interpolating/low quality mixer. For speed + FSOUND_MIXER_QUALITY_MONO, // CE/PS2/GC only - MONO Interpolating mixer. For speed + + FSOUND_MIXER_MAX + ); + + +{ +[ENUM] +[ + [DESCRIPTION] + These definitions describe the type of song being played. + + [SEE_ALSO] + FMUSIC_GetType +] +} +type + TFMusicTypes = ( + FMUSIC_TYPE_NONE, + FMUSIC_TYPE_MOD, // Protracker / FastTracker + FMUSIC_TYPE_S3M, // ScreamTracker 3 + FMUSIC_TYPE_XM, // FastTracker 2 + FMUSIC_TYPE_IT, // Impulse Tracker + FMUSIC_TYPE_MIDI, // MIDI file + FMUSIC_TYPE_FSB // FMOD Sample Bank file + ); + + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_DSP_PRIORITIES + + [DESCRIPTION] + These default priorities are used by FMOD internal system DSP units. They describe the + position of the DSP chain, and the order of how audio processing is executed. + You can actually through the use of FSOUND_DSP_GetxxxUnit (where xxx is the name of the DSP + unit), disable or even change the priority of a DSP unit. + + [SEE_ALSO] + FSOUND_DSP_Create + FSOUND_DSP_SetPriority + FSOUND_DSP_GetSpectrum +] +} +const + FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT = 0; // DSP CLEAR unit - done first + FSOUND_DSP_DEFAULTPRIORITY_SFXUNIT = 100; // DSP SFX unit - done second + FSOUND_DSP_DEFAULTPRIORITY_MUSICUNIT = 200; // DSP MUSIC unit - done third + FSOUND_DSP_DEFAULTPRIORITY_USER = 300; // User priority, use this as reference for your own DSP units + FSOUND_DSP_DEFAULTPRIORITY_FFTUNIT = 900; // This reads data for FSOUND_DSP_GetSpectrum, so it comes after user units + FSOUND_DSP_DEFAULTPRIORITY_CLIPANDCOPYUNIT = 1000; // DSP CLIP AND COPY unit - last +// [DEFINE_END] + + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_CAPS + + [DESCRIPTION] + Driver description bitfields. Use FSOUND_Driver_GetCaps to determine if a driver enumerated + has the settings you are after. The enumerated driver depends on the output mode, see + FSOUND_OUTPUTTYPES + + [SEE_ALSO] + FSOUND_GetDriverCaps + FSOUND_OUTPUTTYPES +] +} +const + FSOUND_CAPS_HARDWARE = $1; // This driver supports hardware accelerated 3d sound. + FSOUND_CAPS_EAX2 = $2; // This driver supports EAX 2 reverb + FSOUND_CAPS_EAX3 = $10; // This driver supports EAX 3 reverb +// [DEFINE_END] + + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_MODES + + [DESCRIPTION] + Sample description bitfields, OR them together for loading and describing samples. + NOTE. If the file format being loaded already has a defined format, such as WAV or MP3, then + trying to override the pre-defined format with a new set of format flags will not work. For + example, an 8 bit WAV file will not load as 16bit if you specify FSOUND_16BITS. It will just + ignore the flag and go ahead loading it as 8bits. For these type of formats the only flags + you can specify that will really alter the behaviour of how it is loaded, are the following. + + Looping behaviour - FSOUND_LOOP_OFF, FSOUND_LOOP_NORMAL, FSOUND_LOOP_BIDI + Load destination - FSOUND_HW3D, FSOUND_HW2D, FSOUND_2D + Loading behaviour - FSOUND_NONBLOCKING, FSOUND_LOADMEMORY, FSOUND_LOADRAW, FSOUND_MPEGACCURATE, FSOUND_MPEGHALFRATE, FSOUND_FORCEMONO + Playback behaviour - FSOUND_STREAMABLE, FSOUND_ENABLEFX + PlayStation 2 only - FSOUND_USECORE0, FSOUND_USECORE1, FSOUND_LOADMEMORYIOP + + See flag descriptions for what these do. +] +} +const + FSOUND_LOOP_OFF = $00000001; // For non looping samples. + FSOUND_LOOP_NORMAL = $00000002; // For forward looping samples. + FSOUND_LOOP_BIDI = $00000004; // For bidirectional looping samples. (no effect if in hardware). + FSOUND_8BITS = $00000008; // For 8 bit samples. + FSOUND_16BITS = $00000010; // For 16 bit samples. + FSOUND_MONO = $00000020; // For mono samples. + FSOUND_STEREO = $00000040; // For stereo samples. + FSOUND_UNSIGNED = $00000080; // For user created source data containing unsigned samples. + FSOUND_SIGNED = $00000100; // For user created source data containing signed data. + FSOUND_DELTA = $00000200; // For user created source data stored as delta values. + FSOUND_IT214 = $00000400; // For user created source data stored using IT214 compression. + FSOUND_IT215 = $00000800; // For user created source data stored using IT215 compression. + FSOUND_HW3D = $00001000; // Attempts to make samples use 3d hardware acceleration. (if the card supports it) + FSOUND_2D = $00002000; // Ignores any 3d processing. Overrides FSOUND_HW3D. Located in software. + FSOUND_STREAMABLE = $00004000; // For a streamimg sound where you feed the data to it. */ + FSOUND_LOADMEMORY = $00008000; // "name" will be interpreted as a pointer to data for streaming and samples. + FSOUND_LOADRAW = $00010000; // Will ignore file format and treat as raw pcm. + FSOUND_MPEGACCURATE = $00020000; // For FSOUND_Stream_OpenFile - for accurate FSOUND_Stream_GetLengthMs/FSOUND_Stream_SetTime. WARNING, see FSOUND_Stream_OpenFile for inital opening time performance issues. + FSOUND_FORCEMONO = $00040000; // For forcing stereo streams and samples to be mono - needed if using FSOUND_HW3D and stereo data - incurs a small speed hit for streams + FSOUND_HW2D = $00080000; // 2D hardware sounds. allows hardware specific effects + FSOUND_ENABLEFX = $00100000; // Allows DX8 FX to be played back on a sound. Requires DirectX 8 - Note these sounds cannot be played more than once, be 8 bit, be less than a certain size, or have a changing frequency + FSOUND_MPEGHALFRATE = $00200000; // For FMODCE only - decodes mpeg streams using a lower quality decode, but faster execution + FSOUND_XADPCM = $00400000; // For XBOX only - Contents are compressed as XADPCM */ + FSOUND_VAG = $00800000; // For PS2 only - Contents are compressed as Sony VAG format */ + FSOUND_NONBLOCKING = $01000000; // For FSOUND_Stream_OpenFile - Causes stream to open in the background and not block the foreground app - stream plays only when ready. + FSOUND_GCADPCM = $02000000; // For Gamecube only - Contents are compressed as Gamecube DSP-ADPCM format + FSOUND_MULTICHANNEL = $04000000; // For PS2 only - Contents are interleaved into a multi-channel (more than stereo) format + FSOUND_USECORE0 = $08000000; // For PS2 only - Sample/Stream is forced to use hardware voices 00-23 + FSOUND_USECORE1 = $10000000; // For PS2 only - Sample/Stream is forced to use hardware voices 24-47 + FSOUND_LOADMEMORYIOP = $20000000; // For PS2 only - "name" will be interpreted as a pointer to data for streaming and samples. The address provided will be an IOP address + +const + FSOUND_NORMAL = (FSOUND_16BITS or FSOUND_SIGNED or FSOUND_MONO); +// [DEFINE_END] + + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_CDPLAYMODES + + [DESCRIPTION] + Playback method for a CD Audio track, using FSOUND_CD_SetPlayMode + + [SEE_ALSO] + FSOUND_CD_SetPlayMode + FSOUND_CD_Play +] +} +const + FSOUND_CD_PLAYCONTINUOUS = 0; // Starts from the current track and plays to end of CD. + FSOUND_CD_PLAYONCE = 1; // Plays the specified track then stops. + FSOUND_CD_PLAYLOOPED = 2; // Plays the specified track looped, forever until stopped manually. + FSOUND_CD_PLAYRANDOM = 3; // Plays tracks in random order +// [DEFINE_END] + + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_CHANNELSAMPLEMODE + + [DESCRIPTION] + Miscellaneous values for FMOD functions. + + [SEE_ALSO] + FSOUND_PlaySound + FSOUND_PlaySoundEx + FSOUND_Sample_Alloc + FSOUND_Sample_Load + FSOUND_SetPan +] +} +const + FSOUND_FREE = -1; // value to play on any free channel, or to allocate a sample in a free sample slot. + FSOUND_UNMANAGED = -2; // value to allocate a sample that is NOT managed by FSOUND or placed in a sample slot. + FSOUND_ALL = -3; // for a channel index , this flag will affect ALL channels available! Not supported by every function. + FSOUND_STEREOPAN = -1; // value for FSOUND_SetPan so that stereo sounds are not played at half volume. See FSOUND_SetPan for more on this. + FSOUND_SYSTEMCHANNEL = -1000; // special 'channel' ID for all channel based functions that want to alter the global FSOUND software mixing output + FSOUND_SYSTEMSAMPLE = -1000; // special 'sample' ID for all sample based functions that want to alter the global FSOUND software mixing output sample +// [DEFINE_END] + + +{ +[STRUCT_START] +[ + [NAME] + FSOUND_REVERB_PROPERTIES + + [DESCRIPTION] + Structure defining a reverb environment. + + [REMARKS] + For more indepth descriptions of the reverb properties under win32, please see the EAX2/EAX3 + documentation at http://developer.creative.com/ under the 'downloads' section. + If they do not have the EAX3 documentation, then most information can be attained from + the EAX2 documentation, as EAX3 only adds some more parameters and functionality on top of + EAX2. + Note the default reverb properties are the same as the FSOUND_PRESET_GENERIC preset. + Note that integer values that typically range from -10,000 to 1000 are represented in + decibels, and are of a logarithmic scale, not linear, wheras float values are typically linear. + PORTABILITY: Each member has the platform it supports in braces ie (win32/xbox). + Some reverb parameters are only supported in win32 and some only on xbox. If all parameters are set then + the reverb should product a similar effect on either platform. + Only WIN32 supports the reverb api. + + The numerical values listed below are the maximum, minimum and default values for each variable respectively. + + [SEE_ALSO] + FSOUND_Reverb_SetProperties + FSOUND_Reverb_GetProperties + FSOUND_REVERB_PRESETS + FSOUND_REVERB_FLAGS +] +} +type + TFSoundReverbProperties = record // MIN MAX DEFAULT DESCRIPTION + Environment: Cardinal; // 0 25 0 sets all listener properties (win32 only) + EnvSize: Single; // 1.0 100.0 7.5 environment size in meters (win32 only) + EnvDiffusion: Single; // 0.0 1.0 1.0 environment diffusion (win32/xbox) + Room: Integer; // -10000 0 -1000 room effect level (at mid frequencies) (win32/xbox) + RoomHF: Integer; // -10000 0 -100 relative room effect level at high frequencies (win32/xbox) + RoomLF: Integer; // -10000 0 0 relative room effect level at low frequencies (win32 only) + DecayTime: Single; // 0.1 20.0 1.49 reverberation decay time at mid frequencies (win32/xbox) + DecayHFRatio: Single; // 0.1 2.0 0.83 high-frequency to mid-frequency decay time ratio (win32/xbox) + DecayLFRatio: Single; // 0.1 2.0 1.0 low-frequency to mid-frequency decay time ratio (win32 only) + Reflections: Integer; // -10000 1000 -2602 early reflections level relative to room effect (win32/xbox) + ReflectionsDelay: Single; // 0.0 0.3 0.007 initial reflection delay time (win32/xbox) + ReflectionsPan: array [0..2] of Single; // 0,0,0 early reflections panning vector (win32 only) + Reverb: Integer; // -10000 2000 200 late reverberation level relative to room effect (win32/xbox) + ReverbDelay: Single; // 0.0 0.1 0.011 late reverberation delay time relative to initial reflection (win32/xbox) + ReverbPan: array [0..2] of Single; // 0,0,0 late reverberation panning vector (win32 only) + EchoTime: Single; // .075 0.25 0.25 echo time (win32 only) + EchoDepth: Single; // 0.0 1.0 0.0 echo depth (win32 only) + ModulationTime: Single; // 0.04 4.0 0.25 modulation time (win32 only) + ModulationDepth: Single; // 0.0 1.0 0.0 modulation depth (win32 only) + AirAbsorptionHF: Single; // -100 0.0 -5.0 change in level per meter at high frequencies (win32 only) + HFReference: Single; // 1000.0 20000 5000.0 reference high frequency (hz) (win32/xbox) + LFReference: Single; // 20.0 1000.0 250.0 reference low frequency (hz) (win32 only) + RoomRolloffFactor: Single; // 0.0 10.0 0.0 like FSOUND_3D_SetRolloffFactor but for room effect (win32/xbox) + Diffusion: Single; // 0.0 100.0 100.0 Value that controls the echo density in the late reverberation decay. (xbox only) + Density: Single; // 0.0 100.0 100.0 Value that controls the modal density in the late reverberation decay (xbox only) + Flags: Cardinal; // FSOUND_REVERB_PROPERTYFLAGS - modifies the behavior of above properties (win32 only) + end; +// [STRUCT_END] + + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_FLAGS + + [DESCRIPTION] + Values for the Flags member of the FSOUND_REVERB_PROPERTIES structure. + + [SEE_ALSO] + FSOUND_REVERB_PROPERTIES +] +} +const + FSOUND_REVERBFLAGS_DECAYTIMESCALE = $00000001; // EnvironmentSize affects reverberation decay time + FSOUND_REVERBFLAGS_REFLECTIONSSCALE = $00000002; // EnvironmentSize affects reflection level + FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE = $00000004; // EnvironmentSize affects initial reflection delay time + FSOUND_REVERBFLAGS_REVERBSCALE = $00000008; // EnvironmentSize affects reflections level + FSOUND_REVERBFLAGS_REVERBDELAYSCALE = $00000010; // EnvironmentSize affects late reverberation delay time + FSOUND_REVERBFLAGS_DECAYHFLIMIT = $00000020; // AirAbsorptionHF affects DecayHFRatio + FSOUND_REVERBFLAGS_ECHOTIMESCALE = $00000040; // EnvironmentSize affects echo time + FSOUND_REVERBFLAGS_MODULATIONTIMESCALE = $00000080; // EnvironmentSize affects modulation time + FSOUND_REVERB_FLAGS_CORE0 = $00000100; // PS2 Only - Reverb is applied to CORE0 (hw voices 0-23) + FSOUND_REVERB_FLAGS_CORE1 = $00000200; // PS2 Only - Reverb is applied to CORE1 (hw voices 24-47) + FSOUND_REVERBFLAGS_DEFAULT = FSOUND_REVERBFLAGS_DECAYTIMESCALE or FSOUND_REVERBFLAGS_REFLECTIONSSCALE or + FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE or FSOUND_REVERBFLAGS_REVERBSCALE or + FSOUND_REVERBFLAGS_REVERBDELAYSCALE or FSOUND_REVERBFLAGS_DECAYHFLIMIT or + FSOUND_REVERB_FLAGS_CORE0 or FSOUND_REVERB_FLAGS_CORE1; +// [DEFINE_END] + + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_PRESETS + + [DESCRIPTION] + A set of predefined environment PARAMETERS, created by Creative Labs + These are used to initialize an FSOUND_REVERB_PROPERTIES structure statically. + ie + FSOUND_REVERB_PROPERTIES prop = FSOUND_PRESET_GENERIC; + + [SEE_ALSO] + FSOUND_Reverb_SetProperties +] +} +{ +const +// Env Size Diffus Room RoomHF RmLF DecTm DecHF DecLF Refl RefDel RefPan Revb RevDel ReverbPan EchoTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff Diffus Densty FLAGS + FSOUND_PRESET_OFF = 0, 7.5f, 1.00f, -10000, -10000, 0, 1.00f, 1.00f, 1.0f, -2602, 0.007f, 0.0f,0.0f,0.0f, 200, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 0.0f, 0.0f, 0x3f ; + FSOUND_PRESET_GENERIC = 0, 7.5f, 1.00f, -1000, -100, 0, 1.49f, 0.83f, 1.0f, -2602, 0.007f, 0.0f,0.0f,0.0f, 200, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_PADDEDCELL = 1, 1.4f, 1.00f, -1000, -6000, 0, 0.17f, 0.10f, 1.0f, -1204, 0.001f, 0.0f,0.0f,0.0f, 207, 0.002f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_ROOM = 2, 1.9f, 1.00f, -1000, -454, 0, 0.40f, 0.83f, 1.0f, -1646, 0.002f, 0.0f,0.0f,0.0f, 53, 0.003f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_BATHROOM = 3, 1.4f, 1.00f, -1000, -1200, 0, 1.49f, 0.54f, 1.0f, -370, 0.007f, 0.0f,0.0f,0.0f, 1030, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 60.0f, 0x3f ; + FSOUND_PRESET_LIVINGROOM = 4, 2.5f, 1.00f, -1000, -6000, 0, 0.50f, 0.10f, 1.0f, -1376, 0.003f, 0.0f,0.0f,0.0f, -1104, 0.004f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_STONEROOM = 5, 11.6f, 1.00f, -1000, -300, 0, 2.31f, 0.64f, 1.0f, -711, 0.012f, 0.0f,0.0f,0.0f, 83, 0.017f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_AUDITORIUM = 6, 21.6f, 1.00f, -1000, -476, 0, 4.32f, 0.59f, 1.0f, -789, 0.020f, 0.0f,0.0f,0.0f, -289, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_CONCERTHALL = 7, 19.6f, 1.00f, -1000, -500, 0, 3.92f, 0.70f, 1.0f, -1230, 0.020f, 0.0f,0.0f,0.0f, -2, 0.029f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_CAVE = 8, 14.6f, 1.00f, -1000, 0, 0, 2.91f, 1.30f, 1.0f, -602, 0.015f, 0.0f,0.0f,0.0f, -302, 0.022f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f ; + FSOUND_PRESET_ARENA = 9, 36.2f, 1.00f, -1000, -698, 0, 7.24f, 0.33f, 1.0f, -1166, 0.020f, 0.0f,0.0f,0.0f, 16, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_HANGAR = 10, 50.3f, 1.00f, -1000, -1000, 0, 10.05f, 0.23f, 1.0f, -602, 0.020f, 0.0f,0.0f,0.0f, 198, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_CARPETTEDHALLWAY = 11, 1.9f, 1.00f, -1000, -4000, 0, 0.30f, 0.10f, 1.0f, -1831, 0.002f, 0.0f,0.0f,0.0f, -1630, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_HALLWAY = 12, 1.8f, 1.00f, -1000, -300, 0, 1.49f, 0.59f, 1.0f, -1219, 0.007f, 0.0f,0.0f,0.0f, 441, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_STONECORRIDOR = 13, 13.5f, 1.00f, -1000, -237, 0, 2.70f, 0.79f, 1.0f, -1214, 0.013f, 0.0f,0.0f,0.0f, 395, 0.020f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_ALLEY = 14, 7.5f, 0.30f, -1000, -270, 0, 1.49f, 0.86f, 1.0f, -1204, 0.007f, 0.0f,0.0f,0.0f, -4, 0.011f, 0.0f,0.0f,0.0f, 0.125f, 0.95f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_FOREST = 15, 38.0f, 0.30f, -1000, -3300, 0, 1.49f, 0.54f, 1.0f, -2560, 0.162f, 0.0f,0.0f,0.0f, -229, 0.088f, 0.0f,0.0f,0.0f, 0.125f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 79.0f, 100.0f, 0x3f ; + FSOUND_PRESET_CITY = 16, 7.5f, 0.50f, -1000, -800, 0, 1.49f, 0.67f, 1.0f, -2273, 0.007f, 0.0f,0.0f,0.0f, -1691, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 50.0f, 100.0f, 0x3f ; + FSOUND_PRESET_MOUNTAINS = 17, 100.0f, 0.27f, -1000, -2500, 0, 1.49f, 0.21f, 1.0f, -2780, 0.300f, 0.0f,0.0f,0.0f, -1434, 0.100f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 27.0f, 100.0f, 0x1f ; + FSOUND_PRESET_QUARRY = 18, 17.5f, 1.00f, -1000, -1000, 0, 1.49f, 0.83f, 1.0f, -10000, 0.061f, 0.0f,0.0f,0.0f, 500, 0.025f, 0.0f,0.0f,0.0f, 0.125f, 0.70f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + FSOUND_PRESET_PLAIN = 19, 42.5f, 0.21f, -1000, -2000, 0, 1.49f, 0.50f, 1.0f, -2466, 0.179f, 0.0f,0.0f,0.0f, -1926, 0.100f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 21.0f, 100.0f, 0x3f ; + FSOUND_PRESET_PARKINGLOT = 20, 8.3f, 1.00f, -1000, 0, 0, 1.65f, 1.50f, 1.0f, -1363, 0.008f, 0.0f,0.0f,0.0f, -1153, 0.012f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f ; + FSOUND_PRESET_SEWERPIPE = 21, 1.7f, 0.80f, -1000, -1000, 0, 2.81f, 0.14f, 1.0f, 429, 0.014f, 0.0f,0.0f,0.0f, 1023, 0.021f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 80.0f, 60.0f, 0x3f ; + FSOUND_PRESET_UNDERWATER = 22, 1.8f, 1.00f, -1000, -4000, 0, 1.49f, 0.10f, 1.0f, -449, 0.007f, 0.0f,0.0f,0.0f, 1700, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 1.18f, 0.348f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f ; + +// Non I3DL2 presets + + FSOUND_PRESET_DRUGGED = 23, 1.9f, 0.50f, -1000, 0, 0, 8.39f, 1.39f, 1.0f, -115, 0.002f, 0.0f,0.0f,0.0f, 985, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f ; + FSOUND_PRESET_DIZZY = 24, 1.8f, 0.60f, -1000, -400, 0, 17.23f, 0.56f, 1.0f, -1713, 0.020f, 0.0f,0.0f,0.0f, -613, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.81f, 0.310f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f ; + FSOUND_PRESET_PSYCHOTIC = 25, 1.0f, 0.50f, -1000, -151, 0, 7.56f, 0.91f, 1.0f, -626, 0.020f, 0.0f,0.0f,0.0f, 774, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 4.00f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f ; +} +// [DEFINE_END] + + +{ +[STRUCTURE] +[ + [DESCRIPTION] + Structure defining the properties for a reverb source, related to a FSOUND channel. + For more indepth descriptions of the reverb properties under win32, please see the EAX3 + documentation at http://developer.creative.com/ under the 'downloads' section. + If they do not have the EAX3 documentation, then most information can be attained from + the EAX2 documentation, as EAX3 only adds some more parameters and functionality on top of + EAX2. + + Note the default reverb properties are the same as the FSOUND_PRESET_GENERIC preset. + Note that integer values that typically range from -10,000 to 1000 are represented in + decibels, and are of a logarithmic scale, not linear, wheras float values are typically linear. + PORTABILITY: Each member has the platform it supports in braces ie (win32/xbox). + Some reverb parameters are only supported in win32 and some only on xbox. If all parameters are set then + the reverb should product a similar effect on either platform. + Linux and FMODCE do not support the reverb api. + + The numerical values listed below are the maximum, minimum and default values for each variable respectively. + + [SEE_ALSO] + FSOUND_Reverb_SetChannelProperties + FSOUND_Reverb_GetChannelProperties + FSOUND_REVERB_CHANNELFLAGS +] +} +type + TFSoundReverbChannelProperties = record // MIN MAX DEFAULT + Direct: Integer; // -10000 1000 0 direct path level (at low and mid frequencies) (win32/xbox) + DirectHF: Integer; // -10000 0 0 relative direct path level at high frequencies (win32/xbox) + Room: Integer; // -10000 1000 0 room effect level (at low and mid frequencies) (win32/xbox) + RoomHF: Integer; // -10000 0 0 relative room effect level at high frequencies (win32/xbox) + Obstruction: Integer; // -10000 0 0 main obstruction control (attenuation at high frequencies) (win32/xbox) + ObstructionLFRatio: Single; // 0.0 1.0 0.0 obstruction low-frequency level re. main control (win32/xbox) + Occlusion: Integer; // -10000 0 0 main occlusion control (attenuation at high frequencies) (win32/xbox) + OcclusionLFRatio: Single; // 0.0 1.0 0.25 occlusion low-frequency level re. main control (win32/xbox) + OcclusionRoomRatio: Single; // 0.0 10.0 1.5 relative occlusion control for room effect (win32) + OcclusionDirectRatio: Single; // 0.0 10.0 1.0 relative occlusion control for direct path (win32) + Exclusion: Integer; // -10000 0 0 main exlusion control (attenuation at high frequencies) (win32) + ExclusionLFRatio: Single; // 0.0 1.0 1.0 exclusion low-frequency level re. main control (win32) + OutsideVolumeHF: Integer; // -10000 0 0 outside sound cone level at high frequencies (win32) + DopplerFactor: Single; // 0.0 10.0 0.0 like DS3D flDopplerFactor but per source (win32) + RolloffFactor: Single; // 0.0 10.0 0.0 like DS3D flRolloffFactor but per source (win32) + RoomRolloffFactor: Single; // 0.0 10.0 0.0 like DS3D flRolloffFactor but for room effect (win32/xbox) + AirAbsorptionFactor: Single; // 0.0 10.0 1.0 multiplies AirAbsorptionHF member of FSOUND_REVERB_PROPERTIES (win32) + Flags: Integer; // FSOUND_REVERB_CHANNELFLAGS - modifies the behavior of properties (win32) + end; +// [STRUCT_END] + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_CHANNELFLAGS + + [DESCRIPTION] + Values for the Flags member of the FSOUND_REVERB_CHANNELPROPERTIES structure. + + [SEE_ALSO] + FSOUND_REVERB_CHANNELPROPERTIES +] +} +const + FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO = $01; // Automatic setting of 'Direct' due to distance from listener + FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO = $02; // Automatic setting of 'Room' due to distance from listener + FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO = $04; // Automatic setting of 'RoomHF' due to distance from listener + FSOUND_REVERB_CHANNELFLAGS_DEFAULT = FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO or + FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO or + FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO; +// [DEFINE_END] + + +{ +[ENUM] +[ + [DESCRIPTION] + These values are used with FSOUND_FX_Enable to enable DirectX 8 FX for a channel. + + [SEE_ALSO] + FSOUND_FX_Enable + FSOUND_FX_Disable + FSOUND_FX_SetChorus + FSOUND_FX_SetCompressor + FSOUND_FX_SetDistortion + FSOUND_FX_SetEcho + FSOUND_FX_SetFlanger + FSOUND_FX_SetGargle + FSOUND_FX_SetI3DL2Reverb + FSOUND_FX_SetParamEQ + FSOUND_FX_SetWavesReverb +] +} + +type + TFSoundFXModes = ( + FSOUND_FX_CHORUS, + FSOUND_FX_COMPRESSOR, + FSOUND_FX_DISTORTION, + FSOUND_FX_ECHO, + FSOUND_FX_FLANGER, + FSOUND_FX_GARGLE, + FSOUND_FX_I3DL2REVERB, + FSOUND_FX_PARAMEQ, + FSOUND_FX_WAVES_REVERB, + FSOUND_FX_MAX + ); +// [DEFINE_END] + + +{ +[ENUM] +[ + [DESCRIPTION] + These are speaker types defined for use with the FSOUND_SetSpeakerMode command. + Note - Only reliably works with FSOUND_OUTPUT_DSOUND or FSOUND_OUTPUT_XBOX output modes. Other output modes will only + interpret FSOUND_SPEAKERMODE_MONO and set everything else to be stereo. + + [SEE_ALSO] + FSOUND_SetSpeakerMode + + [REMARKS] + Note - Only reliably works with FSOUND_OUTPUT_DSOUND or FSOUND_OUTPUT_XBOX output modes. Other output modes will only + interpret FSOUND_SPEAKERMODE_MONO and set everything else to be stereo. + + Using either DolbyDigital or DTS will use whatever 5.1 digital mode is available if destination hardware is unsure. +] +} +type + TFSoundSpeakerModes = + ( + FSOUND_SPEAKERMODE_DOLBYDIGITAL, // The audio is played through a speaker arrangement of surround speakers with a subwoofer. + FSOUND_SPEAKERMODE_HEADPHONES, // The speakers are headphones. + FSOUND_SPEAKERMODE_MONO, // The speakers are monaural. + FSOUND_SPEAKERMODE_QUAD, // The speakers are quadraphonic. + FSOUND_SPEAKERMODE_STEREO, // The speakers are stereo (default value). + FSOUND_SPEAKERMODE_SURROUND, // The speakers are surround sound. + FSOUND_SPEAKERMODE_DTS // The audio is played through a speaker arrangement of surround speakers with a subwoofer. + ); + FSOUND_SPEAKERMODES = TFSoundSpeakerModes; + + +{ +[DEFINE_START] +[ + [NAME] + FSOUND_INIT_FLAGS + + [DESCRIPTION] + Initialization flags. Use them with FSOUND_Init in the flags parameter to change various behaviour. + + FSOUND_INIT_ENABLESYSTEMCHANNELFX Is an init mode which enables the FSOUND mixer buffer to be affected by DirectX 8 effects. + Note that due to limitations of DirectSound, FSOUND_Init may fail if this is enabled because the buffersize is too small. + This can be fixed with FSOUND_SetBufferSize. Increase the BufferSize until it works. + When it is enabled you can use the FSOUND_FX api, and use FSOUND_SYSTEMCHANNEL as the channel id when setting parameters. + + [SEE_ALSO] + FSOUND_Init +] +} +const + FSOUND_INIT_USEDEFAULTMIDISYNTH = $01; // Causes MIDI playback to force software decoding. + FSOUND_INIT_GLOBALFOCUS = $02; // For DirectSound output - sound is not muted when window is out of focus. + FSOUND_INIT_ENABLESYSTEMCHANNELFX = $04; // For DirectSound output - Allows FSOUND_FX api to be used on global software mixer output! + FSOUND_INIT_ACCURATEVULEVELS = $08; // This latency adjusts FSOUND_GetCurrentLevels, but incurs a small cpu and memory hit. + FSOUND_INIT_PS2_DISABLECORE0REVERB = $10; // PS2 only - Disable reverb on CORE 0 to regain SRAM. + FSOUND_INIT_PS2_DISABLECORE1REVERB = $20; // PS2 only - Disable reverb on CORE 1 to regain SRAM. + FSOUND_INIT_PS2_SWAPDMACORES = $40; // PS2 only - By default FMOD uses DMA CH0 for mixing, CH1 for uploads, this flag swaps them around. + FSOUND_INIT_DONTLATENCYADJUST = $80; // Callbacks are not latency adjusted, and are called at mix time. Also information functions are immediate. + FSOUND_INIT_GC_INITLIBS = $100; // Gamecube only - Initializes GC audio libraries. + FSOUND_INIT_STREAM_FROM_MAIN_THREAD = $200; // Turns off fmod streamer thread, and makes streaming update from FSOUND_Update called by the user. + FSOUND_INIT_PS2_USEVOLUMERAMPING = $400; // PS2 only - Turns on volume ramping system to remove hardware clicks. + FSOUND_INIT_DSOUND_DEFERRED = $800; // Win32 only - For DirectSound output. 3D commands are batched together and executed at FSOUND_Update. + FSOUND_INIT_DSOUND_HRTF_LIGHT = $1000; // Win32 only - For DirectSound output. FSOUND_HW3D buffers use a slightly higher quality algorithm when 3d hardware acceleration is not present. + FSOUND_INIT_DSOUND_HRTF_FULL = $2000; // Win32 only - For DirectSound output. FSOUND_HW3D buffers use full quality 3d playback when 3d hardware acceleration is not present. + FSOUND_INIT_XBOX_REMOVEHEADROOM = $4000; // XBox only - By default directsound attenuates all sound by 6db to avoid clipping/distortion. CAUTION. If you use this flag you are responsible for the final mix to make sure clipping / distortion doesn't happen. + FSOUND_INIT_PSP_SILENCEONUNDERRUN = $8000; // PSP only - If streams skip / stutter when device is powered on, either increase stream buffersize, or use this flag instead to play silence while the UMD is recovering. + +// [DEFINE_END] + +(* +[ENUM] +[ + [DESCRIPTION] + Status values for internet streams. Use FSOUND_Stream_Net_GetStatus to get the current status of an internet stream. + + [SEE_ALSO] + FSOUND_Stream_Net_GetStatus +] +*) +type + TFSoundStreamNetStatus = + ( + FSOUND_STREAM_NET_NOTCONNECTED, (* Stream hasn't connected yet *) + FSOUND_STREAM_NET_CONNECTING, (* Stream is connecting to remote host *) + FSOUND_STREAM_NET_BUFFERING, (* Stream is buffering data *) + FSOUND_STREAM_NET_READY, (* Stream is ready to play *) + FSOUND_STREAM_NET_ERROR (* Stream has suffered a fatal error *) + ); + + +(* +[ENUM] +[ + [DESCRIPTION] + Describes the type of a particular tag field. + + [SEE_ALSO] + FSOUND_Stream_GetNumTagFields + FSOUND_Stream_GetTagField + FSOUND_Stream_FindTagField +] +*) +type + TFSoundTagFieldType = + ( + FSOUND_TAGFIELD_VORBISCOMMENT, (* A vorbis comment *) + FSOUND_TAGFIELD_ID3V1, (* Part of an ID3v1 tag *) + FSOUND_TAGFIELD_ID3V2, (* An ID3v2 frame *) + FSOUND_TAGFIELD_SHOUTCAST, (* A SHOUTcast header line *) + FSOUND_TAGFIELD_ICECAST, (* An Icecast header line *) + FSOUND_TAGFIELD_ASF (* An Advanced Streaming Format header line *) + ); + + +(* +[DEFINE_START] +[ + [NAME] + FSOUND_STATUS_FLAGS + + [DESCRIPTION] + These values describe the protocol and format of an internet stream. Use FSOUND_Stream_Net_GetStatus to retrieve this information for an open internet stream. + + [SEE_ALSO] + FSOUND_Stream_Net_GetStatus +] +*) +const + FSOUND_PROTOCOL_SHOUTCAST = $00000001; + FSOUND_PROTOCOL_ICECAST = $00000002; + FSOUND_PROTOCOL_HTTP = $00000004; + FSOUND_FORMAT_MPEG = $00010000; + FSOUND_FORMAT_OGGVORBIS = $00020000; +(* [DEFINE_END] *) + +{ +[STRUCTURE] +[ + [DESCRIPTION] + Structure defining a CD table of contents. This structure is returned as a tag from FSOUND_Stream_FindTagField when the tag name "CD_TOC" is specified. + Note: All tracks on the CD - including data tracks- will be represented in this structure so it's use for anything other than generating disc id information is not recommended. + See the cdda example program for info on retrieving and using this structure. + + [SEE_ALSO] + FSOUND_Stream_Open + FSOUND_Stream_FindTagField +] +} +type + TFSoundTOCTag = record + Name: array [0..3] of Char; // The string "TOC" (4th character is 0), just in case this structure is accidentally treated as a string. + NumTracks: Integer; // The number of tracks on the CD. + Min: array [0..99] of Integer; // The start offset of each track in minutes. + Sec: array [0..99] of Integer; // The start offset of each track in seconds. + Frame: array [0..99] of Integer; // The start offset of each track in frames. + end; +// [STRUCT_END] + +implementation + +end. diff --git a/lib/fmodapi375win/api/fmod.dll b/lib/fmodapi375win/api/fmod.dll new file mode 100644 index 0000000..6b0e379 Binary files /dev/null and b/lib/fmodapi375win/api/fmod.dll differ diff --git a/lib/fmodapi375win/api/fmod64.dll b/lib/fmodapi375win/api/fmod64.dll new file mode 100644 index 0000000..2a8bab2 Binary files /dev/null and b/lib/fmodapi375win/api/fmod64.dll differ diff --git a/lib/fmodapi375win/api/inc/fmod.h b/lib/fmodapi375win/api/inc/fmod.h new file mode 100644 index 0000000..54d3562 --- /dev/null +++ b/lib/fmodapi375win/api/inc/fmod.h @@ -0,0 +1,1224 @@ +/* ========================================================================================== */ +/* FMOD Main header file. Copyright (c), Firelight Technologies Pty, Ltd. 1999-2004. */ +/* ========================================================================================== */ + +#ifndef _FMOD_H_ +#define _FMOD_H_ + +/* ========================================================================================== */ +/* DEFINITIONS */ +/* ========================================================================================== */ + +#if (!defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(_WIN64) && !defined(_WIN32_WCE) && !defined(_XBOX)) || (defined(__GNUC__) && defined(WIN32)) + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __stdcall + #define __stdcall + #endif +#endif + +#if defined(_WIN32_WCE) + #define F_API _cdecl + #define F_CALLBACKAPI _cdecl +#else + #define F_API __stdcall + #define F_CALLBACKAPI __stdcall +#endif + +#ifdef DLL_EXPORTS + #define DLL_API __declspec(dllexport) +#else + #if defined(__LCC__) || defined(__MINGW32__) || defined(__CYGWIN32__) + #define DLL_API F_API + #else + #define DLL_API + #endif /* __LCC__ || __MINGW32__ || __CYGWIN32__ */ +#endif /* DLL_EXPORTS */ + +#define FMOD_VERSION 3.75f + +/* + FMOD defined types +*/ +typedef struct FSOUND_SAMPLE FSOUND_SAMPLE; +typedef struct FSOUND_STREAM FSOUND_STREAM; +typedef struct FSOUND_DSPUNIT FSOUND_DSPUNIT; +typedef struct FSOUND_SYNCPOINT FSOUND_SYNCPOINT; +typedef struct FMUSIC_MODULE FMUSIC_MODULE; + +/* + Callback types +*/ +typedef void * (F_CALLBACKAPI *FSOUND_OPENCALLBACK) (const char *name); +typedef void (F_CALLBACKAPI *FSOUND_CLOSECALLBACK) (void *handle); +typedef int (F_CALLBACKAPI *FSOUND_READCALLBACK) (void *buffer, int size, void *handle); +typedef int (F_CALLBACKAPI *FSOUND_SEEKCALLBACK) (void *handle, int pos, signed char mode); +typedef int (F_CALLBACKAPI *FSOUND_TELLCALLBACK) (void *handle); + +typedef void * (F_CALLBACKAPI *FSOUND_ALLOCCALLBACK) (unsigned int size); +typedef void * (F_CALLBACKAPI *FSOUND_REALLOCCALLBACK) (void *ptr, unsigned int size); +typedef void (F_CALLBACKAPI *FSOUND_FREECALLBACK) (void *ptr); + +typedef void * (F_CALLBACKAPI *FSOUND_DSPCALLBACK) (void *originalbuffer, void *newbuffer, int length, void *userdata); +typedef signed char (F_CALLBACKAPI *FSOUND_STREAMCALLBACK) (FSOUND_STREAM *stream, void *buff, int len, void *userdata); +typedef signed char (F_CALLBACKAPI *FSOUND_METADATACALLBACK)(char *name, char *value, void *userdata); +typedef void (F_CALLBACKAPI *FMUSIC_CALLBACK) (FMUSIC_MODULE *mod, unsigned char param); + + +/* +[ENUM] +[ + [DESCRIPTION] + On failure of commands in FMOD, use FSOUND_GetError to attain what happened. + + [SEE_ALSO] + FSOUND_GetError +] +*/ +enum FMOD_ERRORS +{ + FMOD_ERR_NONE, /* No errors */ + FMOD_ERR_BUSY, /* Cannot call this command after FSOUND_Init. Call FSOUND_Close first. */ + FMOD_ERR_UNINITIALIZED, /* This command failed because FSOUND_Init or FSOUND_SetOutput was not called */ + FMOD_ERR_INIT, /* Error initializing output device. */ + FMOD_ERR_ALLOCATED, /* Error initializing output device, but more specifically, the output device is already in use and cannot be reused. */ + FMOD_ERR_PLAY, /* Playing the sound failed. */ + FMOD_ERR_OUTPUT_FORMAT, /* Soundcard does not support the features needed for this soundsystem (16bit stereo output) */ + FMOD_ERR_COOPERATIVELEVEL, /* Error setting cooperative level for hardware. */ + FMOD_ERR_CREATEBUFFER, /* Error creating hardware sound buffer. */ + FMOD_ERR_FILE_NOTFOUND, /* File not found */ + FMOD_ERR_FILE_FORMAT, /* Unknown file format */ + FMOD_ERR_FILE_BAD, /* Error loading file */ + FMOD_ERR_MEMORY, /* Not enough memory or resources */ + FMOD_ERR_VERSION, /* The version number of this file format is not supported */ + FMOD_ERR_INVALID_PARAM, /* An invalid parameter was passed to this function */ + FMOD_ERR_NO_EAX, /* Tried to use an EAX command on a non EAX enabled channel or output. */ + FMOD_ERR_CHANNEL_ALLOC, /* Failed to allocate a new channel */ + FMOD_ERR_RECORD, /* Recording is not supported on this machine */ + FMOD_ERR_MEDIAPLAYER, /* Windows Media Player not installed so cannot play wma or use internet streaming. */ + FMOD_ERR_CDDEVICE /* An error occured trying to open the specified CD device */ +}; + + +/* +[ENUM] +[ + [DESCRIPTION] + These output types are used with FSOUND_SetOutput, to choose which output driver to use. + + FSOUND_OUTPUT_DSOUND will not support hardware 3d acceleration if the sound card driver + does not support DirectX 6 Voice Manager Extensions. + + FSOUND_OUTPUT_WINMM is recommended for NT and CE. + + [SEE_ALSO] + FSOUND_SetOutput + FSOUND_GetOutput +] +*/ +enum FSOUND_OUTPUTTYPES +{ + FSOUND_OUTPUT_NOSOUND, /* NoSound driver, all calls to this succeed but do nothing. */ + FSOUND_OUTPUT_WINMM, /* Windows Multimedia driver. */ + FSOUND_OUTPUT_DSOUND, /* DirectSound driver. You need this to get EAX2 or EAX3 support, or FX api support. */ + FSOUND_OUTPUT_A3D, /* A3D driver. */ + + FSOUND_OUTPUT_OSS, /* Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers. */ + FSOUND_OUTPUT_ESD, /* Linux/Unix ESD (Enlightment Sound Daemon) driver. */ + FSOUND_OUTPUT_ALSA, /* Linux Alsa driver. */ + + FSOUND_OUTPUT_ASIO, /* Low latency ASIO driver */ + FSOUND_OUTPUT_XBOX, /* Xbox driver */ + FSOUND_OUTPUT_PS2, /* PlayStation 2 driver */ + FSOUND_OUTPUT_MAC, /* Mac SoundManager driver */ + FSOUND_OUTPUT_GC, /* Gamecube driver */ + FSOUND_OUTPUT_PSP, /* PlayStation Portable driver */ + + FSOUND_OUTPUT_NOSOUND_NONREALTIME /* This is the same as nosound, but the sound generation is driven by FSOUND_Update */ +}; + + +/* +[ENUM] +[ + [DESCRIPTION] + These mixer types are used with FSOUND_SetMixer, to choose which mixer to use, or to act + upon for other reasons using FSOUND_GetMixer. + It is not nescessary to set the mixer. FMOD will autodetect the best mixer for you. + + [SEE_ALSO] + FSOUND_SetMixer + FSOUND_GetMixer +] +*/ +enum FSOUND_MIXERTYPES +{ + FSOUND_MIXER_AUTODETECT, /* CE/PS2/GC Only - Non interpolating/low quality mixer. */ + FSOUND_MIXER_BLENDMODE, /* Removed / obsolete. */ + FSOUND_MIXER_MMXP5, /* Removed / obsolete. */ + FSOUND_MIXER_MMXP6, /* Removed / obsolete. */ + + FSOUND_MIXER_QUALITY_AUTODETECT,/* All platforms - Autodetect the fastest quality mixer based on your cpu. */ + FSOUND_MIXER_QUALITY_FPU, /* Win32/Linux only - Interpolating/volume ramping FPU mixer. */ + FSOUND_MIXER_QUALITY_MMXP5, /* Win32/Linux only - Interpolating/volume ramping P5 MMX mixer. */ + FSOUND_MIXER_QUALITY_MMXP6, /* Win32/Linux only - Interpolating/volume ramping ppro+ MMX mixer. */ + + FSOUND_MIXER_MONO, /* CE/PS2/GC only - MONO non interpolating/low quality mixer. For speed*/ + FSOUND_MIXER_QUALITY_MONO, /* CE/PS2/GC only - MONO Interpolating mixer. For speed */ + + FSOUND_MIXER_MAX +}; + + +/* +[ENUM] +[ + [DESCRIPTION] + These definitions describe the type of song being played. + + [SEE_ALSO] + FMUSIC_GetType +] +*/ +enum FMUSIC_TYPES +{ + FMUSIC_TYPE_NONE, + FMUSIC_TYPE_MOD, /* Protracker / Fasttracker */ + FMUSIC_TYPE_S3M, /* ScreamTracker 3 */ + FMUSIC_TYPE_XM, /* FastTracker 2 */ + FMUSIC_TYPE_IT, /* Impulse Tracker. */ + FMUSIC_TYPE_MIDI, /* MIDI file */ + FMUSIC_TYPE_FSB /* FMOD Sample Bank file */ +}; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_DSP_PRIORITIES + + [DESCRIPTION] + These default priorities are used by FMOD internal system DSP units. They describe the + position of the DSP chain, and the order of how audio processing is executed. + You can actually through the use of FSOUND_DSP_GetxxxUnit (where xxx is the name of the DSP + unit), disable or even change the priority of a DSP unit. + + [SEE_ALSO] + FSOUND_DSP_Create + FSOUND_DSP_SetPriority + FSOUND_DSP_GetSpectrum +] +*/ +#define FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT 0 /* DSP CLEAR unit - done first */ +#define FSOUND_DSP_DEFAULTPRIORITY_SFXUNIT 100 /* DSP SFX unit - done second */ +#define FSOUND_DSP_DEFAULTPRIORITY_MUSICUNIT 200 /* DSP MUSIC unit - done third */ +#define FSOUND_DSP_DEFAULTPRIORITY_USER 300 /* User priority, use this as reference for your own DSP units */ +#define FSOUND_DSP_DEFAULTPRIORITY_FFTUNIT 900 /* This reads data for FSOUND_DSP_GetSpectrum, so it comes after user units */ +#define FSOUND_DSP_DEFAULTPRIORITY_CLIPANDCOPYUNIT 1000 /* DSP CLIP AND COPY unit - last */ +/* [DEFINE_END] */ + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_CAPS + + [DESCRIPTION] + Driver description bitfields. Use FSOUND_Driver_GetCaps to determine if a driver enumerated + has the settings you are after. The enumerated driver depends on the output mode, see + FSOUND_OUTPUTTYPES + + [SEE_ALSO] + FSOUND_GetDriverCaps + FSOUND_OUTPUTTYPES +] +*/ +#define FSOUND_CAPS_HARDWARE 0x1 /* This driver supports hardware accelerated 3d sound. */ +#define FSOUND_CAPS_EAX2 0x2 /* This driver supports EAX 2 reverb */ +#define FSOUND_CAPS_EAX3 0x10 /* This driver supports EAX 3 reverb */ +/* [DEFINE_END] */ + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_MODES + + [DESCRIPTION] + Sample description bitfields, OR them together for loading and describing samples. + NOTE. If the file format being loaded already has a defined format, such as WAV or MP3, then + trying to override the pre-defined format with a new set of format flags will not work. For + example, an 8 bit WAV file will not load as 16bit if you specify FSOUND_16BITS. It will just + ignore the flag and go ahead loading it as 8bits. For these type of formats the only flags + you can specify that will really alter the behaviour of how it is loaded, are the following. + --------- + Looping behaviour - FSOUND_LOOP_OFF, FSOUND_LOOP_NORMAL, FSOUND_LOOP_BIDI + Load destination - FSOUND_HW3D, FSOUND_HW2D, FSOUND_2D + Loading behaviour - FSOUND_NONBLOCKING, FSOUND_LOADMEMORY, FSOUND_LOADRAW, FSOUND_MPEGACCURATE, FSOUND_MPEGHALFRATE, FSOUND_FORCEMONO + Playback behaviour - FSOUND_STREAMABLE, FSOUND_ENABLEFX + PlayStation 2 only - FSOUND_USECORE0, FSOUND_USECORE1, FSOUND_LOADMEMORYIOP + --------- + See flag descriptions for what these do. +] +*/ +#define FSOUND_LOOP_OFF 0x00000001 /* For non looping samples. */ +#define FSOUND_LOOP_NORMAL 0x00000002 /* For forward looping samples. */ +#define FSOUND_LOOP_BIDI 0x00000004 /* For bidirectional looping samples. (no effect if in hardware). */ +#define FSOUND_8BITS 0x00000008 /* For 8 bit samples. */ +#define FSOUND_16BITS 0x00000010 /* For 16 bit samples. */ +#define FSOUND_MONO 0x00000020 /* For mono samples. */ +#define FSOUND_STEREO 0x00000040 /* For stereo samples. */ +#define FSOUND_UNSIGNED 0x00000080 /* For user created source data containing unsigned samples. */ +#define FSOUND_SIGNED 0x00000100 /* For user created source data containing signed data. */ +#define FSOUND_DELTA 0x00000200 /* For user created source data stored as delta values. */ +#define FSOUND_IT214 0x00000400 /* For user created source data stored using IT214 compression. */ +#define FSOUND_IT215 0x00000800 /* For user created source data stored using IT215 compression. */ +#define FSOUND_HW3D 0x00001000 /* Attempts to make samples use 3d hardware acceleration. (if the card supports it) */ +#define FSOUND_2D 0x00002000 /* Tells software (not hardware) based sample not to be included in 3d processing. */ +#define FSOUND_STREAMABLE 0x00004000 /* For a streamimg sound where you feed the data to it. */ +#define FSOUND_LOADMEMORY 0x00008000 /* "name" will be interpreted as a pointer to data for streaming and samples. */ +#define FSOUND_LOADRAW 0x00010000 /* Will ignore file format and treat as raw pcm. */ +#define FSOUND_MPEGACCURATE 0x00020000 /* For FSOUND_Stream_Open - for accurate FSOUND_Stream_GetLengthMs/FSOUND_Stream_SetTime. WARNING, see FSOUND_Stream_Open for inital opening time performance issues. */ +#define FSOUND_FORCEMONO 0x00040000 /* For forcing stereo streams and samples to be mono - needed if using FSOUND_HW3D and stereo data - incurs a small speed hit for streams */ +#define FSOUND_HW2D 0x00080000 /* 2D hardware sounds. allows hardware specific effects */ +#define FSOUND_ENABLEFX 0x00100000 /* Allows DX8 FX to be played back on a sound. Requires DirectX 8 - Note these sounds cannot be played more than once, be 8 bit, be less than a certain size, or have a changing frequency */ +#define FSOUND_MPEGHALFRATE 0x00200000 /* For FMODCE only - decodes mpeg streams using a lower quality decode, but faster execution */ +#define FSOUND_IMAADPCM 0x00400000 /* Contents are stored compressed as IMA ADPCM */ +#define FSOUND_VAG 0x00800000 /* For PS2 only - Contents are compressed as Sony VAG format */ +#define FSOUND_NONBLOCKING 0x01000000 /* For FSOUND_Stream_Open/FMUSIC_LoadSong - Causes stream or music to open in the background and not block the foreground app. See FSOUND_Stream_GetOpenState or FMUSIC_GetOpenState to determine when it IS ready. */ +#define FSOUND_GCADPCM 0x02000000 /* For Gamecube only - Contents are compressed as Gamecube DSP-ADPCM format */ +#define FSOUND_MULTICHANNEL 0x04000000 /* For PS2 and Gamecube only - Contents are interleaved into a multi-channel (more than stereo) format */ +#define FSOUND_USECORE0 0x08000000 /* For PS2 only - Sample/Stream is forced to use hardware voices 00-23 */ +#define FSOUND_USECORE1 0x10000000 /* For PS2 only - Sample/Stream is forced to use hardware voices 24-47 */ +#define FSOUND_LOADMEMORYIOP 0x20000000 /* For PS2 only - "name" will be interpreted as a pointer to data for streaming and samples. The address provided will be an IOP address */ +#define FSOUND_IGNORETAGS 0x40000000 /* Skips id3v2 etc tag checks when opening a stream, to reduce seek/read overhead when opening files (helps with CD performance) */ +#define FSOUND_STREAM_NET 0x80000000 /* Specifies an internet stream */ + +#define FSOUND_NORMAL (FSOUND_16BITS | FSOUND_SIGNED | FSOUND_MONO) +/* [DEFINE_END] */ + + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_CDPLAYMODES + + [DESCRIPTION] + Playback method for a CD Audio track, with FSOUND_CD_SetPlayMode + + [SEE_ALSO] + FSOUND_CD_SetPlayMode + FSOUND_CD_Play +] +*/ +#define FSOUND_CD_PLAYCONTINUOUS 0 /* Starts from the current track and plays to end of CD. */ +#define FSOUND_CD_PLAYONCE 1 /* Plays the specified track then stops. */ +#define FSOUND_CD_PLAYLOOPED 2 /* Plays the specified track looped, forever until stopped manually. */ +#define FSOUND_CD_PLAYRANDOM 3 /* Plays tracks in random order */ +/* [DEFINE_END] */ + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_MISC_VALUES + + [DESCRIPTION] + Miscellaneous values for FMOD functions. + + [SEE_ALSO] + FSOUND_PlaySound + FSOUND_PlaySoundEx + FSOUND_Sample_Alloc + FSOUND_Sample_Load + FSOUND_SetPan +] +*/ +#define FSOUND_FREE -1 /* value to play on any free channel, or to allocate a sample in a free sample slot. */ +#define FSOUND_UNMANAGED -2 /* value to allocate a sample that is NOT managed by FSOUND or placed in a sample slot. */ +#define FSOUND_ALL -3 /* for a channel index , this flag will affect ALL channels available! Not supported by every function. */ +#define FSOUND_STEREOPAN -1 /* value for FSOUND_SetPan so that stereo sounds are not played at half volume. See FSOUND_SetPan for more on this. */ +#define FSOUND_SYSTEMCHANNEL -1000 /* special 'channel' ID for all channel based functions that want to alter the global FSOUND software mixing output channel */ +#define FSOUND_SYSTEMSAMPLE -1000 /* special 'sample' ID for all sample based functions that want to alter the global FSOUND software mixing output sample */ + +/* [DEFINE_END] */ + + +/* +[STRUCTURE] +[ + [DESCRIPTION] + Structure defining a reverb environment. + For more indepth descriptions of the reverb properties under win32, please see the EAX2 and EAX3 + documentation at http://developer.creative.com/ under the 'downloads' section. + If they do not have the EAX3 documentation, then most information can be attained from + the EAX2 documentation, as EAX3 only adds some more parameters and functionality on top of EAX2. + Note the default reverb properties are the same as the FSOUND_PRESET_GENERIC preset. + Note that integer values that typically range from -10,000 to 1000 are represented in decibels, and are of a logarithmic scale, not linear, wheras float values are typically linear. + PORTABILITY: Each member has the platform it supports in braces ie (win32/xbox). + Some reverb parameters are only supported in win32 and some only on xbox. If all parameters are set then the reverb should product a similar effect on either platform. + + The numerical values listed below are the maximum, minimum and default values for each variable respectively. + + [SEE_ALSO] + FSOUND_Reverb_SetProperties + FSOUND_Reverb_GetProperties + FSOUND_REVERB_PRESETS + FSOUND_REVERB_FLAGS +] +*/ +typedef struct _FSOUND_REVERB_PROPERTIES /* MIN MAX DEFAULT DESCRIPTION */ +{ + unsigned int Environment; /* 0 , 25 , 0 , sets all listener properties (WIN32/PS2 only) */ + float EnvSize; /* 1.0 , 100.0 , 7.5 , environment size in meters (WIN32 only) */ + float EnvDiffusion; /* 0.0 , 1.0 , 1.0 , environment diffusion (WIN32/XBOX) */ + int Room; /* -10000, 0 , -1000 , room effect level (at mid frequencies) (WIN32/XBOX/PS2) */ + int RoomHF; /* -10000, 0 , -100 , relative room effect level at high frequencies (WIN32/XBOX) */ + int RoomLF; /* -10000, 0 , 0 , relative room effect level at low frequencies (WIN32 only) */ + float DecayTime; /* 0.1 , 20.0 , 1.49 , reverberation decay time at mid frequencies (WIN32/XBOX) */ + float DecayHFRatio; /* 0.1 , 2.0 , 0.83 , high-frequency to mid-frequency decay time ratio (WIN32/XBOX) */ + float DecayLFRatio; /* 0.1 , 2.0 , 1.0 , low-frequency to mid-frequency decay time ratio (WIN32 only) */ + int Reflections; /* -10000, 1000 , -2602 , early reflections level relative to room effect (WIN32/XBOX) */ + float ReflectionsDelay; /* 0.0 , 0.3 , 0.007 , initial reflection delay time (WIN32/XBOX) */ + float ReflectionsPan[3]; /* , , [0,0,0], early reflections panning vector (WIN32 only) */ + int Reverb; /* -10000, 2000 , 200 , late reverberation level relative to room effect (WIN32/XBOX) */ + float ReverbDelay; /* 0.0 , 0.1 , 0.011 , late reverberation delay time relative to initial reflection (WIN32/XBOX) */ + float ReverbPan[3]; /* , , [0,0,0], late reverberation panning vector (WIN32 only) */ + float EchoTime; /* .075 , 0.25 , 0.25 , echo time (WIN32/PS2 only. PS2 = Delay time for ECHO/DELAY modes only) */ + float EchoDepth; /* 0.0 , 1.0 , 0.0 , echo depth (WIN32/PS2 only. PS2 = Feedback level for ECHO mode only) */ + float ModulationTime; /* 0.04 , 4.0 , 0.25 , modulation time (WIN32 only) */ + float ModulationDepth; /* 0.0 , 1.0 , 0.0 , modulation depth (WIN32 only) */ + float AirAbsorptionHF; /* -100 , 0.0 , -5.0 , change in level per meter at high frequencies (WIN32 only) */ + float HFReference; /* 1000.0, 20000 , 5000.0 , reference high frequency (hz) (WIN32/XBOX) */ + float LFReference; /* 20.0 , 1000.0, 250.0 , reference low frequency (hz) (WIN32 only) */ + float RoomRolloffFactor; /* 0.0 , 10.0 , 0.0 , like FSOUND_3D_SetRolloffFactor but for room effect (WIN32/XBOX) */ + float Diffusion; /* 0.0 , 100.0 , 100.0 , Value that controls the echo density in the late reverberation decay. (XBOX only) */ + float Density; /* 0.0 , 100.0 , 100.0 , Value that controls the modal density in the late reverberation decay (XBOX only) */ + unsigned int Flags; /* FSOUND_REVERB_FLAGS - modifies the behavior of above properties (WIN32/PS2 only) */ +} FSOUND_REVERB_PROPERTIES; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_FLAGS + + [DESCRIPTION] + Values for the Flags member of the FSOUND_REVERB_PROPERTIES structure. + + [SEE_ALSO] + FSOUND_REVERB_PROPERTIES +] +*/ +#define FSOUND_REVERB_FLAGS_DECAYTIMESCALE 0x00000001 /* 'EnvSize' affects reverberation decay time */ +#define FSOUND_REVERB_FLAGS_REFLECTIONSSCALE 0x00000002 /* 'EnvSize' affects reflection level */ +#define FSOUND_REVERB_FLAGS_REFLECTIONSDELAYSCALE 0x00000004 /* 'EnvSize' affects initial reflection delay time */ +#define FSOUND_REVERB_FLAGS_REVERBSCALE 0x00000008 /* 'EnvSize' affects reflections level */ +#define FSOUND_REVERB_FLAGS_REVERBDELAYSCALE 0x00000010 /* 'EnvSize' affects late reverberation delay time */ +#define FSOUND_REVERB_FLAGS_DECAYHFLIMIT 0x00000020 /* AirAbsorptionHF affects DecayHFRatio */ +#define FSOUND_REVERB_FLAGS_ECHOTIMESCALE 0x00000040 /* 'EnvSize' affects echo time */ +#define FSOUND_REVERB_FLAGS_MODULATIONTIMESCALE 0x00000080 /* 'EnvSize' affects modulation time */ +#define FSOUND_REVERB_FLAGS_CORE0 0x00000100 /* PS2 Only - Reverb is applied to CORE0 (hw voices 0-23) */ +#define FSOUND_REVERB_FLAGS_CORE1 0x00000200 /* PS2 Only - Reverb is applied to CORE1 (hw voices 24-47) */ +#define FSOUND_REVERB_FLAGS_DEFAULT (FSOUND_REVERB_FLAGS_DECAYTIMESCALE | \ + FSOUND_REVERB_FLAGS_REFLECTIONSSCALE | \ + FSOUND_REVERB_FLAGS_REFLECTIONSDELAYSCALE | \ + FSOUND_REVERB_FLAGS_REVERBSCALE | \ + FSOUND_REVERB_FLAGS_REVERBDELAYSCALE | \ + FSOUND_REVERB_FLAGS_DECAYHFLIMIT | \ + FSOUND_REVERB_FLAGS_CORE0 | \ + FSOUND_REVERB_FLAGS_CORE1 ) +/* [DEFINE_END] */ + + + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_PRESETS + + [DESCRIPTION] + A set of predefined environment PARAMETERS, created by Creative Labs + These are used to initialize an FSOUND_REVERB_PROPERTIES structure statically. + ie + FSOUND_REVERB_PROPERTIES prop = FSOUND_PRESET_GENERIC; + + [SEE_ALSO] + FSOUND_Reverb_SetProperties +] +*/ +/* Env Size Diffus Room RoomHF RmLF DecTm DecHF DecLF Refl RefDel RefPan Revb RevDel ReverbPan EchoTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff Diffus Densty FLAGS */ +#define FSOUND_PRESET_OFF {0, 7.5f, 1.00f, -10000, -10000, 0, 1.00f, 1.00f, 1.0f, -2602, 0.007f, { 0.0f,0.0f,0.0f }, 200, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 0.0f, 0.0f, 0x33f } +#define FSOUND_PRESET_GENERIC {0, 7.5f, 1.00f, -1000, -100, 0, 1.49f, 0.83f, 1.0f, -2602, 0.007f, { 0.0f,0.0f,0.0f }, 200, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_PADDEDCELL {1, 1.4f, 1.00f, -1000, -6000, 0, 0.17f, 0.10f, 1.0f, -1204, 0.001f, { 0.0f,0.0f,0.0f }, 207, 0.002f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_ROOM {2, 1.9f, 1.00f, -1000, -454, 0, 0.40f, 0.83f, 1.0f, -1646, 0.002f, { 0.0f,0.0f,0.0f }, 53, 0.003f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_BATHROOM {3, 1.4f, 1.00f, -1000, -1200, 0, 1.49f, 0.54f, 1.0f, -370, 0.007f, { 0.0f,0.0f,0.0f }, 1030, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 60.0f, 0x3f } +#define FSOUND_PRESET_LIVINGROOM {4, 2.5f, 1.00f, -1000, -6000, 0, 0.50f, 0.10f, 1.0f, -1376, 0.003f, { 0.0f,0.0f,0.0f }, -1104, 0.004f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_STONEROOM {5, 11.6f, 1.00f, -1000, -300, 0, 2.31f, 0.64f, 1.0f, -711, 0.012f, { 0.0f,0.0f,0.0f }, 83, 0.017f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_AUDITORIUM {6, 21.6f, 1.00f, -1000, -476, 0, 4.32f, 0.59f, 1.0f, -789, 0.020f, { 0.0f,0.0f,0.0f }, -289, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_CONCERTHALL {7, 19.6f, 1.00f, -1000, -500, 0, 3.92f, 0.70f, 1.0f, -1230, 0.020f, { 0.0f,0.0f,0.0f }, -2, 0.029f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_CAVE {8, 14.6f, 1.00f, -1000, 0, 0, 2.91f, 1.30f, 1.0f, -602, 0.015f, { 0.0f,0.0f,0.0f }, -302, 0.022f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_ARENA {9, 36.2f, 1.00f, -1000, -698, 0, 7.24f, 0.33f, 1.0f, -1166, 0.020f, { 0.0f,0.0f,0.0f }, 16, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_HANGAR {10, 50.3f, 1.00f, -1000, -1000, 0, 10.05f, 0.23f, 1.0f, -602, 0.020f, { 0.0f,0.0f,0.0f }, 198, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_CARPETTEDHALLWAY {11, 1.9f, 1.00f, -1000, -4000, 0, 0.30f, 0.10f, 1.0f, -1831, 0.002f, { 0.0f,0.0f,0.0f }, -1630, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_HALLWAY {12, 1.8f, 1.00f, -1000, -300, 0, 1.49f, 0.59f, 1.0f, -1219, 0.007f, { 0.0f,0.0f,0.0f }, 441, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_STONECORRIDOR {13, 13.5f, 1.00f, -1000, -237, 0, 2.70f, 0.79f, 1.0f, -1214, 0.013f, { 0.0f,0.0f,0.0f }, 395, 0.020f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_ALLEY {14, 7.5f, 0.30f, -1000, -270, 0, 1.49f, 0.86f, 1.0f, -1204, 0.007f, { 0.0f,0.0f,0.0f }, -4, 0.011f, { 0.0f,0.0f,0.0f }, 0.125f, 0.95f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_FOREST {15, 38.0f, 0.30f, -1000, -3300, 0, 1.49f, 0.54f, 1.0f, -2560, 0.162f, { 0.0f,0.0f,0.0f }, -229, 0.088f, { 0.0f,0.0f,0.0f }, 0.125f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 79.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_CITY {16, 7.5f, 0.50f, -1000, -800, 0, 1.49f, 0.67f, 1.0f, -2273, 0.007f, { 0.0f,0.0f,0.0f }, -1691, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 50.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_MOUNTAINS {17, 100.0f, 0.27f, -1000, -2500, 0, 1.49f, 0.21f, 1.0f, -2780, 0.300f, { 0.0f,0.0f,0.0f }, -1434, 0.100f, { 0.0f,0.0f,0.0f }, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 27.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_QUARRY {18, 17.5f, 1.00f, -1000, -1000, 0, 1.49f, 0.83f, 1.0f, -10000, 0.061f, { 0.0f,0.0f,0.0f }, 500, 0.025f, { 0.0f,0.0f,0.0f }, 0.125f, 0.70f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_PLAIN {19, 42.5f, 0.21f, -1000, -2000, 0, 1.49f, 0.50f, 1.0f, -2466, 0.179f, { 0.0f,0.0f,0.0f }, -1926, 0.100f, { 0.0f,0.0f,0.0f }, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 21.0f, 100.0f, 0x3f } +#define FSOUND_PRESET_PARKINGLOT {20, 8.3f, 1.00f, -1000, 0, 0, 1.65f, 1.50f, 1.0f, -1363, 0.008f, { 0.0f,0.0f,0.0f }, -1153, 0.012f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_SEWERPIPE {21, 1.7f, 0.80f, -1000, -1000, 0, 2.81f, 0.14f, 1.0f, 429, 0.014f, { 0.0f,0.0f,0.0f }, 1023, 0.021f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 80.0f, 60.0f, 0x3f } +#define FSOUND_PRESET_UNDERWATER {22, 1.8f, 1.00f, -1000, -4000, 0, 1.49f, 0.10f, 1.0f, -449, 0.007f, { 0.0f,0.0f,0.0f }, 1700, 0.011f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 1.18f, 0.348f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f } + +/* Non I3DL2 presets */ + +#define FSOUND_PRESET_DRUGGED {23, 1.9f, 0.50f, -1000, 0, 0, 8.39f, 1.39f, 1.0f, -115, 0.002f, { 0.0f,0.0f,0.0f }, 985, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 0.25f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_DIZZY {24, 1.8f, 0.60f, -1000, -400, 0, 17.23f, 0.56f, 1.0f, -1713, 0.020f, { 0.0f,0.0f,0.0f }, -613, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 1.00f, 0.81f, 0.310f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } +#define FSOUND_PRESET_PSYCHOTIC {25, 1.0f, 0.50f, -1000, -151, 0, 7.56f, 0.91f, 1.0f, -626, 0.020f, { 0.0f,0.0f,0.0f }, 774, 0.030f, { 0.0f,0.0f,0.0f }, 0.250f, 0.00f, 4.00f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f } + +/* PlayStation 2 and PlayStation Portable only presets */ + +#define FSOUND_PRESET_PS2_ROOM {1, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_STUDIO_A {2, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_STUDIO_B {3, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_STUDIO_C {4, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_HALL {5, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_SPACE {6, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_ECHO {7, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_DELAY {8, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } +#define FSOUND_PRESET_PS2_PIPE {9, 0, 0, 0, 0, 0, 0.0f, 0.0f, 0.0f, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0, 0.000f, { 0.0f,0.0f,0.0f }, 0.000f, 0.00f, 0.00f, 0.000f, 0.0f, 0000.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0x31f } + +/* [DEFINE_END] */ + + +/* +[STRUCTURE] +[ + [DESCRIPTION] + Structure defining the properties for a reverb source, related to a FSOUND channel. + For more indepth descriptions of the reverb properties under win32, please see the EAX3 + documentation at http://developer.creative.com/ under the 'downloads' section. + If they do not have the EAX3 documentation, then most information can be attained from + the EAX2 documentation, as EAX3 only adds some more parameters and functionality on top of + EAX2. + + Note the default reverb properties are the same as the FSOUND_PRESET_GENERIC preset. + Note that integer values that typically range from -10,000 to 1000 are represented in + decibels, and are of a logarithmic scale, not linear, wheras float values are typically linear. + PORTABILITY: Each member has the platform it supports in braces ie (win32/xbox). + Some reverb parameters are only supported in win32 and some only on xbox. If all parameters are set then + the reverb should product a similar effect on either platform. + Linux and FMODCE do not support the reverb api. + + The numerical values listed below are the maximum, minimum and default values for each variable respectively. + + [SEE_ALSO] + FSOUND_Reverb_SetChannelProperties + FSOUND_Reverb_GetChannelProperties + FSOUND_REVERB_CHANNELFLAGS +] +*/ +typedef struct _FSOUND_REVERB_CHANNELPROPERTIES /* MIN MAX DEFAULT */ +{ + int Direct; /* -10000, 1000, 0, direct path level (at low and mid frequencies) (WIN32/XBOX) */ + int DirectHF; /* -10000, 0, 0, relative direct path level at high frequencies (WIN32/XBOX) */ + int Room; /* -10000, 1000, 0, room effect level (at low and mid frequencies) (WIN32/XBOX/PS2) */ + int RoomHF; /* -10000, 0, 0, relative room effect level at high frequencies (WIN32/XBOX) */ + int Obstruction; /* -10000, 0, 0, main obstruction control (attenuation at high frequencies) (WIN32/XBOX) */ + float ObstructionLFRatio; /* 0.0, 1.0, 0.0, obstruction low-frequency level re. main control (WIN32/XBOX) */ + int Occlusion; /* -10000, 0, 0, main occlusion control (attenuation at high frequencies) (WIN32/XBOX) */ + float OcclusionLFRatio; /* 0.0, 1.0, 0.25, occlusion low-frequency level re. main control (WIN32/XBOX) */ + float OcclusionRoomRatio; /* 0.0, 10.0, 1.5, relative occlusion control for room effect (WIN32) */ + float OcclusionDirectRatio; /* 0.0, 10.0, 1.0, relative occlusion control for direct path (WIN32) */ + int Exclusion; /* -10000, 0, 0, main exlusion control (attenuation at high frequencies) (WIN32) */ + float ExclusionLFRatio; /* 0.0, 1.0, 1.0, exclusion low-frequency level re. main control (WIN32) */ + int OutsideVolumeHF; /* -10000, 0, 0, outside sound cone level at high frequencies (WIN32) */ + float DopplerFactor; /* 0.0, 10.0, 0.0, like DS3D flDopplerFactor but per source (WIN32) */ + float RolloffFactor; /* 0.0, 10.0, 0.0, like DS3D flRolloffFactor but per source (WIN32) */ + float RoomRolloffFactor; /* 0.0, 10.0, 0.0, like DS3D flRolloffFactor but for room effect (WIN32/XBOX) */ + float AirAbsorptionFactor; /* 0.0, 10.0, 1.0, multiplies AirAbsorptionHF member of FSOUND_REVERB_PROPERTIES (WIN32) */ + int Flags; /* FSOUND_REVERB_CHANNELFLAGS - modifies the behavior of properties (WIN32) */ +} FSOUND_REVERB_CHANNELPROPERTIES; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_REVERB_CHANNELFLAGS + + [DESCRIPTION] + Values for the Flags member of the FSOUND_REVERB_CHANNELPROPERTIES structure. + + [SEE_ALSO] + FSOUND_REVERB_CHANNELPROPERTIES +] +*/ +#define FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO 0x00000001 /* Automatic setting of 'Direct' due to distance from listener */ +#define FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO 0x00000002 /* Automatic setting of 'Room' due to distance from listener */ +#define FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO 0x00000004 /* Automatic setting of 'RoomHF' due to distance from listener */ +#define FSOUND_REVERB_CHANNELFLAGS_DEFAULT (FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO | \ + FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO| \ + FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO) +/* [DEFINE_END] */ + + +/* +[ENUM] +[ + [DESCRIPTION] + These values are used with FSOUND_FX_Enable to enable DirectX 8 FX for a channel. + + [SEE_ALSO] + FSOUND_FX_Enable + FSOUND_FX_Disable + FSOUND_FX_SetChorus + FSOUND_FX_SetCompressor + FSOUND_FX_SetDistortion + FSOUND_FX_SetEcho + FSOUND_FX_SetFlanger + FSOUND_FX_SetGargle + FSOUND_FX_SetI3DL2Reverb + FSOUND_FX_SetParamEQ + FSOUND_FX_SetWavesReverb +] +*/ +enum FSOUND_FX_MODES +{ + FSOUND_FX_CHORUS, + FSOUND_FX_COMPRESSOR, + FSOUND_FX_DISTORTION, + FSOUND_FX_ECHO, + FSOUND_FX_FLANGER, + FSOUND_FX_GARGLE, + FSOUND_FX_I3DL2REVERB, + FSOUND_FX_PARAMEQ, + FSOUND_FX_WAVES_REVERB, + + FSOUND_FX_MAX +}; + +/* +[ENUM] +[ + [DESCRIPTION] + These are speaker types defined for use with the FSOUND_SetSpeakerMode command. + Note - Only reliably works with FSOUND_OUTPUT_DSOUND or FSOUND_OUTPUT_XBOX output modes. Other output modes will only + interpret FSOUND_SPEAKERMODE_MONO and set everything else to be stereo. + + Using either DolbyDigital or DTS will use whatever 5.1 digital mode is available if destination hardware is unsure. + + [SEE_ALSO] + FSOUND_SetSpeakerMode + +] +*/ +enum FSOUND_SPEAKERMODES +{ + FSOUND_SPEAKERMODE_DOLBYDIGITAL, /* Dolby Digital Output (XBOX or PC only). */ + FSOUND_SPEAKERMODE_HEADPHONES, /* The speakers are headphones. */ + FSOUND_SPEAKERMODE_MONO, /* The speakers are monaural. */ + FSOUND_SPEAKERMODE_QUAD, /* The speakers are quadraphonic. */ + FSOUND_SPEAKERMODE_STEREO, /* The speakers are stereo (default value). */ + FSOUND_SPEAKERMODE_SURROUND, /* The speakers are surround sound. */ + FSOUND_SPEAKERMODE_DTS, /* DTS output (XBOX only). */ + FSOUND_SPEAKERMODE_PROLOGIC2, /* Dolby Prologic 2. Playstation 2 and Gamecube only. PlayStation 2 doesnt support interior panning, but supports 48 voices simultaneously. */ + FSOUND_SPEAKERMODE_PROLOGIC2_INTERIOR /* Dolby Prologic 2. Playstation 2 and Gamecube only. PlayStation 2 does support interior panning, but only supports 24 voices simultaneously. */ +}; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_INIT_FLAGS + + [DESCRIPTION] + Initialization flags. Use them with FSOUND_Init in the flags parameter to change various behaviour. + + FSOUND_INIT_ENABLESYSTEMCHANNELFX Is an init mode which enables the FSOUND mixer buffer to be affected by DirectX 8 effects. + Note that due to limitations of DirectSound, FSOUND_Init may fail if this is enabled because the buffersize is too small. + This can be fixed with FSOUND_SetBufferSize. Increase the BufferSize until it works. + When it is enabled you can use the FSOUND_FX api, and use FSOUND_SYSTEMCHANNEL as the channel id when setting parameters. + + [SEE_ALSO] + FSOUND_Init +] +*/ +#define FSOUND_INIT_USEDEFAULTMIDISYNTH 0x0001 /* Win32 only - Causes MIDI playback to force software decoding. */ +#define FSOUND_INIT_GLOBALFOCUS 0x0002 /* Win32 only - For DirectSound output - sound is not muted when window is out of focus. */ +#define FSOUND_INIT_ENABLESYSTEMCHANNELFX 0x0004 /* Win32 only - For DirectSound output - Allows FSOUND_FX api to be used on global software mixer output! (use FSOUND_SYSTEMCHANNEL as channel id) */ +#define FSOUND_INIT_ACCURATEVULEVELS 0x0008 /* This latency adjusts FSOUND_GetCurrentLevels, but incurs a small cpu and memory hit */ +#define FSOUND_INIT_PS2_DISABLECORE0REVERB 0x0010 /* PS2 only - Disable reverb on CORE 0 (SPU2 voices 00-23) to regain SRAM */ +#define FSOUND_INIT_PS2_DISABLECORE1REVERB 0x0020 /* PS2 only - Disable reverb on CORE 1 (SPU2 voices 24-47) to regain SRAM */ +#define FSOUND_INIT_PS2_SWAPDMACORES 0x0040 /* PS2 only - By default FMOD uses DMA CH0 for mixing, CH1 for uploads, this flag swaps them around */ +#define FSOUND_INIT_DONTLATENCYADJUST 0x0080 /* Callbacks are not latency adjusted, and are called at mix time. Also information functions are immediate */ +#define FSOUND_INIT_GC_INITLIBS 0x0100 /* GC only - Initializes GC audio libraries */ +#define FSOUND_INIT_STREAM_FROM_MAIN_THREAD 0x0200 /* Turns off fmod streamer thread, and makes streaming update from FSOUND_Update called by the user */ +#define FSOUND_INIT_PS2_USEVOLUMERAMPING 0x0400 /* PS2 only - Turns on volume ramping system to remove hardware clicks. */ +#define FSOUND_INIT_DSOUND_DEFERRED 0x0800 /* Win32 only - For DirectSound output. 3D commands are batched together and executed at FSOUND_Update. */ +#define FSOUND_INIT_DSOUND_HRTF_LIGHT 0x1000 /* Win32 only - For DirectSound output. FSOUND_HW3D buffers use a slightly higher quality algorithm when 3d hardware acceleration is not present. */ +#define FSOUND_INIT_DSOUND_HRTF_FULL 0x2000 /* Win32 only - For DirectSound output. FSOUND_HW3D buffers use full quality 3d playback when 3d hardware acceleration is not present. */ +#define FSOUND_INIT_XBOX_REMOVEHEADROOM 0x4000 /* XBox only - By default directsound attenuates all sound by 6db to avoid clipping/distortion. CAUTION. If you use this flag you are responsible for the final mix to make sure clipping / distortion doesn't happen. */ +#define FSOUND_INIT_PSP_SILENCEONUNDERRUN 0x8000 /* PSP only - If streams skip / stutter when device is powered on, either increase stream buffersize, or use this flag instead to play silence while the UMD is recovering. */ +/* [DEFINE_END] */ + + +/* +[ENUM] +[ + [DESCRIPTION] + Status values for internet streams. Use FSOUND_Stream_Net_GetStatus to get the current status of an internet stream. + + [SEE_ALSO] + FSOUND_Stream_Net_GetStatus +] +*/ +enum FSOUND_STREAM_NET_STATUS +{ + FSOUND_STREAM_NET_NOTCONNECTED = 0, /* Stream hasn't connected yet */ + FSOUND_STREAM_NET_CONNECTING, /* Stream is connecting to remote host */ + FSOUND_STREAM_NET_BUFFERING, /* Stream is buffering data */ + FSOUND_STREAM_NET_READY, /* Stream is ready to play */ + FSOUND_STREAM_NET_ERROR /* Stream has suffered a fatal error */ +}; + + +/* +[ENUM] +[ + [DESCRIPTION] + Describes the type of a particular tag field. + + [SEE_ALSO] + FSOUND_Stream_GetNumTagFields + FSOUND_Stream_GetTagField + FSOUND_Stream_FindTagField +] +*/ +enum FSOUND_TAGFIELD_TYPE +{ + FSOUND_TAGFIELD_VORBISCOMMENT = 0, /* A vorbis comment */ + FSOUND_TAGFIELD_ID3V1, /* Part of an ID3v1 tag */ + FSOUND_TAGFIELD_ID3V2, /* An ID3v2 frame */ + FSOUND_TAGFIELD_SHOUTCAST, /* A SHOUTcast header line */ + FSOUND_TAGFIELD_ICECAST, /* An Icecast header line */ + FSOUND_TAGFIELD_ASF /* An Advanced Streaming Format header line */ +}; + + +/* +[DEFINE_START] +[ + [NAME] + FSOUND_STATUS_FLAGS + + [DESCRIPTION] + These values describe the protocol and format of an internet stream. Use FSOUND_Stream_Net_GetStatus to retrieve this information for an open internet stream. + + [SEE_ALSO] + FSOUND_Stream_Net_GetStatus +] +*/ +#define FSOUND_PROTOCOL_SHOUTCAST 0x00000001 +#define FSOUND_PROTOCOL_ICECAST 0x00000002 +#define FSOUND_PROTOCOL_HTTP 0x00000004 +#define FSOUND_FORMAT_MPEG 0x00010000 +#define FSOUND_FORMAT_OGGVORBIS 0x00020000 +/* [DEFINE_END] */ + + +/* +[STRUCTURE] +[ + [DESCRIPTION] + Structure defining a CD table of contents. This structure is returned as a tag from FSOUND_Stream_FindTagField when the tag name "CD_TOC" is specified. + Note: All tracks on the CD - including data tracks- will be represented in this structure so it's use for anything other than generating disc id information is not recommended. + See the cdda example program for info on retrieving and using this structure. + + [SEE_ALSO] + FSOUND_Stream_Open + FSOUND_Stream_FindTagField +] +*/ +typedef struct _FSOUND_TOC_TAG +{ + char name[4]; /* The string "TOC", just in case this structure is accidentally treated as a string */ + int numtracks; /* The number of tracks on the CD */ + int min[100]; /* The start offset of each track in minutes */ + int sec[100]; /* The start offset of each track in seconds */ + int frame[100]; /* The start offset of each track in frames */ + +} FSOUND_TOC_TAG; + + +/* ========================================================================================== */ +/* FUNCTION PROTOTYPES */ +/* ========================================================================================== */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ================================== */ +/* Initialization / Global functions. */ +/* ================================== */ + +/* + PRE - FSOUND_Init functions. These can't be called after FSOUND_Init is + called (they will fail). They set up FMOD system functionality. +*/ + +DLL_API signed char F_API FSOUND_SetOutput(int outputtype); +DLL_API signed char F_API FSOUND_SetDriver(int driver); +DLL_API signed char F_API FSOUND_SetMixer(int mixer); +DLL_API signed char F_API FSOUND_SetBufferSize(int len_ms); +DLL_API signed char F_API FSOUND_SetHWND(void *hwnd); +DLL_API signed char F_API FSOUND_SetMinHardwareChannels(int min); +DLL_API signed char F_API FSOUND_SetMaxHardwareChannels(int max); +DLL_API signed char F_API FSOUND_SetMemorySystem(void *pool, + int poollen, + FSOUND_ALLOCCALLBACK useralloc, + FSOUND_REALLOCCALLBACK userrealloc, + FSOUND_FREECALLBACK userfree); +/* + Main initialization / closedown functions. + Note : Use FSOUND_INIT_USEDEFAULTMIDISYNTH with FSOUND_Init for software override + with MIDI playback. + : Use FSOUND_INIT_GLOBALFOCUS with FSOUND_Init to make sound audible no matter + which window is in focus. (FSOUND_OUTPUT_DSOUND only) +*/ + +DLL_API signed char F_API FSOUND_Init(int mixrate, int maxsoftwarechannels, unsigned int flags); +DLL_API void F_API FSOUND_Close(); + +/* + Runtime system level functions +*/ + +DLL_API void F_API FSOUND_Update(); /* This is called to update 3d sound / non-realtime output */ + +DLL_API void F_API FSOUND_SetSpeakerMode(unsigned int speakermode); +DLL_API void F_API FSOUND_SetSFXMasterVolume(int volume); +DLL_API void F_API FSOUND_SetPanSeperation(float pansep); +DLL_API void F_API FSOUND_File_SetCallbacks(FSOUND_OPENCALLBACK useropen, + FSOUND_CLOSECALLBACK userclose, + FSOUND_READCALLBACK userread, + FSOUND_SEEKCALLBACK userseek, + FSOUND_TELLCALLBACK usertell); + +/* + System information functions. +*/ + +DLL_API int F_API FSOUND_GetError(); +DLL_API float F_API FSOUND_GetVersion(); +DLL_API int F_API FSOUND_GetOutput(); +DLL_API void * F_API FSOUND_GetOutputHandle(); +DLL_API int F_API FSOUND_GetDriver(); +DLL_API int F_API FSOUND_GetMixer(); +DLL_API int F_API FSOUND_GetNumDrivers(); +DLL_API const char * F_API FSOUND_GetDriverName(int id); +DLL_API signed char F_API FSOUND_GetDriverCaps(int id, unsigned int *caps); +DLL_API int F_API FSOUND_GetOutputRate(); +DLL_API int F_API FSOUND_GetMaxChannels(); +DLL_API int F_API FSOUND_GetMaxSamples(); +DLL_API unsigned int F_API FSOUND_GetSpeakerMode(); +DLL_API int F_API FSOUND_GetSFXMasterVolume(); +DLL_API signed char F_API FSOUND_GetNumHWChannels(int *num2d, int *num3d, int *total); +DLL_API int F_API FSOUND_GetChannelsPlaying(); +DLL_API float F_API FSOUND_GetCPUUsage(); +DLL_API void F_API FSOUND_GetMemoryStats(unsigned int *currentalloced, unsigned int *maxalloced); + +/* =================================== */ +/* Sample management / load functions. */ +/* =================================== */ + +/* + Sample creation and management functions + Note : Use FSOUND_LOADMEMORY flag with FSOUND_Sample_Load to load from memory. + Use FSOUND_LOADRAW flag with FSOUND_Sample_Load to treat as as raw pcm data. +*/ + +DLL_API FSOUND_SAMPLE * F_API FSOUND_Sample_Load(int index, const char *name_or_data, unsigned int mode, int offset, int length); +DLL_API FSOUND_SAMPLE * F_API FSOUND_Sample_Alloc(int index, int length, unsigned int mode, int deffreq, int defvol, int defpan, int defpri); +DLL_API void F_API FSOUND_Sample_Free(FSOUND_SAMPLE *sptr); +DLL_API signed char F_API FSOUND_Sample_Upload(FSOUND_SAMPLE *sptr, void *srcdata, unsigned int mode); +DLL_API signed char F_API FSOUND_Sample_Lock(FSOUND_SAMPLE *sptr, int offset, int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2); +DLL_API signed char F_API FSOUND_Sample_Unlock(FSOUND_SAMPLE *sptr, void *ptr1, void *ptr2, unsigned int len1, unsigned int len2); + +/* + Sample control functions +*/ + +DLL_API signed char F_API FSOUND_Sample_SetMode(FSOUND_SAMPLE *sptr, unsigned int mode); +DLL_API signed char F_API FSOUND_Sample_SetLoopPoints(FSOUND_SAMPLE *sptr, int loopstart, int loopend); +DLL_API signed char F_API FSOUND_Sample_SetDefaults(FSOUND_SAMPLE *sptr, int deffreq, int defvol, int defpan, int defpri); +DLL_API signed char F_API FSOUND_Sample_SetDefaultsEx(FSOUND_SAMPLE *sptr, int deffreq, int defvol, int defpan, int defpri, int varfreq, int varvol, int varpan); +DLL_API signed char F_API FSOUND_Sample_SetMinMaxDistance(FSOUND_SAMPLE *sptr, float min, float max); +DLL_API signed char F_API FSOUND_Sample_SetMaxPlaybacks(FSOUND_SAMPLE *sptr, int max); + +/* + Sample information functions +*/ + +DLL_API FSOUND_SAMPLE * F_API FSOUND_Sample_Get(int sampno); +DLL_API const char * F_API FSOUND_Sample_GetName(FSOUND_SAMPLE *sptr); +DLL_API unsigned int F_API FSOUND_Sample_GetLength(FSOUND_SAMPLE *sptr); +DLL_API signed char F_API FSOUND_Sample_GetLoopPoints(FSOUND_SAMPLE *sptr, int *loopstart, int *loopend); +DLL_API signed char F_API FSOUND_Sample_GetDefaults(FSOUND_SAMPLE *sptr, int *deffreq, int *defvol, int *defpan, int *defpri); +DLL_API signed char F_API FSOUND_Sample_GetDefaultsEx(FSOUND_SAMPLE *sptr, int *deffreq, int *defvol, int *defpan, int *defpri, int *varfreq, int *varvol, int *varpan); +DLL_API unsigned int F_API FSOUND_Sample_GetMode(FSOUND_SAMPLE *sptr); +DLL_API signed char F_API FSOUND_Sample_GetMinMaxDistance(FSOUND_SAMPLE *sptr, float *min, float *max); + +/* ============================ */ +/* Channel control functions. */ +/* ============================ */ + +/* + Playing and stopping sounds. + Note : Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. + Use FSOUND_ALL as the 'channel' variable to control ALL channels with one function call! +*/ + +DLL_API int F_API FSOUND_PlaySound(int channel, FSOUND_SAMPLE *sptr); +DLL_API int F_API FSOUND_PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); +DLL_API signed char F_API FSOUND_StopSound(int channel); + +/* + Functions to control playback of a channel. + Note : FSOUND_ALL can be used on most of these functions as a channel value. +*/ + +DLL_API signed char F_API FSOUND_SetFrequency(int channel, int freq); +DLL_API signed char F_API FSOUND_SetVolume(int channel, int vol); +DLL_API signed char F_API FSOUND_SetVolumeAbsolute(int channel, int vol); +DLL_API signed char F_API FSOUND_SetPan(int channel, int pan); +DLL_API signed char F_API FSOUND_SetSurround(int channel, signed char surround); +DLL_API signed char F_API FSOUND_SetMute(int channel, signed char mute); +DLL_API signed char F_API FSOUND_SetPriority(int channel, int priority); +DLL_API signed char F_API FSOUND_SetReserved(int channel, signed char reserved); +DLL_API signed char F_API FSOUND_SetPaused(int channel, signed char paused); +DLL_API signed char F_API FSOUND_SetLoopMode(int channel, unsigned int loopmode); +DLL_API signed char F_API FSOUND_SetCurrentPosition(int channel, unsigned int offset); +DLL_API signed char F_API FSOUND_3D_SetAttributes(int channel, const float *pos, const float *vel); +DLL_API signed char F_API FSOUND_3D_SetMinMaxDistance(int channel, float min, float max); + +/* + Channel information functions. +*/ + +DLL_API signed char F_API FSOUND_IsPlaying(int channel); +DLL_API int F_API FSOUND_GetFrequency(int channel); +DLL_API int F_API FSOUND_GetVolume(int channel); +DLL_API int F_API FSOUND_GetAmplitude(int channel); +DLL_API int F_API FSOUND_GetPan(int channel); +DLL_API signed char F_API FSOUND_GetSurround(int channel); +DLL_API signed char F_API FSOUND_GetMute(int channel); +DLL_API int F_API FSOUND_GetPriority(int channel); +DLL_API signed char F_API FSOUND_GetReserved(int channel); +DLL_API signed char F_API FSOUND_GetPaused(int channel); +DLL_API unsigned int F_API FSOUND_GetLoopMode(int channel); +DLL_API unsigned int F_API FSOUND_GetCurrentPosition(int channel); +DLL_API FSOUND_SAMPLE * F_API FSOUND_GetCurrentSample(int channel); +DLL_API signed char F_API FSOUND_GetCurrentLevels(int channel, float *l, float *r); +DLL_API int F_API FSOUND_GetNumSubChannels(int channel); +DLL_API int F_API FSOUND_GetSubChannel(int channel, int subchannel); +DLL_API signed char F_API FSOUND_3D_GetAttributes(int channel, float *pos, float *vel); +DLL_API signed char F_API FSOUND_3D_GetMinMaxDistance(int channel, float *min, float *max); + +/* ========================== */ +/* Global 3D sound functions. */ +/* ========================== */ + +/* + See also 3d sample and channel based functions above. + Call FSOUND_Update once a frame to process 3d information. +*/ + +DLL_API void F_API FSOUND_3D_Listener_SetAttributes(const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz); +DLL_API void F_API FSOUND_3D_Listener_GetAttributes(float *pos, float *vel, float *fx, float *fy, float *fz, float *tx, float *ty, float *tz); +DLL_API void F_API FSOUND_3D_Listener_SetCurrent(int current, int numlisteners); /* use this if you use multiple listeners / splitscreen */ +DLL_API void F_API FSOUND_3D_SetDopplerFactor(float scale); +DLL_API void F_API FSOUND_3D_SetDistanceFactor(float scale); +DLL_API void F_API FSOUND_3D_SetRolloffFactor(float scale); + +/* =================== */ +/* FX functions. */ +/* =================== */ + +/* + Functions to control DX8 only effects processing. + + - FX enabled samples can only be played once at a time, not multiple times at once. + - Sounds have to be created with FSOUND_HW2D or FSOUND_HW3D for this to work. + - FSOUND_INIT_ENABLESYSTEMCHANNELFX can be used to apply hardware effect processing to the + global mixed output of FMOD's software channels. + - FSOUND_FX_Enable returns an FX handle that you can use to alter fx parameters. + - FSOUND_FX_Enable can be called multiple times in a row, even on the same FX type, + it will return a unique handle for each FX. + - FSOUND_FX_Enable cannot be called if the sound is playing or locked. + - FSOUND_FX_Disable must be called to reset/clear the FX from a channel. +*/ + +DLL_API int F_API FSOUND_FX_Enable(int channel, unsigned int fxtype); /* See FSOUND_FX_MODES */ +DLL_API signed char F_API FSOUND_FX_Disable(int channel); /* Disables all effects */ + +DLL_API signed char F_API FSOUND_FX_SetChorus(int fxid, float WetDryMix, float Depth, float Feedback, float Frequency, int Waveform, float Delay, int Phase); +DLL_API signed char F_API FSOUND_FX_SetCompressor(int fxid, float Gain, float Attack, float Release, float Threshold, float Ratio, float Predelay); +DLL_API signed char F_API FSOUND_FX_SetDistortion(int fxid, float Gain, float Edge, float PostEQCenterFrequency, float PostEQBandwidth, float PreLowpassCutoff); +DLL_API signed char F_API FSOUND_FX_SetEcho(int fxid, float WetDryMix, float Feedback, float LeftDelay, float RightDelay, int PanDelay); +DLL_API signed char F_API FSOUND_FX_SetFlanger(int fxid, float WetDryMix, float Depth, float Feedback, float Frequency, int Waveform, float Delay, int Phase); +DLL_API signed char F_API FSOUND_FX_SetGargle(int fxid, int RateHz, int WaveShape); +DLL_API signed char F_API FSOUND_FX_SetI3DL2Reverb(int fxid, int Room, int RoomHF, float RoomRolloffFactor, float DecayTime, float DecayHFRatio, int Reflections, float ReflectionsDelay, int Reverb, float ReverbDelay, float Diffusion, float Density, float HFReference); +DLL_API signed char F_API FSOUND_FX_SetParamEQ(int fxid, float Center, float Bandwidth, float Gain); +DLL_API signed char F_API FSOUND_FX_SetWavesReverb(int fxid, float InGain, float ReverbMix, float ReverbTime, float HighFreqRTRatio); + +/* ========================= */ +/* File Streaming functions. */ +/* ========================= */ + +/* + Note : Use FSOUND_LOADMEMORY flag with FSOUND_Stream_Open to stream from memory. + Use FSOUND_LOADRAW flag with FSOUND_Stream_Open to treat stream as raw pcm data. + Use FSOUND_MPEGACCURATE flag with FSOUND_Stream_Open to open mpegs in 'accurate mode' for settime/gettime/getlengthms. + Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. +*/ + +DLL_API signed char F_API FSOUND_Stream_SetBufferSize(int ms); /* call this before opening streams, not after */ + +DLL_API FSOUND_STREAM * F_API FSOUND_Stream_Open(const char *name_or_data, unsigned int mode, int offset, int length); +DLL_API FSOUND_STREAM * F_API FSOUND_Stream_Create(FSOUND_STREAMCALLBACK callback, int length, unsigned int mode, int samplerate, void *userdata); +DLL_API signed char F_API FSOUND_Stream_Close(FSOUND_STREAM *stream); + +DLL_API int F_API FSOUND_Stream_Play(int channel, FSOUND_STREAM *stream); +DLL_API int F_API FSOUND_Stream_PlayEx(int channel, FSOUND_STREAM *stream, FSOUND_DSPUNIT *dsp, signed char startpaused); +DLL_API signed char F_API FSOUND_Stream_Stop(FSOUND_STREAM *stream); + +DLL_API signed char F_API FSOUND_Stream_SetPosition(FSOUND_STREAM *stream, unsigned int position); +DLL_API unsigned int F_API FSOUND_Stream_GetPosition(FSOUND_STREAM *stream); +DLL_API signed char F_API FSOUND_Stream_SetTime(FSOUND_STREAM *stream, int ms); +DLL_API int F_API FSOUND_Stream_GetTime(FSOUND_STREAM *stream); +DLL_API int F_API FSOUND_Stream_GetLength(FSOUND_STREAM *stream); +DLL_API int F_API FSOUND_Stream_GetLengthMs(FSOUND_STREAM *stream); + +DLL_API signed char F_API FSOUND_Stream_SetMode(FSOUND_STREAM *stream, unsigned int mode); +DLL_API unsigned int F_API FSOUND_Stream_GetMode(FSOUND_STREAM *stream); +DLL_API signed char F_API FSOUND_Stream_SetLoopPoints(FSOUND_STREAM *stream, unsigned int loopstartpcm, unsigned int loopendpcm); +DLL_API signed char F_API FSOUND_Stream_SetLoopCount(FSOUND_STREAM *stream, int count); +DLL_API int F_API FSOUND_Stream_GetOpenState(FSOUND_STREAM *stream); /* use with FSOUND_NONBLOCKING opened streams */ +DLL_API FSOUND_SAMPLE * F_API FSOUND_Stream_GetSample(FSOUND_STREAM *stream); +DLL_API FSOUND_DSPUNIT * F_API FSOUND_Stream_CreateDSP(FSOUND_STREAM *stream, FSOUND_DSPCALLBACK callback, int priority, void *userdata); + +DLL_API signed char F_API FSOUND_Stream_SetEndCallback(FSOUND_STREAM *stream, FSOUND_STREAMCALLBACK callback, void *userdata); +DLL_API signed char F_API FSOUND_Stream_SetSyncCallback(FSOUND_STREAM *stream, FSOUND_STREAMCALLBACK callback, void *userdata); + +DLL_API FSOUND_SYNCPOINT * F_API FSOUND_Stream_AddSyncPoint(FSOUND_STREAM *stream, unsigned int pcmoffset, const char *name); +DLL_API signed char F_API FSOUND_Stream_DeleteSyncPoint(FSOUND_SYNCPOINT *point); +DLL_API int F_API FSOUND_Stream_GetNumSyncPoints(FSOUND_STREAM *stream); +DLL_API FSOUND_SYNCPOINT * F_API FSOUND_Stream_GetSyncPoint(FSOUND_STREAM *stream, int index); +DLL_API char * F_API FSOUND_Stream_GetSyncPointInfo(FSOUND_SYNCPOINT *point, unsigned int *pcmoffset); + +DLL_API signed char F_API FSOUND_Stream_SetSubStream(FSOUND_STREAM *stream, int index); /* For FMOD .FSB bank files. */ +DLL_API int F_API FSOUND_Stream_GetNumSubStreams(FSOUND_STREAM *stream); /* For FMOD .FSB bank files. */ +DLL_API signed char F_API FSOUND_Stream_SetSubStreamSentence(FSOUND_STREAM *stream, const int *sentencelist, int numitems); + +DLL_API signed char F_API FSOUND_Stream_GetNumTagFields(FSOUND_STREAM *stream, int *num); +DLL_API signed char F_API FSOUND_Stream_GetTagField(FSOUND_STREAM *stream, int num, int *type, char **name, void **value, int *length); +DLL_API signed char F_API FSOUND_Stream_FindTagField(FSOUND_STREAM *stream, int type, const char *name, void **value, int *length); + +/* + Internet streaming functions +*/ + +DLL_API signed char F_API FSOUND_Stream_Net_SetProxy(const char *proxy); +DLL_API signed char F_API FSOUND_Stream_Net_SetTimeout(int timeout); +DLL_API char * F_API FSOUND_Stream_Net_GetLastServerStatus(); +DLL_API signed char F_API FSOUND_Stream_Net_SetBufferProperties(int buffersize, int prebuffer_percent, int rebuffer_percent); +DLL_API signed char F_API FSOUND_Stream_Net_GetBufferProperties(int *buffersize, int *prebuffer_percent, int *rebuffer_percent); +DLL_API signed char F_API FSOUND_Stream_Net_SetMetadataCallback(FSOUND_STREAM *stream, FSOUND_METADATACALLBACK callback, void *userdata); +DLL_API signed char F_API FSOUND_Stream_Net_GetStatus(FSOUND_STREAM *stream, int *status, int *bufferpercentused, int *bitrate, unsigned int *flags); + +/* =================== */ +/* CD audio functions. */ +/* =================== */ + +/* + Note : 0 = default cdrom. Otherwise specify the drive letter, for example. 'D'. +*/ + +DLL_API signed char F_API FSOUND_CD_Play(char drive, int track); +DLL_API void F_API FSOUND_CD_SetPlayMode(char drive, signed char mode); +DLL_API signed char F_API FSOUND_CD_Stop(char drive); +DLL_API signed char F_API FSOUND_CD_SetPaused(char drive, signed char paused); +DLL_API signed char F_API FSOUND_CD_SetVolume(char drive, int volume); +DLL_API signed char F_API FSOUND_CD_SetTrackTime(char drive, unsigned int ms); +DLL_API signed char F_API FSOUND_CD_OpenTray(char drive, signed char open); + +DLL_API signed char F_API FSOUND_CD_GetPaused(char drive); +DLL_API int F_API FSOUND_CD_GetTrack(char drive); +DLL_API int F_API FSOUND_CD_GetNumTracks(char drive); +DLL_API int F_API FSOUND_CD_GetVolume(char drive); +DLL_API int F_API FSOUND_CD_GetTrackLength(char drive, int track); +DLL_API int F_API FSOUND_CD_GetTrackTime(char drive); + +/* ============== */ +/* DSP functions. */ +/* ============== */ + +/* + DSP Unit control and information functions. + These functions allow you access to the mixed stream that FMOD uses to play back sound on. +*/ + +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_Create(FSOUND_DSPCALLBACK callback, int priority, void *userdata); +DLL_API void F_API FSOUND_DSP_Free(FSOUND_DSPUNIT *unit); +DLL_API void F_API FSOUND_DSP_SetPriority(FSOUND_DSPUNIT *unit, int priority); +DLL_API int F_API FSOUND_DSP_GetPriority(FSOUND_DSPUNIT *unit); +DLL_API void F_API FSOUND_DSP_SetActive(FSOUND_DSPUNIT *unit, signed char active); +DLL_API signed char F_API FSOUND_DSP_GetActive(FSOUND_DSPUNIT *unit); + +/* + Functions to get hold of FSOUND 'system DSP unit' handles. +*/ + +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetClearUnit(); +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetSFXUnit(); +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetMusicUnit(); +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetFFTUnit(); +DLL_API FSOUND_DSPUNIT *F_API FSOUND_DSP_GetClipAndCopyUnit(); + +/* + Miscellaneous DSP functions + Note for the spectrum analysis function to work, you have to enable the FFT DSP unit with + the following code FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE); + It is off by default to save cpu usage. +*/ + +DLL_API signed char F_API FSOUND_DSP_MixBuffers(void *destbuffer, void *srcbuffer, int len, int freq, int vol, int pan, unsigned int mode); +DLL_API void F_API FSOUND_DSP_ClearMixBuffer(); +DLL_API int F_API FSOUND_DSP_GetBufferLength(); /* Length of each DSP update */ +DLL_API int F_API FSOUND_DSP_GetBufferLengthTotal(); /* Total buffer length due to FSOUND_SetBufferSize */ +DLL_API float * F_API FSOUND_DSP_GetSpectrum(); /* Array of 512 floats - call FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE)) for this to work. */ + +/* =================================================================================== */ +/* Reverb functions. (eax2/eax3 reverb) (ONLY SUPPORTED ON WIN32 W/ FSOUND_HW3D FLAG) */ +/* =================================================================================== */ + +/* + See top of file for definitions and information on the reverb parameters. +*/ + +DLL_API signed char F_API FSOUND_Reverb_SetProperties(const FSOUND_REVERB_PROPERTIES *prop); +DLL_API signed char F_API FSOUND_Reverb_GetProperties(FSOUND_REVERB_PROPERTIES *prop); +DLL_API signed char F_API FSOUND_Reverb_SetChannelProperties(int channel, const FSOUND_REVERB_CHANNELPROPERTIES *prop); +DLL_API signed char F_API FSOUND_Reverb_GetChannelProperties(int channel, FSOUND_REVERB_CHANNELPROPERTIES *prop); + +/* ===================================================== */ +/* Recording functions (ONLY SUPPORTED IN WIN32, WINCE) */ +/* ===================================================== */ + +/* + Recording initialization functions +*/ + +DLL_API signed char F_API FSOUND_Record_SetDriver(int outputtype); +DLL_API int F_API FSOUND_Record_GetNumDrivers(); +DLL_API const char * F_API FSOUND_Record_GetDriverName(int id); +DLL_API int F_API FSOUND_Record_GetDriver(); + +/* + Recording functionality. Only one recording session will work at a time. +*/ + +DLL_API signed char F_API FSOUND_Record_StartSample(FSOUND_SAMPLE *sptr, signed char loop); +DLL_API signed char F_API FSOUND_Record_Stop(); +DLL_API int F_API FSOUND_Record_GetPosition(); + +/* ========================================================================================== */ +/* FMUSIC API (MOD,S3M,XM,IT,MIDI PLAYBACK) */ +/* ========================================================================================== */ + +/* + Song management / playback functions. +*/ + +DLL_API FMUSIC_MODULE * F_API FMUSIC_LoadSong(const char *name); +DLL_API FMUSIC_MODULE * F_API FMUSIC_LoadSongEx(const char *name_or_data, int offset, int length, unsigned int mode, const int *samplelist, int samplelistnum); +DLL_API int F_API FMUSIC_GetOpenState(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_FreeSong(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_PlaySong(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_StopSong(FMUSIC_MODULE *mod); +DLL_API void F_API FMUSIC_StopAllSongs(); + +DLL_API signed char F_API FMUSIC_SetZxxCallback(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback); +DLL_API signed char F_API FMUSIC_SetRowCallback(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int rowstep); +DLL_API signed char F_API FMUSIC_SetOrderCallback(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int orderstep); +DLL_API signed char F_API FMUSIC_SetInstCallback(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int instrument); + +DLL_API signed char F_API FMUSIC_SetSample(FMUSIC_MODULE *mod, int sampno, FSOUND_SAMPLE *sptr); +DLL_API signed char F_API FMUSIC_SetUserData(FMUSIC_MODULE *mod, void *userdata); +DLL_API signed char F_API FMUSIC_OptimizeChannels(FMUSIC_MODULE *mod, int maxchannels, int minvolume); + +/* + Runtime song functions. +*/ + +DLL_API signed char F_API FMUSIC_SetReverb(signed char reverb); /* MIDI only */ +DLL_API signed char F_API FMUSIC_SetLooping(FMUSIC_MODULE *mod, signed char looping); +DLL_API signed char F_API FMUSIC_SetOrder(FMUSIC_MODULE *mod, int order); +DLL_API signed char F_API FMUSIC_SetPaused(FMUSIC_MODULE *mod, signed char pause); +DLL_API signed char F_API FMUSIC_SetMasterVolume(FMUSIC_MODULE *mod, int volume); +DLL_API signed char F_API FMUSIC_SetMasterSpeed(FMUSIC_MODULE *mode, float speed); +DLL_API signed char F_API FMUSIC_SetPanSeperation(FMUSIC_MODULE *mod, float pansep); + +/* + Static song information functions. +*/ + +DLL_API const char * F_API FMUSIC_GetName(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetType(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumOrders(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumPatterns(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumInstruments(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumSamples(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetNumChannels(FMUSIC_MODULE *mod); +DLL_API FSOUND_SAMPLE * F_API FMUSIC_GetSample(FMUSIC_MODULE *mod, int sampno); +DLL_API int F_API FMUSIC_GetPatternLength(FMUSIC_MODULE *mod, int orderno); + +/* + Runtime song information. +*/ + +DLL_API signed char F_API FMUSIC_IsFinished(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_IsPlaying(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetMasterVolume(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetGlobalVolume(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetOrder(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetPattern(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetSpeed(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetBPM(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetRow(FMUSIC_MODULE *mod); +DLL_API signed char F_API FMUSIC_GetPaused(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetTime(FMUSIC_MODULE *mod); +DLL_API int F_API FMUSIC_GetRealChannel(FMUSIC_MODULE *mod, int modchannel); +DLL_API void * F_API FMUSIC_GetUserData(FMUSIC_MODULE *mod); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/fmodapi375win/api/inc/fmod_errors.h b/lib/fmodapi375win/api/inc/fmod_errors.h new file mode 100644 index 0000000..b28b9c4 --- /dev/null +++ b/lib/fmodapi375win/api/inc/fmod_errors.h @@ -0,0 +1,32 @@ +#ifndef _FMOD_ERRORS_H +#define _FMOD_ERRORS_H + +static char *FMOD_ErrorString(int errcode) +{ + switch (errcode) + { + case FMOD_ERR_NONE: return "No errors"; + case FMOD_ERR_BUSY: return "Cannot call this command after FSOUND_Init. Call FSOUND_Close first."; + case FMOD_ERR_UNINITIALIZED: return "This command failed because FSOUND_Init was not called"; + case FMOD_ERR_PLAY: return "Playing the sound failed."; + case FMOD_ERR_INIT: return "Error initializing output device."; + case FMOD_ERR_ALLOCATED: return "The output device is already in use and cannot be reused."; + case FMOD_ERR_OUTPUT_FORMAT: return "Soundcard does not support the features needed for this soundsystem (16bit stereo output)"; + case FMOD_ERR_COOPERATIVELEVEL: return "Error setting cooperative level for hardware."; + case FMOD_ERR_CREATEBUFFER: return "Error creating hardware sound buffer."; + case FMOD_ERR_FILE_NOTFOUND: return "File not found"; + case FMOD_ERR_FILE_FORMAT: return "Unknown file format"; + case FMOD_ERR_FILE_BAD: return "Error loading file"; + case FMOD_ERR_MEMORY: return "Not enough memory "; + case FMOD_ERR_VERSION: return "The version number of this file format is not supported"; + case FMOD_ERR_INVALID_PARAM: return "An invalid parameter was passed to this function"; + case FMOD_ERR_NO_EAX: return "Tried to use an EAX command on a non EAX enabled channel or output."; + case FMOD_ERR_CHANNEL_ALLOC: return "Failed to allocate a new channel"; + case FMOD_ERR_RECORD: return "Recording not supported on this device"; + case FMOD_ERR_MEDIAPLAYER: return "Required Mediaplayer codec is not installed"; + + default : return "Unknown error"; + }; +} + +#endif diff --git a/lib/fmodapi375win/api/inc/fmoddyn.h b/lib/fmodapi375win/api/inc/fmoddyn.h new file mode 100644 index 0000000..4d5e38e --- /dev/null +++ b/lib/fmodapi375win/api/inc/fmoddyn.h @@ -0,0 +1,546 @@ +/* =========================================================================================== */ +/* FMOD Dynamic DLL loading header. Copyright (c), Firelight Technologies Pty, Ltd. 1999-2004. */ +/* =========================================================================================== */ + +#ifndef _FMODDYN_H_ +#define _FMODDYN_H_ + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) + #include +#else + #include + #include +#endif +#include + +#include "fmod.h" + +typedef struct +{ + void *module; + + signed char (F_API *FSOUND_SetOutput)(int outputtype); + signed char (F_API *FSOUND_SetDriver)(int driver); + signed char (F_API *FSOUND_SetMixer)(int mixer); + signed char (F_API *FSOUND_SetBufferSize)(int len_ms); + signed char (F_API *FSOUND_SetHWND)(void *hwnd); + signed char (F_API *FSOUND_SetMinHardwareChannels)(int min); + signed char (F_API *FSOUND_SetMaxHardwareChannels)(int max); + signed char (F_API *FSOUND_SetMemorySystem)(void *pool, int poollen, FSOUND_ALLOCCALLBACK useralloc, FSOUND_REALLOCCALLBACK userrealloc, FSOUND_FREECALLBACK userfree); + signed char (F_API *FSOUND_Init)(int mixrate, int maxsoftwarechannels, unsigned int flags); + void (F_API *FSOUND_Close)(); + void (F_API *FSOUND_Update)(); /* you must call this once a frame */ + void (F_API *FSOUND_SetSpeakerMode)(unsigned int speakermode); + void (F_API *FSOUND_SetSFXMasterVolume)(int volume); + void (F_API *FSOUND_SetPanSeperation)(float pansep); + void (F_API *FSOUND_File_SetCallbacks)(FSOUND_OPENCALLBACK useropen, FSOUND_CLOSECALLBACK userclose, FSOUND_READCALLBACK userread, FSOUND_SEEKCALLBACK userseek, FSOUND_TELLCALLBACK usertell); + int (F_API *FSOUND_GetError)(); + float (F_API *FSOUND_GetVersion)(); + int (F_API *FSOUND_GetOutput)(); + void * (F_API *FSOUND_GetOutputHandle)(); + int (F_API *FSOUND_GetDriver)(); + int (F_API *FSOUND_GetMixer)(); + int (F_API *FSOUND_GetNumDrivers)(); + const char * (F_API *FSOUND_GetDriverName)(int id); + signed char (F_API *FSOUND_GetDriverCaps)(int id, unsigned int *caps); + int (F_API *FSOUND_GetOutputRate)(); + int (F_API *FSOUND_GetMaxChannels)(); + int (F_API *FSOUND_GetMaxSamples)(); + unsigned int (F_API *FSOUND_GetSpeakerMode)(); + int (F_API *FSOUND_GetSFXMasterVolume)(); + signed char (F_API *FSOUND_GetNumHWChannels)(int *num2d, int *num3d, int *total); + int (F_API *FSOUND_GetChannelsPlaying)(); + float (F_API *FSOUND_GetCPUUsage)(); + void (F_API *FSOUND_GetMemoryStats)(unsigned int *currentalloced, unsigned int *maxalloced); + FSOUND_SAMPLE * (F_API *FSOUND_Sample_Load)(int index, const char *name_or_data, unsigned int mode, int offset, int length); + FSOUND_SAMPLE * (F_API *FSOUND_Sample_Alloc)(int index, int length, unsigned int mode, int deffreq, int defvol, int defpan, int defpri); + void (F_API *FSOUND_Sample_Free)(FSOUND_SAMPLE *sptr); + signed char (F_API *FSOUND_Sample_Upload)(FSOUND_SAMPLE *sptr, void *srcdata, unsigned int mode); + signed char (F_API *FSOUND_Sample_Lock)(FSOUND_SAMPLE *sptr, int offset, int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2); + signed char (F_API *FSOUND_Sample_Unlock)(FSOUND_SAMPLE *sptr, void *ptr1, void *ptr2, unsigned int len1, unsigned int len2); + signed char (F_API *FSOUND_Sample_SetMode)(FSOUND_SAMPLE *sptr, unsigned int mode); + signed char (F_API *FSOUND_Sample_SetLoopPoints)(FSOUND_SAMPLE *sptr, int loopstart, int loopend); + signed char (F_API *FSOUND_Sample_SetDefaults)(FSOUND_SAMPLE *sptr, int deffreq, int defvol, int defpan, int defpri); + signed char (F_API *FSOUND_Sample_SetDefaultsEx)(FSOUND_SAMPLE *sptr, int deffreq, int defvol, int defpan, int defpri, int varfreq, int varvol, int varpan); + signed char (F_API *FSOUND_Sample_SetMinMaxDistance)(FSOUND_SAMPLE *sptr, float min, float max); + signed char (F_API *FSOUND_Sample_SetMaxPlaybacks)(FSOUND_SAMPLE *sptr, int max); + FSOUND_SAMPLE * (F_API *FSOUND_Sample_Get)(int sampno); + const char * (F_API *FSOUND_Sample_GetName)(FSOUND_SAMPLE *sptr); + unsigned int (F_API *FSOUND_Sample_GetLength)(FSOUND_SAMPLE *sptr); + signed char (F_API *FSOUND_Sample_GetLoopPoints)(FSOUND_SAMPLE *sptr, int *loopstart, int *loopend); + signed char (F_API *FSOUND_Sample_GetDefaults)(FSOUND_SAMPLE *sptr, int *deffreq, int *defvol, int *defpan, int *defpri); + signed char (F_API *FSOUND_Sample_GetDefaultsEx)(FSOUND_SAMPLE *sptr, int *deffreq, int *defvol, int *defpan, int *defpri, int *varfreq, int *varvol, int *varpan); + unsigned int (F_API *FSOUND_Sample_GetMode)(FSOUND_SAMPLE *sptr); + signed char (F_API *FSOUND_Sample_GetMinMaxDistance)(FSOUND_SAMPLE *sptr, float *min, float *max); + int (F_API *FSOUND_PlaySound)(int channel, FSOUND_SAMPLE *sptr); + int (F_API *FSOUND_PlaySoundEx)(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); + signed char (F_API *FSOUND_StopSound)(int channel); + signed char (F_API *FSOUND_SetFrequency)(int channel, int freq); + signed char (F_API *FSOUND_SetVolume)(int channel, int vol); + signed char (F_API *FSOUND_SetVolumeAbsolute)(int channel, int vol); + signed char (F_API *FSOUND_SetPan)(int channel, int pan); + signed char (F_API *FSOUND_SetSurround)(int channel, signed char surround); + signed char (F_API *FSOUND_SetMute)(int channel, signed char mute); + signed char (F_API *FSOUND_SetPriority)(int channel, int priority); + signed char (F_API *FSOUND_SetReserved)(int channel, signed char reserved); + signed char (F_API *FSOUND_SetPaused)(int channel, signed char paused); + signed char (F_API *FSOUND_SetLoopMode)(int channel, unsigned int loopmode); + signed char (F_API *FSOUND_SetCurrentPosition)(int channel, unsigned int offset); + signed char (F_API *FSOUND_3D_SetAttributes)(int channel, const float *pos, const float *vel); + signed char (F_API *FSOUND_3D_SetMinMaxDistance)(int channel, float min, float max); + signed char (F_API *FSOUND_IsPlaying)(int channel); + int (F_API *FSOUND_GetFrequency)(int channel); + int (F_API *FSOUND_GetVolume)(int channel); + int (F_API *FSOUND_GetAmplitude)(int channel); + int (F_API *FSOUND_GetPan)(int channel); + signed char (F_API *FSOUND_GetSurround)(int channel); + signed char (F_API *FSOUND_GetMute)(int channel); + int (F_API *FSOUND_GetPriority)(int channel); + signed char (F_API *FSOUND_GetReserved)(int channel); + signed char (F_API *FSOUND_GetPaused)(int channel); + unsigned int (F_API *FSOUND_GetLoopMode)(int channel); + unsigned int (F_API *FSOUND_GetCurrentPosition)(int channel); + FSOUND_SAMPLE * (F_API *FSOUND_GetCurrentSample)(int channel); + signed char (F_API *FSOUND_GetCurrentLevels)(int channel, float *l, float *r); + int (F_API *FSOUND_GetNumSubChannels)(int channel); + int (F_API *FSOUND_GetSubChannel)(int channel, int subchannel); + signed char (F_API *FSOUND_3D_GetAttributes)(int channel, float *pos, float *vel); + signed char (F_API *FSOUND_3D_GetMinMaxDistance)(int channel, float *min, float *max); + void (F_API *FSOUND_3D_SetDopplerFactor)(float scale); + void (F_API *FSOUND_3D_SetDistanceFactor)(float scale); + void (F_API *FSOUND_3D_SetRolloffFactor)(float scale); + void (F_API *FSOUND_3D_Listener_SetCurrent)(int current, int numlisteners); /* use this if you use multiple listeners / splitscreen */ + void (F_API *FSOUND_3D_Listener_SetAttributes)(const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz); + void (F_API *FSOUND_3D_Listener_GetAttributes)(float *pos, float *vel, float *fx, float *fy, float *fz, float *tx, float *ty, float *tz); + int (F_API *FSOUND_FX_Enable)(int channel, unsigned int fx); /* See FSOUND_FX_MODES */ + signed char (F_API *FSOUND_FX_Disable)(int channel); + signed char (F_API *FSOUND_FX_SetChorus)(int fxid, float WetDryMix, float Depth, float Feedback, float Frequency, int Waveform, float Delay, int Phase); + signed char (F_API *FSOUND_FX_SetCompressor)(int fxid, float Gain, float Attack, float Release, float Threshold, float Ratio, float Predelay); + signed char (F_API *FSOUND_FX_SetDistortion)(int fxid, float Gain, float Edge, float PostEQCenterFrequency, float PostEQBandwidth, float PreLowpassCutoff); + signed char (F_API *FSOUND_FX_SetEcho)(int fxid, float WetDryMix, float Feedback, float LeftDelay, float RightDelay, int PanDelay); + signed char (F_API *FSOUND_FX_SetFlanger)(int fxid, float WetDryMix, float Depth, float Feedback, float Frequency, int Waveform, float Delay, int Phase); + signed char (F_API *FSOUND_FX_SetGargle)(int fxid, int RateHz, int WaveShape); + signed char (F_API *FSOUND_FX_SetI3DL2Reverb)(int fxid, int Room, int RoomHF, float RoomRolloffFactor, float DecayTime, float DecayHFRatio, int Reflections, float ReflectionsDelay, int Reverb, float ReverbDelay, float Diffusion, float Density, float HFReference); + signed char (F_API *FSOUND_FX_SetParamEQ)(int fxid, float Center, float Bandwidth, float Gain); + signed char (F_API *FSOUND_FX_SetWavesReverb)(int fxid, float InGain, float ReverbMix, float ReverbTime, float HighFreqRTRatio); + signed char (F_API *FSOUND_Stream_SetBufferSize)(int ms); /* call this before opening streams, not after */ + FSOUND_STREAM * (F_API *FSOUND_Stream_Open)(const char *name_or_data, unsigned int mode, int offset, int length); + FSOUND_STREAM * (F_API *FSOUND_Stream_Create)(FSOUND_STREAMCALLBACK callback, int length, unsigned int mode, int samplerate, void *userdata); + signed char (F_API *FSOUND_Stream_Close)(FSOUND_STREAM *stream); + int (F_API *FSOUND_Stream_Play)(int channel, FSOUND_STREAM *stream); + int (F_API *FSOUND_Stream_PlayEx)(int channel, FSOUND_STREAM *stream, FSOUND_DSPUNIT *dsp, signed char startpaused); + signed char (F_API *FSOUND_Stream_Stop)(FSOUND_STREAM *stream); + signed char (F_API *FSOUND_Stream_SetPosition)(FSOUND_STREAM *stream, unsigned int position); + unsigned int (F_API *FSOUND_Stream_GetPosition)(FSOUND_STREAM *stream); + signed char (F_API *FSOUND_Stream_SetTime)(FSOUND_STREAM *stream, int ms); + int (F_API *FSOUND_Stream_GetTime)(FSOUND_STREAM *stream); + int (F_API *FSOUND_Stream_GetLength)(FSOUND_STREAM *stream); + int (F_API *FSOUND_Stream_GetLengthMs)(FSOUND_STREAM *stream); + signed char (F_API *FSOUND_Stream_SetMode)(FSOUND_STREAM *stream, unsigned int mode); + unsigned int (F_API *FSOUND_Stream_GetMode)(FSOUND_STREAM *stream); + signed char (F_API *FSOUND_Stream_SetLoopPoints)(FSOUND_STREAM *stream, unsigned int loopstartpcm, unsigned int loopendpcm); + signed char (F_API *FSOUND_Stream_SetLoopCount)(FSOUND_STREAM *stream, int count); + int (F_API *FSOUND_Stream_GetOpenState)(FSOUND_STREAM *stream); + FSOUND_SAMPLE * (F_API *FSOUND_Stream_GetSample)(FSOUND_STREAM *stream); /* every stream contains a sample to playback on */ + FSOUND_DSPUNIT * (F_API *FSOUND_Stream_CreateDSP)(FSOUND_STREAM *stream, FSOUND_DSPCALLBACK callback, int priority, void *userdata); + signed char (F_API *FSOUND_Stream_SetEndCallback)(FSOUND_STREAM *stream, FSOUND_STREAMCALLBACK callback, void *userdata); + signed char (F_API *FSOUND_Stream_SetSyncCallback)(FSOUND_STREAM *stream, FSOUND_STREAMCALLBACK callback, void *userdata); + FSOUND_SYNCPOINT *(F_API *FSOUND_Stream_AddSyncPoint)(FSOUND_STREAM *stream, unsigned int pcmoffset, const char *name); + signed char (F_API *FSOUND_Stream_DeleteSyncPoint)(FSOUND_SYNCPOINT *point); + int (F_API *FSOUND_Stream_GetNumSyncPoints)(FSOUND_STREAM *stream); + FSOUND_SYNCPOINT *(F_API *FSOUND_Stream_GetSyncPoint)(FSOUND_STREAM *stream, int index); + char * (F_API *FSOUND_Stream_GetSyncPointInfo)(FSOUND_SYNCPOINT *point, unsigned int *pcmoffset); + signed char (F_API *FSOUND_Stream_SetSubStream)(FSOUND_STREAM *stream, int index); + int (F_API *FSOUND_Stream_GetNumSubStreams)(FSOUND_STREAM *stream); + signed char (F_API *FSOUND_Stream_SetSubStreamSentence)(FSOUND_STREAM *stream, const int *sentencelist, int numitems); + signed char (F_API *FSOUND_Stream_GetNumTagFields)(FSOUND_STREAM *stream, int *num); + signed char (F_API *FSOUND_Stream_GetTagField)(FSOUND_STREAM *stream, int num, int *type, char **name, void **value, int *length); + signed char (F_API *FSOUND_Stream_FindTagField)(FSOUND_STREAM *stream, int type, const char *name, void **value, int *length); + signed char (F_API *FSOUND_Stream_Net_SetProxy)(const char *proxy); + signed char (F_API *FSOUND_Stream_Net_SetTimeout)(int timeout); + char * (F_API *FSOUND_Stream_Net_GetLastServerStatus)(); + signed char (F_API *FSOUND_Stream_Net_SetBufferProperties)(int buffersize, int prebuffer_percent, int rebuffer_percent); + signed char (F_API *FSOUND_Stream_Net_GetBufferProperties)(int *buffersize, int *prebuffer_percent, int *rebuffer_percent); + signed char (F_API *FSOUND_Stream_Net_SetMetadataCallback)(FSOUND_STREAM *stream, FSOUND_METADATACALLBACK callback, void *userdata); + signed char (F_API *FSOUND_Stream_Net_GetStatus)(FSOUND_STREAM *stream, int *status, int *bufferpercentused, int *bitrate, unsigned int *flags); + signed char (F_API *FSOUND_CD_Play)(char drive, int track); + void (F_API *FSOUND_CD_SetPlayMode)(char drive, signed char mode); + signed char (F_API *FSOUND_CD_Stop)(char drive); + signed char (F_API *FSOUND_CD_SetPaused)(char drive, signed char paused); + signed char (F_API *FSOUND_CD_SetVolume)(char drive, int volume); + signed char (F_API *FSOUND_CD_SetTrackTime)(char drive, unsigned int ms); + signed char (F_API *FSOUND_CD_OpenTray)(char drive, signed char open); + signed char (F_API *FSOUND_CD_GetPaused)(char drive); + int (F_API *FSOUND_CD_GetTrack)(char drive); + int (F_API *FSOUND_CD_GetNumTracks)(char drive); + int (F_API *FSOUND_CD_GetVolume)(char drive); + int (F_API *FSOUND_CD_GetTrackLength)(char drive, int track); + int (F_API *FSOUND_CD_GetTrackTime)(char drive); + FSOUND_DSPUNIT * (F_API *FSOUND_DSP_Create)(FSOUND_DSPCALLBACK callback, int priority, void *userdata); + void (F_API *FSOUND_DSP_Free)(FSOUND_DSPUNIT *unit); + void (F_API *FSOUND_DSP_SetPriority)(FSOUND_DSPUNIT *unit, int priority); + int (F_API *FSOUND_DSP_GetPriority)(FSOUND_DSPUNIT *unit); + void (F_API *FSOUND_DSP_SetActive)(FSOUND_DSPUNIT *unit, signed char active); + signed char (F_API *FSOUND_DSP_GetActive)(FSOUND_DSPUNIT *unit); + FSOUND_DSPUNIT * (F_API *FSOUND_DSP_GetClearUnit)(); + FSOUND_DSPUNIT * (F_API *FSOUND_DSP_GetSFXUnit)(); + FSOUND_DSPUNIT * (F_API *FSOUND_DSP_GetMusicUnit)(); + FSOUND_DSPUNIT * (F_API *FSOUND_DSP_GetFFTUnit)(); + FSOUND_DSPUNIT * (F_API *FSOUND_DSP_GetClipAndCopyUnit)(); + signed char (F_API *FSOUND_DSP_MixBuffers)(void *destbuffer, void *srcbuffer, int len, int freq, int vol, int pan, unsigned int mode); + void (F_API *FSOUND_DSP_ClearMixBuffer)(); + int (F_API *FSOUND_DSP_GetBufferLength)(); /* Length of each DSP update */ + int (F_API *FSOUND_DSP_GetBufferLengthTotal)(); /* Total buffer length due to FSOUND_SetBufferSize */ + float * (F_API *FSOUND_DSP_GetSpectrum)(); /* Array of 512 floats - call FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE)) for this to work. */ + signed char (F_API *FSOUND_Reverb_SetProperties)(const FSOUND_REVERB_PROPERTIES *prop); + signed char (F_API *FSOUND_Reverb_GetProperties)(FSOUND_REVERB_PROPERTIES *prop); + signed char (F_API *FSOUND_Reverb_SetChannelProperties)(int channel, const FSOUND_REVERB_CHANNELPROPERTIES *prop); + signed char (F_API *FSOUND_Reverb_GetChannelProperties)(int channel, FSOUND_REVERB_CHANNELPROPERTIES *prop); + signed char (F_API *FSOUND_Record_SetDriver)(int outputtype); + int (F_API *FSOUND_Record_GetNumDrivers)(); + const char * (F_API *FSOUND_Record_GetDriverName)(int id); + int (F_API *FSOUND_Record_GetDriver)(); + signed char (F_API *FSOUND_Record_StartSample)(FSOUND_SAMPLE *sptr, signed char loop); + signed char (F_API *FSOUND_Record_Stop)(); + int (F_API *FSOUND_Record_GetPosition)(); + FMUSIC_MODULE * (F_API *FMUSIC_LoadSong)(const char *name); + FMUSIC_MODULE * (F_API *FMUSIC_LoadSongEx)(const char *name_or_data, int offset, int length, unsigned int mode, const int *samplelist, int samplelistnum); + int (F_API *FMUSIC_GetOpenState)(FMUSIC_MODULE *mod); + signed char (F_API *FMUSIC_FreeSong)(FMUSIC_MODULE *mod); + signed char (F_API *FMUSIC_PlaySong)(FMUSIC_MODULE *mod); + signed char (F_API *FMUSIC_StopSong)(FMUSIC_MODULE *mod); + void (F_API *FMUSIC_StopAllSongs)(); + signed char (F_API *FMUSIC_SetZxxCallback)(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback); + signed char (F_API *FMUSIC_SetRowCallback)(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int rowstep); + signed char (F_API *FMUSIC_SetOrderCallback)(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int orderstep); + signed char (F_API *FMUSIC_SetInstCallback)(FMUSIC_MODULE *mod, FMUSIC_CALLBACK callback, int instrument); + signed char (F_API *FMUSIC_SetSample)(FMUSIC_MODULE *mod, int sampno, FSOUND_SAMPLE *sptr); + signed char (F_API *FMUSIC_SetUserData)(FMUSIC_MODULE *mod, void *userdata); + signed char (F_API *FMUSIC_OptimizeChannels)(FMUSIC_MODULE *mod, int maxchannels, int minvolume); + signed char (F_API *FMUSIC_SetReverb)(signed char reverb); /* MIDI only */ + signed char (F_API *FMUSIC_SetLooping)(FMUSIC_MODULE *mod, signed char looping); + signed char (F_API *FMUSIC_SetOrder)(FMUSIC_MODULE *mod, int order); + signed char (F_API *FMUSIC_SetPaused)(FMUSIC_MODULE *mod, signed char pause); + signed char (F_API *FMUSIC_SetMasterVolume)(FMUSIC_MODULE *mod, int volume); + signed char (F_API *FMUSIC_SetMasterSpeed)(FMUSIC_MODULE *mode, float speed); + signed char (F_API *FMUSIC_SetPanSeperation)(FMUSIC_MODULE *mod, float pansep); + const char * (F_API *FMUSIC_GetName)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetType)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetNumOrders)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetNumPatterns)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetNumInstruments)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetNumSamples)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetNumChannels)(FMUSIC_MODULE *mod); + FSOUND_SAMPLE * (F_API *FMUSIC_GetSample)(FMUSIC_MODULE *mod, int sampno); + int (F_API *FMUSIC_GetPatternLength)(FMUSIC_MODULE *mod, int orderno); + signed char (F_API *FMUSIC_IsFinished)(FMUSIC_MODULE *mod); + signed char (F_API *FMUSIC_IsPlaying)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetMasterVolume)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetGlobalVolume)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetOrder)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetPattern)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetSpeed)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetBPM)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetRow)(FMUSIC_MODULE *mod); + signed char (F_API *FMUSIC_GetPaused)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetTime)(FMUSIC_MODULE *mod); + int (F_API *FMUSIC_GetRealChannel)(FMUSIC_MODULE *mod, int modchannel); + unsigned int (F_API *FMUSIC_GetUserData)(FMUSIC_MODULE *mod); +} FMOD_INSTANCE; + + +static FMOD_INSTANCE *FMOD_CreateInstance(char *dllName) +{ + FMOD_INSTANCE *instance; + + instance = (FMOD_INSTANCE *)calloc(sizeof(FMOD_INSTANCE), 1); + if (!instance) + { + return NULL; + } + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) + instance->module = LoadLibrary(dllName); +#else + instance->module = dlopen(dllName, RTLD_LAZY); +#endif + if (!instance->module) + { + free(instance); + return NULL; + } + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) + #define F_GETPROC(_x, _y) \ + { \ + *((unsigned int *)&instance->_x) = (unsigned int)GetProcAddress((HMODULE)instance->module, _y); \ + if (!instance->_x) \ + { \ + FreeLibrary((HMODULE)instance->module); \ + free(instance); \ + return NULL; \ + } \ + } +#else + #define F_GETPROC(_x, _y) \ + { \ + char tmp[] = _y; \ + *(strchr(tmp, '@')) = 0; \ + *((unsigned int *)&instance->_x) = (unsigned int)dlsym(instance->module, &tmp[1]); \ + if (!instance->_x) \ + { \ + dlclose(instance->module); \ + free(instance); \ + return NULL; \ + } \ + } +#endif + + F_GETPROC(FSOUND_SetOutput, "_FSOUND_SetOutput@4"); + F_GETPROC(FSOUND_SetDriver, "_FSOUND_SetDriver@4"); + F_GETPROC(FSOUND_SetMixer, "_FSOUND_SetMixer@4"); + F_GETPROC(FSOUND_SetBufferSize, "_FSOUND_SetBufferSize@4"); + F_GETPROC(FSOUND_SetHWND, "_FSOUND_SetHWND@4"); + F_GETPROC(FSOUND_SetMinHardwareChannels, "_FSOUND_SetMinHardwareChannels@4"); + F_GETPROC(FSOUND_SetMaxHardwareChannels, "_FSOUND_SetMaxHardwareChannels@4"); + F_GETPROC(FSOUND_SetMemorySystem, "_FSOUND_SetMemorySystem@20"); + F_GETPROC(FSOUND_Init, "_FSOUND_Init@12"); + F_GETPROC(FSOUND_Close, "_FSOUND_Close@0"); + F_GETPROC(FSOUND_Update, "_FSOUND_Update@0"); + F_GETPROC(FSOUND_SetSFXMasterVolume, "_FSOUND_SetSFXMasterVolume@4"); + F_GETPROC(FSOUND_SetPanSeperation, "_FSOUND_SetPanSeperation@4"); + F_GETPROC(FSOUND_SetSpeakerMode, "_FSOUND_SetSpeakerMode@4"); + F_GETPROC(FSOUND_GetError, "_FSOUND_GetError@0"); + F_GETPROC(FSOUND_GetVersion, "_FSOUND_GetVersion@0"); + F_GETPROC(FSOUND_GetOutput, "_FSOUND_GetOutput@0"); + F_GETPROC(FSOUND_GetOutputHandle, "_FSOUND_GetOutputHandle@0"); + F_GETPROC(FSOUND_GetDriver, "_FSOUND_GetDriver@0"); + F_GETPROC(FSOUND_GetMixer, "_FSOUND_GetMixer@0"); + F_GETPROC(FSOUND_GetNumDrivers, "_FSOUND_GetNumDrivers@0"); + F_GETPROC(FSOUND_GetDriverName, "_FSOUND_GetDriverName@4"); + F_GETPROC(FSOUND_GetDriverCaps, "_FSOUND_GetDriverCaps@8"); + F_GETPROC(FSOUND_GetOutputRate, "_FSOUND_GetOutputRate@0"); + F_GETPROC(FSOUND_GetMaxChannels, "_FSOUND_GetMaxChannels@0"); + F_GETPROC(FSOUND_GetMaxSamples, "_FSOUND_GetMaxSamples@0"); + F_GETPROC(FSOUND_GetSpeakerMode, "_FSOUND_GetSpeakerMode@0"); + F_GETPROC(FSOUND_GetSFXMasterVolume, "_FSOUND_GetSFXMasterVolume@0"); + F_GETPROC(FSOUND_GetNumHWChannels, "_FSOUND_GetNumHWChannels@12"); + F_GETPROC(FSOUND_GetChannelsPlaying, "_FSOUND_GetChannelsPlaying@0"); + F_GETPROC(FSOUND_GetCPUUsage, "_FSOUND_GetCPUUsage@0"); + F_GETPROC(FSOUND_GetMemoryStats, "_FSOUND_GetMemoryStats@8"); + F_GETPROC(FSOUND_Sample_Load, "_FSOUND_Sample_Load@20"); + F_GETPROC(FSOUND_Sample_Alloc, "_FSOUND_Sample_Alloc@28"); + F_GETPROC(FSOUND_Sample_Free, "_FSOUND_Sample_Free@4"); + F_GETPROC(FSOUND_Sample_Upload, "_FSOUND_Sample_Upload@12"); + F_GETPROC(FSOUND_Sample_Lock, "_FSOUND_Sample_Lock@28"); + F_GETPROC(FSOUND_Sample_Unlock, "_FSOUND_Sample_Unlock@20"); + F_GETPROC(FSOUND_Sample_SetMode, "_FSOUND_Sample_SetMode@8"); + F_GETPROC(FSOUND_Sample_SetLoopPoints, "_FSOUND_Sample_SetLoopPoints@12"); + F_GETPROC(FSOUND_Sample_SetDefaults, "_FSOUND_Sample_SetDefaults@20"); + F_GETPROC(FSOUND_Sample_SetDefaultsEx, "_FSOUND_Sample_SetDefaultsEx@32"); + F_GETPROC(FSOUND_Sample_SetMinMaxDistance, "_FSOUND_Sample_SetMinMaxDistance@12"); + F_GETPROC(FSOUND_Sample_SetMaxPlaybacks, "_FSOUND_Sample_SetMaxPlaybacks@8"); + F_GETPROC(FSOUND_Sample_Get, "_FSOUND_Sample_Get@4"); + F_GETPROC(FSOUND_Sample_GetName, "_FSOUND_Sample_GetName@4"); + F_GETPROC(FSOUND_Sample_GetLength, "_FSOUND_Sample_GetLength@4"); + F_GETPROC(FSOUND_Sample_GetLoopPoints, "_FSOUND_Sample_GetLoopPoints@12"); + F_GETPROC(FSOUND_Sample_GetDefaults, "_FSOUND_Sample_GetDefaults@20"); + F_GETPROC(FSOUND_Sample_GetDefaultsEx, "_FSOUND_Sample_GetDefaultsEx@32"); + F_GETPROC(FSOUND_Sample_GetMode, "_FSOUND_Sample_GetMode@4"); + F_GETPROC(FSOUND_Sample_GetMinMaxDistance, "_FSOUND_Sample_GetMinMaxDistance@12"); + F_GETPROC(FSOUND_PlaySound, "_FSOUND_PlaySound@8"); + F_GETPROC(FSOUND_PlaySoundEx, "_FSOUND_PlaySoundEx@16"); + F_GETPROC(FSOUND_StopSound, "_FSOUND_StopSound@4"); + F_GETPROC(FSOUND_SetFrequency, "_FSOUND_SetFrequency@8"); + F_GETPROC(FSOUND_SetVolume, "_FSOUND_SetVolume@8"); + F_GETPROC(FSOUND_SetVolumeAbsolute, "_FSOUND_SetVolumeAbsolute@8"); + F_GETPROC(FSOUND_SetPan, "_FSOUND_SetPan@8"); + F_GETPROC(FSOUND_SetSurround, "_FSOUND_SetSurround@8"); + F_GETPROC(FSOUND_SetMute, "_FSOUND_SetMute@8"); + F_GETPROC(FSOUND_SetPriority, "_FSOUND_SetPriority@8"); + F_GETPROC(FSOUND_SetReserved, "_FSOUND_SetReserved@8"); + F_GETPROC(FSOUND_SetPaused, "_FSOUND_SetPaused@8"); + F_GETPROC(FSOUND_SetLoopMode, "_FSOUND_SetLoopMode@8"); + F_GETPROC(FSOUND_SetCurrentPosition, "_FSOUND_SetCurrentPosition@8"); + F_GETPROC(FSOUND_3D_SetAttributes, "_FSOUND_3D_SetAttributes@12"); + F_GETPROC(FSOUND_3D_SetMinMaxDistance, "_FSOUND_3D_SetMinMaxDistance@12"); + F_GETPROC(FSOUND_IsPlaying, "_FSOUND_IsPlaying@4"); + F_GETPROC(FSOUND_GetFrequency, "_FSOUND_GetFrequency@4"); + F_GETPROC(FSOUND_GetVolume, "_FSOUND_GetVolume@4"); + F_GETPROC(FSOUND_GetAmplitude, "_FSOUND_GetAmplitude@4"); + F_GETPROC(FSOUND_GetPan, "_FSOUND_GetPan@4"); + F_GETPROC(FSOUND_GetSurround, "_FSOUND_GetSurround@4"); + F_GETPROC(FSOUND_GetMute, "_FSOUND_GetMute@4"); + F_GETPROC(FSOUND_GetPriority, "_FSOUND_GetPriority@4"); + F_GETPROC(FSOUND_GetReserved, "_FSOUND_GetReserved@4"); + F_GETPROC(FSOUND_GetPaused, "_FSOUND_GetPaused@4"); + F_GETPROC(FSOUND_GetLoopMode, "_FSOUND_GetLoopMode@4"); + F_GETPROC(FSOUND_GetCurrentPosition, "_FSOUND_GetCurrentPosition@4"); + F_GETPROC(FSOUND_GetCurrentSample, "_FSOUND_GetCurrentSample@4"); + F_GETPROC(FSOUND_GetCurrentLevels, "_FSOUND_GetCurrentLevels@12"); + F_GETPROC(FSOUND_GetNumSubChannels, "_FSOUND_GetNumSubChannels@4"); + F_GETPROC(FSOUND_GetSubChannel, "_FSOUND_GetSubChannel@8"); + F_GETPROC(FSOUND_3D_GetAttributes, "_FSOUND_3D_GetAttributes@12"); + F_GETPROC(FSOUND_3D_GetMinMaxDistance, "_FSOUND_3D_GetMinMaxDistance@12"); + F_GETPROC(FSOUND_3D_Listener_SetCurrent, "_FSOUND_3D_Listener_SetCurrent@8"); + F_GETPROC(FSOUND_3D_Listener_SetAttributes, "_FSOUND_3D_Listener_SetAttributes@32"); + F_GETPROC(FSOUND_3D_Listener_GetAttributes, "_FSOUND_3D_Listener_GetAttributes@32"); + F_GETPROC(FSOUND_3D_SetDopplerFactor, "_FSOUND_3D_SetDopplerFactor@4"); + F_GETPROC(FSOUND_3D_SetDistanceFactor, "_FSOUND_3D_SetDistanceFactor@4"); + F_GETPROC(FSOUND_3D_SetRolloffFactor, "_FSOUND_3D_SetRolloffFactor@4"); + F_GETPROC(FSOUND_FX_Enable, "_FSOUND_FX_Enable@8"); + F_GETPROC(FSOUND_FX_Disable, "_FSOUND_FX_Disable@4"); + F_GETPROC(FSOUND_FX_SetChorus, "_FSOUND_FX_SetChorus@32"); + F_GETPROC(FSOUND_FX_SetCompressor, "_FSOUND_FX_SetCompressor@28"); + F_GETPROC(FSOUND_FX_SetDistortion, "_FSOUND_FX_SetDistortion@24"); + F_GETPROC(FSOUND_FX_SetEcho, "_FSOUND_FX_SetEcho@24"); + F_GETPROC(FSOUND_FX_SetFlanger, "_FSOUND_FX_SetFlanger@32"); + F_GETPROC(FSOUND_FX_SetGargle, "_FSOUND_FX_SetGargle@12"); + F_GETPROC(FSOUND_FX_SetI3DL2Reverb, "_FSOUND_FX_SetI3DL2Reverb@52"); + F_GETPROC(FSOUND_FX_SetParamEQ, "_FSOUND_FX_SetParamEQ@16"); + F_GETPROC(FSOUND_FX_SetWavesReverb, "_FSOUND_FX_SetWavesReverb@20"); + F_GETPROC(FSOUND_Stream_Open, "_FSOUND_Stream_Open@16"); + F_GETPROC(FSOUND_Stream_Create, "_FSOUND_Stream_Create@20"); + F_GETPROC(FSOUND_Stream_Play, "_FSOUND_Stream_Play@8"); + F_GETPROC(FSOUND_Stream_PlayEx, "_FSOUND_Stream_PlayEx@16"); + F_GETPROC(FSOUND_Stream_Stop, "_FSOUND_Stream_Stop@4"); + F_GETPROC(FSOUND_Stream_Close, "_FSOUND_Stream_Close@4"); + F_GETPROC(FSOUND_Stream_SetEndCallback, "_FSOUND_Stream_SetEndCallback@12"); + F_GETPROC(FSOUND_Stream_SetSyncCallback, "_FSOUND_Stream_SetSyncCallback@12"); + F_GETPROC(FSOUND_Stream_GetSample, "_FSOUND_Stream_GetSample@4"); + F_GETPROC(FSOUND_Stream_CreateDSP, "_FSOUND_Stream_CreateDSP@16"); + F_GETPROC(FSOUND_Stream_SetBufferSize, "_FSOUND_Stream_SetBufferSize@4"); + F_GETPROC(FSOUND_Stream_SetPosition, "_FSOUND_Stream_SetPosition@8"); + F_GETPROC(FSOUND_Stream_GetPosition, "_FSOUND_Stream_GetPosition@4"); + F_GETPROC(FSOUND_Stream_SetTime, "_FSOUND_Stream_SetTime@8"); + F_GETPROC(FSOUND_Stream_GetTime, "_FSOUND_Stream_GetTime@4"); + F_GETPROC(FSOUND_Stream_GetLength, "_FSOUND_Stream_GetLength@4"); + F_GETPROC(FSOUND_Stream_GetLengthMs, "_FSOUND_Stream_GetLengthMs@4"); + F_GETPROC(FSOUND_Stream_SetMode, "_FSOUND_Stream_SetMode@8"); + F_GETPROC(FSOUND_Stream_GetMode, "_FSOUND_Stream_GetMode@4"); + F_GETPROC(FSOUND_Stream_SetSubStream, "_FSOUND_Stream_SetSubStream@8"); + F_GETPROC(FSOUND_Stream_GetNumSubStreams, "_FSOUND_Stream_GetNumSubStreams@4"); + F_GETPROC(FSOUND_Stream_SetSubStreamSentence, "_FSOUND_Stream_SetSubStreamSentence@12"); + F_GETPROC(FSOUND_Stream_SetLoopPoints, "_FSOUND_Stream_SetLoopPoints@12"); + F_GETPROC(FSOUND_Stream_SetLoopCount, "_FSOUND_Stream_SetLoopCount@8"); + F_GETPROC(FSOUND_Stream_AddSyncPoint, "_FSOUND_Stream_AddSyncPoint@12"); + F_GETPROC(FSOUND_Stream_DeleteSyncPoint, "_FSOUND_Stream_DeleteSyncPoint@4"); + F_GETPROC(FSOUND_Stream_GetNumSyncPoints, "_FSOUND_Stream_GetNumSyncPoints@4"); + F_GETPROC(FSOUND_Stream_GetSyncPoint, "_FSOUND_Stream_GetSyncPoint@8"); + F_GETPROC(FSOUND_Stream_GetSyncPointInfo, "_FSOUND_Stream_GetSyncPointInfo@8"); + F_GETPROC(FSOUND_Stream_GetOpenState, "_FSOUND_Stream_GetOpenState@4"); + F_GETPROC(FSOUND_Stream_GetNumTagFields, "_FSOUND_Stream_GetNumTagFields@8"); + F_GETPROC(FSOUND_Stream_GetTagField, "_FSOUND_Stream_GetTagField@24"); + F_GETPROC(FSOUND_Stream_FindTagField, "_FSOUND_Stream_FindTagField@20"); + F_GETPROC(FSOUND_Stream_Net_SetProxy, "_FSOUND_Stream_Net_SetProxy@4"); + F_GETPROC(FSOUND_Stream_Net_GetLastServerStatus, "_FSOUND_Stream_Net_GetLastServerStatus@0"); + F_GETPROC(FSOUND_Stream_Net_SetBufferProperties, "_FSOUND_Stream_Net_SetBufferProperties@12"); + F_GETPROC(FSOUND_Stream_Net_GetBufferProperties, "_FSOUND_Stream_Net_GetBufferProperties@12"); + F_GETPROC(FSOUND_Stream_Net_SetMetadataCallback, "_FSOUND_Stream_Net_SetMetadataCallback@12"); + F_GETPROC(FSOUND_Stream_Net_GetStatus, "_FSOUND_Stream_Net_GetStatus@20"); + F_GETPROC(FSOUND_CD_Play, "_FSOUND_CD_Play@8"); + F_GETPROC(FSOUND_CD_SetPlayMode, "_FSOUND_CD_SetPlayMode@8"); + F_GETPROC(FSOUND_CD_Stop, "_FSOUND_CD_Stop@4"); + F_GETPROC(FSOUND_CD_SetPaused, "_FSOUND_CD_SetPaused@8"); + F_GETPROC(FSOUND_CD_SetVolume, "_FSOUND_CD_SetVolume@8"); + F_GETPROC(FSOUND_CD_SetTrackTime, "_FSOUND_CD_SetTrackTime@8"); + F_GETPROC(FSOUND_CD_OpenTray, "_FSOUND_CD_OpenTray@8"); + F_GETPROC(FSOUND_CD_GetPaused, "_FSOUND_CD_GetPaused@4"); + F_GETPROC(FSOUND_CD_GetTrack, "_FSOUND_CD_GetTrack@4"); + F_GETPROC(FSOUND_CD_GetNumTracks, "_FSOUND_CD_GetNumTracks@4"); + F_GETPROC(FSOUND_CD_GetVolume, "_FSOUND_CD_GetVolume@4"); + F_GETPROC(FSOUND_CD_GetTrackLength, "_FSOUND_CD_GetTrackLength@8"); + F_GETPROC(FSOUND_CD_GetTrackTime, "_FSOUND_CD_GetTrackTime@4"); + F_GETPROC(FSOUND_DSP_Create, "_FSOUND_DSP_Create@12"); + F_GETPROC(FSOUND_DSP_Free, "_FSOUND_DSP_Free@4"); + F_GETPROC(FSOUND_DSP_SetPriority, "_FSOUND_DSP_SetPriority@8"); + F_GETPROC(FSOUND_DSP_GetPriority, "_FSOUND_DSP_GetPriority@4"); + F_GETPROC(FSOUND_DSP_SetActive, "_FSOUND_DSP_SetActive@8"); + F_GETPROC(FSOUND_DSP_GetActive, "_FSOUND_DSP_GetActive@4"); + F_GETPROC(FSOUND_DSP_GetClearUnit, "_FSOUND_DSP_GetClearUnit@0"); + F_GETPROC(FSOUND_DSP_GetSFXUnit, "_FSOUND_DSP_GetSFXUnit@0"); + F_GETPROC(FSOUND_DSP_GetMusicUnit, "_FSOUND_DSP_GetMusicUnit@0"); + F_GETPROC(FSOUND_DSP_GetClipAndCopyUnit, "_FSOUND_DSP_GetClipAndCopyUnit@0"); + F_GETPROC(FSOUND_DSP_GetFFTUnit, "_FSOUND_DSP_GetFFTUnit@0"); + F_GETPROC(FSOUND_DSP_MixBuffers, "_FSOUND_DSP_MixBuffers@28"); + F_GETPROC(FSOUND_DSP_ClearMixBuffer, "_FSOUND_DSP_ClearMixBuffer@0"); + F_GETPROC(FSOUND_DSP_GetBufferLength, "_FSOUND_DSP_GetBufferLength@0"); + F_GETPROC(FSOUND_DSP_GetBufferLengthTotal, "_FSOUND_DSP_GetBufferLengthTotal@0"); + F_GETPROC(FSOUND_DSP_GetSpectrum, "_FSOUND_DSP_GetSpectrum@0"); + F_GETPROC(FSOUND_Reverb_SetProperties, "_FSOUND_Reverb_SetProperties@4"); + F_GETPROC(FSOUND_Reverb_GetProperties, "_FSOUND_Reverb_GetProperties@4"); + F_GETPROC(FSOUND_Reverb_SetChannelProperties, "_FSOUND_Reverb_SetChannelProperties@8"); + F_GETPROC(FSOUND_Reverb_GetChannelProperties, "_FSOUND_Reverb_GetChannelProperties@8"); + F_GETPROC(FSOUND_Record_SetDriver, "_FSOUND_Record_SetDriver@4"); + F_GETPROC(FSOUND_Record_GetNumDrivers, "_FSOUND_Record_GetNumDrivers@0"); + F_GETPROC(FSOUND_Record_GetDriverName, "_FSOUND_Record_GetDriverName@4"); + F_GETPROC(FSOUND_Record_GetDriver, "_FSOUND_Record_GetDriver@0"); + F_GETPROC(FSOUND_Record_StartSample, "_FSOUND_Record_StartSample@8"); + F_GETPROC(FSOUND_Record_Stop, "_FSOUND_Record_Stop@0"); + F_GETPROC(FSOUND_Record_GetPosition, "_FSOUND_Record_GetPosition@0"); + F_GETPROC(FSOUND_File_SetCallbacks, "_FSOUND_File_SetCallbacks@20"); + F_GETPROC(FMUSIC_LoadSong, "_FMUSIC_LoadSong@4"); + F_GETPROC(FMUSIC_LoadSongEx, "_FMUSIC_LoadSongEx@24"); + F_GETPROC(FMUSIC_GetOpenState, "_FMUSIC_GetOpenState@4"); + F_GETPROC(FMUSIC_FreeSong, "_FMUSIC_FreeSong@4"); + F_GETPROC(FMUSIC_PlaySong, "_FMUSIC_PlaySong@4"); + F_GETPROC(FMUSIC_StopSong, "_FMUSIC_StopSong@4"); + F_GETPROC(FMUSIC_StopAllSongs, "_FMUSIC_StopAllSongs@0"); + F_GETPROC(FMUSIC_SetZxxCallback, "_FMUSIC_SetZxxCallback@8"); + F_GETPROC(FMUSIC_SetRowCallback, "_FMUSIC_SetRowCallback@12"); + F_GETPROC(FMUSIC_SetOrderCallback, "_FMUSIC_SetOrderCallback@12"); + F_GETPROC(FMUSIC_SetInstCallback, "_FMUSIC_SetInstCallback@12"); + F_GETPROC(FMUSIC_SetSample, "_FMUSIC_SetSample@12"); + F_GETPROC(FMUSIC_SetUserData, "_FMUSIC_SetUserData@8"); + F_GETPROC(FMUSIC_OptimizeChannels, "_FMUSIC_OptimizeChannels@12"); + F_GETPROC(FMUSIC_SetReverb, "_FMUSIC_SetReverb@4"); + F_GETPROC(FMUSIC_SetLooping, "_FMUSIC_SetLooping@8"); + F_GETPROC(FMUSIC_SetOrder, "_FMUSIC_SetOrder@8"); + F_GETPROC(FMUSIC_SetPaused, "_FMUSIC_SetPaused@8"); + F_GETPROC(FMUSIC_SetMasterVolume, "_FMUSIC_SetMasterVolume@8"); + F_GETPROC(FMUSIC_SetMasterSpeed, "_FMUSIC_SetMasterSpeed@8"); + F_GETPROC(FMUSIC_SetPanSeperation, "_FMUSIC_SetPanSeperation@8"); + F_GETPROC(FMUSIC_GetName, "_FMUSIC_GetName@4"); + F_GETPROC(FMUSIC_GetType, "_FMUSIC_GetType@4"); + F_GETPROC(FMUSIC_GetNumOrders, "_FMUSIC_GetNumOrders@4"); + F_GETPROC(FMUSIC_GetNumPatterns, "_FMUSIC_GetNumPatterns@4"); + F_GETPROC(FMUSIC_GetNumInstruments, "_FMUSIC_GetNumInstruments@4"); + F_GETPROC(FMUSIC_GetNumSamples, "_FMUSIC_GetNumSamples@4"); + F_GETPROC(FMUSIC_GetNumChannels, "_FMUSIC_GetNumChannels@4"); + F_GETPROC(FMUSIC_GetSample, "_FMUSIC_GetSample@8"); + F_GETPROC(FMUSIC_GetPatternLength, "_FMUSIC_GetPatternLength@8"); + F_GETPROC(FMUSIC_IsFinished, "_FMUSIC_IsFinished@4"); + F_GETPROC(FMUSIC_IsPlaying, "_FMUSIC_IsPlaying@4"); + F_GETPROC(FMUSIC_GetMasterVolume, "_FMUSIC_GetMasterVolume@4"); + F_GETPROC(FMUSIC_GetGlobalVolume, "_FMUSIC_GetGlobalVolume@4"); + F_GETPROC(FMUSIC_GetOrder, "_FMUSIC_GetOrder@4"); + F_GETPROC(FMUSIC_GetPattern, "_FMUSIC_GetPattern@4"); + F_GETPROC(FMUSIC_GetSpeed, "_FMUSIC_GetSpeed@4"); + F_GETPROC(FMUSIC_GetBPM, "_FMUSIC_GetBPM@4"); + F_GETPROC(FMUSIC_GetRow, "_FMUSIC_GetRow@4"); + F_GETPROC(FMUSIC_GetPaused, "_FMUSIC_GetPaused@4"); + F_GETPROC(FMUSIC_GetTime, "_FMUSIC_GetTime@4"); + F_GETPROC(FMUSIC_GetRealChannel, "_FMUSIC_GetRealChannel@8"); + F_GETPROC(FMUSIC_GetUserData, "_FMUSIC_GetUserData@4"); + + return instance; +} + +static void FMOD_FreeInstance(FMOD_INSTANCE *instance) +{ + if (instance) + { + if (instance->module) + { +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) + FreeLibrary((HMODULE)instance->module); +#else + dlclose(instance->module); +#endif + } + free(instance); + } +} + +#endif + diff --git a/lib/fmodapi375win/api/inc/wincompat.h b/lib/fmodapi375win/api/inc/wincompat.h new file mode 100644 index 0000000..f660001 --- /dev/null +++ b/lib/fmodapi375win/api/inc/wincompat.h @@ -0,0 +1,81 @@ +#if !defined(WINCOMPAT_INCLUDED) && !defined(PLATFORM_WINDOWS) && !defined(WIN32) && !defined(WINDOWS) && !defined(__WIN32__) +#define WINCOMPAT_INCLUDED + +/** + * + * Author: Magnus Naeslund (mag@fbab.net, mag@bahnhof.se) + * (c) 2000 Magnus Naeslund, all rights reserved + * + */ + +#include +#include +#include +#include +#include +#include + +#ifndef TRUE + #define TRUE 1 +#endif +#ifndef FALSE + #define FALSE 0 +#endif + +#define _kbhit kbhit +#define stricmp strcasecmp +#define strnicmp strncasecmp + +#define Sleep(x) usleep((x)*1000) + +static int inited=0; +static struct termios ori; + +static void tcatexit(){ + tcsetattr(0,0,&ori); +} + +static void init_terminal(){ + struct termios t; + tcgetattr(0,&t); + tcgetattr(0,&ori); + t.c_lflag &= ~(ICANON); + tcsetattr(0,0,&t); + atexit(tcatexit); +} + +static inline int kbhit(){ + fd_set rfds; + struct timeval tv; + + if (!inited){ + inited=1; + init_terminal(); + } + + FD_ZERO(&rfds); + FD_SET(0, &rfds); + tv.tv_sec = 0; + tv.tv_usec = 10*1000; + return select(1, &rfds, NULL, NULL, &tv)>0; +} + +static inline int getch(){ + fd_set rfds; + + if (!inited){ + inited=1; + init_terminal(); + } + + FD_ZERO(&rfds); + FD_SET(0, &rfds); + if (select(1, &rfds, NULL, NULL, NULL)>0) + return getchar(); + else{ + printf("wincompat.h: select() on fd 0 failed\n"); + return 0xDeadBeef; + } +} + +#endif diff --git a/lib/fmodapi375win/api/lib/fmod64vc.lib b/lib/fmodapi375win/api/lib/fmod64vc.lib new file mode 100644 index 0000000..f0369df Binary files /dev/null and b/lib/fmodapi375win/api/lib/fmod64vc.lib differ diff --git a/lib/fmodapi375win/api/lib/fmodbc.lib b/lib/fmodapi375win/api/lib/fmodbc.lib new file mode 100644 index 0000000..0b0399b Binary files /dev/null and b/lib/fmodapi375win/api/lib/fmodbc.lib differ diff --git a/lib/fmodapi375win/api/lib/fmodlcc.lib b/lib/fmodapi375win/api/lib/fmodlcc.lib new file mode 100644 index 0000000..0738c0a Binary files /dev/null and b/lib/fmodapi375win/api/lib/fmodlcc.lib differ diff --git a/lib/fmodapi375win/api/lib/fmodvc.lib b/lib/fmodapi375win/api/lib/fmodvc.lib new file mode 100644 index 0000000..b3c9fd9 Binary files /dev/null and b/lib/fmodapi375win/api/lib/fmodvc.lib differ diff --git a/lib/fmodapi375win/api/lib/fmodwc.lib b/lib/fmodapi375win/api/lib/fmodwc.lib new file mode 100644 index 0000000..12fe755 Binary files /dev/null and b/lib/fmodapi375win/api/lib/fmodwc.lib differ diff --git a/lib/fmodapi375win/api/vb/fmod.bas b/lib/fmodapi375win/api/vb/fmod.bas new file mode 100644 index 0000000..58d16eb --- /dev/null +++ b/lib/fmodapi375win/api/vb/fmod.bas @@ -0,0 +1,914 @@ +Attribute VB_Name = "FMod" +Option Explicit + +' +'FMOD VB6 Module +' + +Public Const FMOD_VERSION = 3.75 + +'************ +'* Enums +'************ + + +' FMOD_ERRORS +' On failure of commands in FMOD, use FSOUND_GetError to attain what happened. +' +Public Enum FMOD_ERRORS + FMOD_ERR_NONE ' No errors + FMOD_ERR_BUSY ' Cannot call this command after FSOUND_Init. Call FSOUND_Close first. + FMOD_ERR_UNINITIALIZED ' This command failed because FSOUND_Init was not called + FMOD_ERR_INIT ' Error initializing output device. + FMOD_ERR_ALLOCATED ' Error initializing output device, but more specifically, the output device is already in use and cannot be reused. + FMOD_ERR_PLAY ' Playing the sound failed. + FMOD_ERR_OUTPUT_FORMAT ' Soundcard does not support the features needed for this soundsystem (16bit stereo output) + FMOD_ERR_COOPERATIVELEVEL ' Error setting cooperative level for hardware. + FMOD_ERR_CREATEBUFFER ' Error creating hardware sound buffer. + FMOD_ERR_FILE_NOTFOUND ' File not found + FMOD_ERR_FILE_FORMAT ' Unknown file format + FMOD_ERR_FILE_BAD ' Error loading file + FMOD_ERR_MEMORY ' Not enough memory + FMOD_ERR_VERSION ' The version number of this file format is not supported + FMOD_ERR_INVALID_PARAM ' An invalid parameter was passed to this function + FMOD_ERR_NO_EAX ' Tried to use an EAX command on a non EAX enabled channel or output. + FMOD_ERR_CHANNEL_ALLOC ' Failed to allocate a new channel + FMOD_ERR_RECORD ' Recording is not supported on this machine + FMOD_ERR_MEDIAPLAYER ' Windows Media Player not installed so cannot play wma or use internet streaming. + FMOD_ERR_CDDEVICE ' An error occured trying to open the specified CD device +End Enum + + +' FSOUND_OUTPUTTYPES +' These output types are used with FSOUND_SetOutput, to choose which output driver to use. +' FSOUND_OUTPUT_DSOUND will not support hardware 3d acceleration if the sound card driver +' does not support DirectX 6 Voice Manager Extensions. +' FSOUND_OUTPUT_WINMM is recommended for NT and CE. +' +Public Enum FSOUND_OUTPUTTYPES + FSOUND_OUTPUT_NOSOUND ' NoSound driver, all calls to this succeed but do nothing. + FSOUND_OUTPUT_WINMM ' Windows Multimedia driver. + FSOUND_OUTPUT_DSOUND ' DirectSound driver. You need this to get EAX2 or EAX3 support, or FX api support. + FSOUND_OUTPUT_A3D ' A3D driver. + + FSOUND_OUTPUT_OSS ' Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers. + FSOUND_OUTPUT_ESD ' Linux/Unix ESD (Enlightment Sound Daemon) driver. + FSOUND_OUTPUT_ALSA ' Linux Alsa driver. + + FSOUND_OUTPUT_ASIO ' Low latency ASIO driver + FSOUND_OUTPUT_XBOX ' Xbox driver + FSOUND_OUTPUT_PS2 ' PlayStation 2 driver + FSOUND_OUTPUT_MAC ' Mac SoundMager driver + FSOUND_OUTPUT_GC ' Gamecube driver + FSOUND_OUTPUT_PSP ' PlayStation Portable driver + + FSOUND_OUTPUT_NOSOUND_NONREALTIME ' This is the same as nosound, but the sound generation is driven by FSOUND_Update +End Enum + + +' FSOUND_MIXERTYPES +' These mixer types are used with FSOUND_SetMixer, to choose which mixer to use, or to act +' upon for other reasons using FSOUND_GetMixer. +' It is not nescessary to set the mixer. FMOD will autodetect the best mixer for you. +' +Public Enum FSOUND_MIXERTYPES + FSOUND_MIXER_AUTODETECT ' CE/PS2 Only - Non interpolating/low quality mixer + FSOUND_MIXER_BLENDMODE ' removed / obsolete. + FSOUND_MIXER_MMXP5 ' removed / obsolete. + FSOUND_MIXER_MMXP6 ' removed / obsolete. + + FSOUND_MIXER_QUALITY_AUTODETECT ' All platforms - Autodetect the fastest quality mixer based on your cpu. + FSOUND_MIXER_QUALITY_FPU ' Win32/Linux only - Interpolating/volume ramping FPU mixer. + FSOUND_MIXER_QUALITY_MMXP5 ' Win32/Linux only - Interpolating/volume ramping FPU mixer. + FSOUND_MIXER_QUALITY_MMXP6 ' Win32/Linux only - Interpolating/volume ramping ppro+ MMX mixer. + + FSOUND_MIXER_MONO ' CE/PS2 only - MONO non interpolating/low quality mixer. For speed + FSOUND_MIXER_QUALITY_MONO ' CE/PS2 only - MONO Interpolating mixer. For speed +End Enum + + +' FMUSIC_TYPES +' These definitions describe the type of song being played. +' See FMUSIC_GetType +' +Public Enum FMUSIC_TYPES + FMUSIC_TYPE_NONE + FMUSIC_TYPE_MOD 'Protracker / Fasttracker + FMUSIC_TYPE_S3M 'ScreamTracker 3 + FMUSIC_TYPE_XM 'FastTracker 2 + FMUSIC_TYPE_IT 'Impulse Tracker. + FMUSIC_TYPE_MIDI 'MIDI file + FMUSIC_TYPE_FSB 'FMOD Sample Bank file +End Enum + + +' FSOUND_DSP_PRIORITIES +' These default priorities are used by FMOD internal system DSP units. They describe the +' position of the DSP chain, and the order of how audio processing is executed. +' You can actually through the use of FSOUND_DSP_GetxxxUnit (where xxx is the name of the DSP +' unit), disable or even change the priority of a DSP unit. +' +Public Enum FSOUND_DSP_PRIORITIES + FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT = 0 'DSP CLEAR unit - done first + FSOUND_DSP_DEFAULTPRIORITY_SFXUNIT = 100 'DSP SFX unit - done second + FSOUND_DSP_DEFAULTPRIORITY_MUSICUNIT = 200 'DSP MUSIC unit - done third + FSOUND_DSP_DEFAULTPRIORITY_USER = 300 'User priority, use this as reference for your own dsp units + FSOUND_DSP_DEFAULTPRIORITY_FFTUNIT = 900 'This reads data for FSOUND_DSP_GetSpectrum, so it comes after user units + FSOUND_DSP_DEFAULTPRIORITY_CLIPANDCOPYUNIT = 1000 'DSP CLIP AND COPY unit - last +End Enum + + +' FSOUND_CAPS +' Driver description bitfields. Use FSOUND_Driver_GetCaps to determine if a driver enumerated +' has the settings you are after. The enumerated driver depends on the output mode, see +' FSOUND_OUTPUTTYPES +' +Public Enum FSOUND_CAPS + FSOUND_CAPS_HARDWARE = &H1 ' This driver supports hardware accelerated 3d sound. + FSOUND_CAPS_EAX2 = &H2 ' This driver supports EAX 2 reverb + FSOUND_CAPS_EAX3 = &H10 ' This driver supports EAX 3 reverb +End Enum + + +' FSOUND_MODES +' Sample description bitfields, OR them together for loading and describing samples. +' NOTE. If the file format being loaded already has a defined format, such as WAV or MP3, then +' trying to override the pre-defined format with a new set of format flags will not work. For +' example, an 8 bit WAV file will not load as 16bit if you specify FSOUND_16BITS. It will just +' ignore the flag and go ahead loading it as 8bits. For these type of formats the only flags +' you can specify that will really alter the behaviour of how it is loaded, are the following. +' +' Looping behaviour - FSOUND_LOOP_OFF, FSOUND_LOOP_NORMAL, FSOUND_LOOP_BIDI +' Load destination - FSOUND_HW3D, FSOUND_HW2D, FSOUND_2D +' Loading behaviour - FSOUND_NONBLOCKING, FSOUND_LOADMEMORY, FSOUND_LOADRAW, FSOUND_MPEGACCURATE, FSOUND_MPEGHALFRATE, FSOUND_FORCEMONO +' Playback behaviour - FSOUND_STREAMABLE, FSOUND_ENABLEFX +' PlayStation 2 only - FSOUND_USECORE0, FSOUND_USECORE1, FSOUND_LOADMEMORYIOP +' +' See flag descriptions for what these do. +' +Public Enum FSOUND_MODES + FSOUND_LOOP_OFF = &H1 ' For non looping samples. + FSOUND_LOOP_NORMAL = &H2 ' For forward looping samples. + FSOUND_LOOP_BIDI = &H4 ' For bidirectional looping samples. (no effect if in hardware). + FSOUND_8BITS = &H8 ' For 8 bit samples. + FSOUND_16BITS = &H10 ' For 16 bit samples. + FSOUND_MONO = &H20 ' For mono samples. + FSOUND_STEREO = &H40 ' For stereo samples. + FSOUND_UNSIGNED = &H80 ' For source data containing unsigned samples. + FSOUND_SIGNED = &H100 ' For source data containing signed data. + FSOUND_DELTA = &H200 ' For source data stored as delta values. + FSOUND_IT214 = &H400 ' For source data stored using IT214 compression. + FSOUND_IT215 = &H800 ' For source data stored using IT215 compression. + FSOUND_HW3D = &H1000 ' Attempts to make samples use 3d hardware acceleration. (if the card supports it) + FSOUND_2D = &H2000 ' Ignores any 3d processing. overrides FSOUND_HW3D. Located in software. + FSOUND_STREAMABLE = &H4000 ' For realtime streamable samples. If you dont supply this sound may come out corrupted. + FSOUND_LOADMEMORY = &H8000 ' For FSOUND_Sample_Load - name will be interpreted as a pointer to data + FSOUND_LOADRAW = &H10000 ' For FSOUND_Sample_Load/FSOUND_Stream_Open - will ignore file format and treat as raw pcm. + FSOUND_MPEGACCURATE = &H20000 ' For FSOUND_Stream_Open - scans MP2/MP3 (VBR also) for accurate FSOUND_Stream_GetLengthMs/FSOUND_Stream_SetTime. + FSOUND_FORCEMONO = &H40000 ' For forcing stereo streams and samples to be mono - needed with FSOUND_HW3D - incurs speed hit + FSOUND_HW2D = &H80000 ' 2d hardware sounds. allows hardware specific effects + FSOUND_ENABLEFX = &H100000 ' Allows DX8 FX to be played back on a sound. Requires DirectX 8 - Note these sounds cant be played more than once, or have a changing frequency + FSOUND_MPEGHALFRATE = &H200000 ' For FMODCE only - decodes mpeg streams using a lower quality decode, but faster execution + FSOUND_XADPCM = &H400000 ' For XBOX only - Describes a user sample that its contents are compressed as XADPCM + FSOUND_VAG = &H800000 ' For PS2 only - Describes a user sample that its contents are compressed as Sony VAG format. + FSOUND_NONBLOCKING = &H1000000 ' For FSOUND_Stream_Open - Causes stream to open in the background and not block the foreground app - stream plays only when ready. + FSOUND_GCADPCM = &H2000000 ' For Gamecube only - Contents are compressed as Gamecube DSP-ADPCM format + FSOUND_MULTICHANNEL = &H4000000 ' For PS2 only - Contents are interleaved into a multi-channel (more than stereo) format + FSOUND_USECORE0 = &H8000000 ' For PS2 only - Sample/Stream is forced to use hardware voices 00-23 + FSOUND_USECORE1 = &H10000000 ' For PS2 only - Sample/Stream is forced to use hardware voices 24-47 + FSOUND_LOADMEMORYIOP = &H20000000 ' For PS2 only - "name" will be interpreted as a pointer to data for streaming and samples. The address provided will be an IOP address + FSOUND_IGNORETAGS = &H40000000 ' Skips id3v2 etc tag checks when opening a stream, to reduce seek/read overhead when opening files (helps with CD performance) + FSOUND_STREAM_NET = &H80000000 ' Specifies an internet stream + + FSOUND_NORMAL = FSOUND_16BITS Or FSOUND_SIGNED Or FSOUND_MONO +End Enum + + +' FSOUND_CDPLAYMODES +' Playback method for a CD Audio track, with FSOUND_CD_SetPlayMode +' +Public Enum FSOUND_CDPLAYMODES + FSOUND_CD_PLAYCONTINUOUS 'Starts from the current track and plays to end of CD. + FSOUND_CD_PLAYONCE 'Plays the specified track then stops. + FSOUND_CD_PLAYLOOPED 'Plays the specified track looped, forever until stopped manually. + FSOUND_CD_PLAYRANDOM 'Plays tracks in random order +End Enum + + +' FSOUND_CHANNELSAMPLEMODE +' Miscellaneous values for FMOD functions. +' FSOUND_PlaySound, FSOUND_PlaySoundEx, FSOUND_Sample_Alloc, FSOUND_Sample_Load, FSOUND_SetPan +' +Public Enum FSOUND_CHANNELSAMPLEMODE + FSOUND_FREE = -1 ' definition for dynamically allocated channel or sample + FSOUND_UNMANAGED = -2 ' definition for allocating a sample that is NOT managed by fsound + FSOUND_ALL = -3 ' for a channel index or sample index, this flag affects ALL channels or samples available! Not supported by all functions. + FSOUND_STEREOPAN = -1 ' definition for full middle stereo volume on both channels + FSOUND_SYSTEMCHANNEL = -1000 ' special channel ID for channel based functions that want to alter the global FSOUND software mixing output channel + FSOUND_SYSTEMSAMPLE = -1000 ' special sample ID for all sample based functions that want to alter the global FSOUND software mixing output sample +End Enum + + +' FSOUND_REVERB_PROPERTIES +' FSOUND_Reverb_SetProperties, FSOUND_Reverb_GetProperties, FSOUND_REVERB_PROPERTYFLAGS +' +Public Type FSOUND_REVERB_PROPERTIES + ' MIN MAX DEFAULT DESCRIPTION + Environment As Long ' 0 25 0 sets all listener properties + EnvSize As Single ' 1.0 100.0 7.5 environment size in meters + EnvDiffusion As Single ' 0.0 1.0 1.0 environment diffusion + Room As Long ' -10000 0 -1000 room effect level (at mid frequencies) + RoomHF As Long ' -10000 0 -100 relative room effect level at high frequencies + RoomLF As Long ' -10000 0 0 relative room effect level at low frequencies + DecayTime As Single ' 0.1 20.0 1.49 reverberation decay time at mid frequencies + DecayHFRatio As Single ' 0.1 2.0 0.83 high-frequency to mid-frequency decay time ratio + DecayLFRatio As Single ' 0.1 2.0 1.0 low-frequency to mid-frequency decay time ratio + Reflections As Long ' -10000 1000 -2602 early reflections level relative to room effect + ReflectionsDelay As Single ' 0.0 0.3 0.007 initial reflection delay time + ReflectionsPan(3) As Single ' 0,0,0 early reflections panning vector + Reverb As Long ' -1000 2000 200 late reverberation level relative to room effect + ReverbDelay As Single ' 0.0 0.1 0.011 late reverberation delay time relative to initial reflection + ReverbPan(3) As Single ' 0,0,0 late reverberation panning vector + EchoTime As Single ' .075 0.25 0.25 echo time + EchoDepth As Single ' 0.0 1.0 0.0 echo depth + ModulationTime As Single ' 0.04 4.0 0.25 modulation time + ModulationDepth As Single ' 0.0 1.0 0.0 modulation depth + AirAbsorptionHF As Single ' -100 0.0 -5.0 change in level per meter at high frequencies + HFReference As Single ' 1000.0 20000 5000.0 reference high frequency (hz) + LFReference As Single ' 20.0 1000.0 250.0 reference low frequency (hz) + RoomRolloffFactor As Single ' 0.0 10.0 0.0 like FSOUND_3D_SetRolloffFactor but for room effect + Diffusion As Single ' 0.0 100.0 100.0 Value that controls the echo density in the late reverberation decay. (xbox only) + Density As Single ' 0.0 100.0 100.0 Value that controls the modal density in the late reverberation decay (xbox only) + flags As Long ' modifies the behavior of above properties +End Type + + +' FSOUND_REVERB_FLAGS +' Values for the Flags member of the FSOUND_REVERB_PROPERTIES structure. +' +Public Enum FSOUND_REVERB_PROPERTYFLAGS + FSOUND_REVERBFLAGS_DECAYTIMESCALE = &H1 ' EnvironmentSize affects reverberation decay time + FSOUND_REVERBFLAGS_REFLECTIONSSCALE = &H2 ' EnvironmentSize affects reflection level + FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE = &H4 ' EnvironmentSize affects initial reflection delay time + FSOUND_REVERBFLAGS_REVERBSCALE = &H8 ' EnvironmentSize affects reflections level + FSOUND_REVERBFLAGS_REVERBDELAYSCALE = &H10 ' EnvironmentSize affects late reverberation delay time + FSOUND_REVERBFLAGS_DECAYHFLIMIT = &H20 ' AirAbsorptionHF affects DecayHFRatio + FSOUND_REVERBFLAGS_ECHOTIMESCALE = &H40 ' EnvironmentSize affects echo time + FSOUND_REVERBFLAGS_MODULATIONTIMESCALE = &H80 ' EnvironmentSize affects modulation time + FSOUND_REVERB_FLAGS_CORE0 = &H100 ' PS2 Only - Reverb is applied to CORE0 (hw voices 0-23) + FSOUND_REVERB_FLAGS_CORE1 = &H200 ' PS2 Only - Reverb is applied to CORE1 (hw voices 24-47) + FSOUND_REVERBFLAGS_DEFAULT = FSOUND_REVERBFLAGS_DECAYTIMESCALE Or FSOUND_REVERBFLAGS_REFLECTIONSSCALE Or FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE Or FSOUND_REVERBFLAGS_REVERBSCALE Or FSOUND_REVERBFLAGS_REVERBDELAYSCALE Or FSOUND_REVERBFLAGS_DECAYHFLIMIT Or FSOUND_REVERB_FLAGS_CORE0 Or FSOUND_REVERB_FLAGS_CORE1 +End Enum + + +' FSOUND_REVERB_CHANNELPROPERTIES +' Structure defining the properties for a reverb source, related to a FSOUND channel. +' FSOUND_Reverb_SetEnvironment, FSOUND_Reverb_SetEnvironmentAdvanced +' +Public Type FSOUND_REVERB_CHANNELPROPERTIES + Direct As Long ' direct path level (at low and mid frequencies) + DirectHF As Long ' relative direct path level at high frequencies + Room As Long ' room effect level (at low and mid frequencies) + RoomHF As Long ' relative room effect level at high frequencies + Obstruction As Long ' main obstruction control (attenuation at high frequencies) + ObstructionLFRatio As Single ' obstruction low-frequency level re. main control + Occlusion As Long ' main occlusion control (attenuation at high frequencies) + OcclustionLFRatio As Single ' occlusion low-frequency level re. main control + OcclusionRoomRatio As Single ' relative occlusion control for room effect + OcclusionDirectRatio As Single ' relative occlusion control for direct path + Exclusion As Long ' main exlusion control (attenuation at high frequencies) + ExclusionLFRatio As Single ' exclusion low-frequency level re. main control + OutsideVolumeHF As Long ' outside sound cone level at high frequencies + DopplerFactor As Single ' like DS3D flDopplerFactor but per source + RolloffFactor As Single ' like DS3D flRolloffFactor but per source + RoomRolloffFactor As Single ' like DS3D flRolloffFactor but for room effect + AirAbsorptionFactor As Single ' multiplies AirAbsorptionHF member of FSOUND_REVERB_PROPERTIES + flags As Long ' modifies the behavior of properties +End Type + + +' FSOUND_REVERB_CHANNELFLAGS +' Values for the Flags member of the FSOUND_REVERB_CHANNELPROPERTIES structure. +' +Public Enum FSOUND_REVERB_CHANNELFLAGS + FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO = &H1 ' Automatic setting of Direct due to distance from listener + FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO = &H2 ' Automatic setting of Room due to distance from listener + FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO = &H4 ' Automatic setting of RoomHF due to distance from listener + FSOUND_REVERB_CHANNELFLAGS_DEFAULT = FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO Or FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO Or FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO +End Enum + + +' FSOUND_FX_MODES +' These values are used with FSOUND_FX_Enable to enable DirectX 8 FX for a channel. +' +Public Enum FSOUND_FX_MODES + FSOUND_FX_CHORUS + FSOUND_FX_COMPRESSOR + FSOUND_FX_DISTORTION + FSOUND_FX_ECHO + FSOUND_FX_FLANGER + FSOUND_FX_GARGLE + FSOUND_FX_I3DL2REVERB + FSOUND_FX_PARAMEQ + FSOUND_FX_WAVES_REVERB +End Enum + + +'FSOUND_SPEAKERMODES +'These are speaker types defined for use with the FSOUND_SetSpeakerMode command. +'Note - Only reliably works with FSOUND_OUTPUT_DSOUND or FSOUND_OUTPUT_XBOX output modes. Other output modes will only +'interpret FSOUND_SPEAKERMODE_MONO and set everything else to be stereo. +'Using either DolbyDigital or DTS will use whatever 5.1 digital mode is available if destination hardware is unsure. +' +Public Enum FSOUND_SPEAKERMODES + FSOUND_SPEAKERMODE_DOLBYDIGITAL ' The audio is played through a speaker arrangement of surround speakers with a subwoofer. + FSOUND_SPEAKERMODE_HEADPHONE ' The speakers are headphones. + FSOUND_SPEAKERMODE_MONO ' The speakers are monaural. + FSOUND_SPEAKERMODE_QUAD ' The speakers are quadraphonic. + FSOUND_SPEAKERMODE_STEREO ' The speakers are stereo (default value). + FSOUND_SPEAKERMODE_SURROUND ' The speakers are surround sound. + FSOUND_SPEAKERMODE_DTS ' The audio is played through a speaker arrangement of surround speakers with a subwoofer. + FSOUND_SPEAKERMODE_PROLOGIC2 ' Dolby Prologic 2. Playstation 2 and Gamecube only +End Enum + + +' FSOUND_INIT_FLAGS +' Initialization flags. Use them with FSOUND_Init in the flags parameter to change various behaviour. +' FSOUND_INIT_ENABLESYSTEMCHANNELFX Is an init mode which enables the FSOUND mixer buffer to be affected by DirectX 8 effects. +' Note that due to limitations of DirectSound, FSOUND_Init may fail if this is enabled because the buffersize is too small. +' This can be fixed with FSOUND_SetBufferSize. Increase the BufferSize until it works. +' When it is enabled you can use the FSOUND_FX api, and use FSOUND_SYSTEMCHANNEL as the channel id when setting parameters. +' +Public Enum FSOUND_INITMODES + FSOUND_INIT_USEDEFAULTMIDISYNTH = &H1 'Causes MIDI playback to force software decoding. + FSOUND_INIT_GLOBALFOCUS = &H2 'For DirectSound output - sound is not muted when window is out of focus. + FSOUND_INIT_ENABLESYSTEMCHANNELFX = &H4 'For DirectSound output - Allows FSOUND_FX api to be used on global software mixer output! + FSOUND_INIT_ACCURATEVULEVELS = &H8 'This latency adjusts FSOUND_GetCurrentLevels, but incurs a small cpu and memory hit + FSOUND_INIT_PS2_DISABLECORE0REVERB = &H10 'PS2 only - Disable reverb on CORE 0 to regain SRAM + FSOUND_INIT_PS2_DISABLECORE1REVERB = &H20 'PS2 only - Disable reverb on CORE 1 to regain SRAM + FSOUND_INIT_PS2_SWAPDMACORES = &H40 'PS2 only - By default FMOD uses DMA CH0 for mixing, CH1 for uploads, this flag swaps them around + FSOUND_INIT_DONTLATENCYADJUST = &H80 'Callbacks are not latency adjusted, and are called at mix time. Also information functions are immediate + FSOUND_INIT_GC_INITLIBS = &H100 'Gamecube only - Initializes GC audio libraries + FSOUND_INIT_STREAM_FROM_MAIN_THREAD = &H200 'Turns off fmod streamer thread, and makes streaming update from FSOUND_Update called by the user + FSOUND_INIT_PS2_USEVOLUMERAMPING = &H400 'PS2 only - Turns on volume ramping system to remove hardware clicks. + FSOUND_INIT_DSOUND_DEFERRED = &H800 'Win32 only - For DirectSound output. 3D commands are batched together and executed at FSOUND_Update. + FSOUND_INIT_DSOUND_HRTF_LIGHT = &H1000 'Win32 only - For DirectSound output. FSOUND_HW3D buffers use a slightly higher quality algorithm when 3d hardware acceleration is not present. + FSOUND_INIT_DSOUND_HRTF_FULL = &H2000 'Win32 only - For DirectSound output. FSOUND_HW3D buffers use full quality 3d playback when 3d hardware acceleration is not present. + FSOUND_INIT_XBOX_REMOVEHEADROOM = &H4000 'XBox only - By default directsound attenuates all sound by 6db to avoid clipping/distortion. CAUTION. If you use this flag you are responsible for the final mix to make sure clipping / distortion doesn't happen. + FSOUND_INIT_PSP_SILENCEONUNDERRUN = &H8000 'PSP only - If streams skip / stutter when device is powered on, either increase stream buffersize, or use this flag instead to play silence while the UMD is recovering. +End Enum + + +' FSOUND_STREAM_NET_STATUS +' Status values for internet streams. Use FSOUND_Stream_Net_GetStatus to get the current status of an internet stream. +' +Public Enum FSOUND_STREAM_NET_STATUS + FSOUND_STREAM_NET_NOTCONNECTED ' Stream hasn't connected yet + FSOUND_STREAM_NET_CONNECTING ' Stream is connecting to remote host + FSOUND_STREAM_NET_BUFFERING ' Stream is buffering data + FSOUND_STREAM_NET_READY ' Stream is ready to play + FSOUND_STREAM_NET_ERROR ' Stream has suffered a fatal error +End Enum + + +' FSOUND_TAGFIELD_TYPE +' Describes the type of a particular tag field. +' See FSOUND_Stream_GetNumTagFields, FSOUND_Stream_GetTagField, FSOUND_Stream_FindTagField +' +Public Enum FSOUND_TAGFIELD_TYPE + FSOUND_TAGFIELD_VORBISCOMMENT = 0 ' A vorbis comment + FSOUND_TAGFIELD_ID3V1 ' Part of an ID3v1 tag + FSOUND_TAGFIELD_ID3V2 ' An ID3v2 frame + FSOUND_TAGFIELD_SHOUTCAST ' A SHOUTcast header line + FSOUND_TAGFIELD_ICECAST ' An Icecast header line + FSOUND_TAGFIELD_ASF ' An Advanced Streaming Format header line +End Enum + + +' FSOUND_STATUS_FLAGS +' These values describe the protocol and format of an internet stream. Use FSOUND_Stream_Net_GetStatus to retrieve this information for an open internet stream. +' +Public Enum FSOUND_STATUS_FLAGS + FSOUND_PROTOCOL_SHOUTCAST = &H1 + FSOUND_PROTOCOL_ICECAST = &H2 + FSOUND_PROTOCOL_HTTP = &H4 + FSOUND_FORMAT_MPEG = &H10000 + FSOUND_FORMAT_OGGVORBIS = &H20000 +End Enum + +' FSOUND_TOC_TAG +' FSOUND_Stream_Open, FSOUND_Stream_FindTagField +' +Public Type FSOUND_TOC_TAG + TagName(3) As Byte ' The string "TOC" (4th character is 0), just in case this structure is accidentally treated as a string. + NumTracks As Long ' The number of tracks on the CD. + Min(99) As Long ' The start offset of each track in minutes. + Sec(99) As Long ' The start offset of each track in seconds. + Frame(99) As Long ' The start offset of each track in frames. +End Type + + +'/* ================================== */ +'/* Initialization / Global functions. */ +'/* ================================== */ + + +' PRE - FSOUND_Init functions. These cant be called after FSOUND_Init is +' called (they will fail). They set up FMOD system functionality. + + +Public Declare Function FSOUND_SetOutput Lib "fmod.dll" Alias "_FSOUND_SetOutput@4" (ByVal outputtype As FSOUND_OUTPUTTYPES) As Byte +Public Declare Function FSOUND_SetDriver Lib "fmod.dll" Alias "_FSOUND_SetDriver@4" (ByVal driver As Long) As Byte +Public Declare Function FSOUND_SetMixer Lib "fmod.dll" Alias "_FSOUND_SetMixer@4" (ByVal mixer As FSOUND_MIXERTYPES) As Byte +Public Declare Function FSOUND_SetBufferSize Lib "fmod.dll" Alias "_FSOUND_SetBufferSize@4" (ByVal lenms As Long) As Byte +Public Declare Function FSOUND_SetHWND Lib "fmod.dll" Alias "_FSOUND_SetHWND@4" (ByVal hwnd As Long) As Byte +Public Declare Function FSOUND_SetMinHardwareChannels Lib "fmod.dll" Alias "_FSOUND_SetMinHardwareChannels@4" (ByVal min As Integer) As Byte +Public Declare Function FSOUND_SetMaxHardwareChannels Lib "fmod.dll" Alias "_FSOUND_SetMaxHardwareChannels@4" (ByVal min As Integer) As Byte +Public Declare Function FSOUND_SetMemorySystem Lib "fmod.dll" Alias "_FSOUND_SetMemorySystem@20" (ByVal pool As Long, ByVal poollen As Long, ByVal useralloc As Long, ByVal userrealloc As Long, ByVal userfree As Long) As Byte + +' +' Main initialization / closedown functions. +' Note : Use FSOUND_INIT_USEDEFAULTMIDISYNTH with FSOUND_Init for software override +' with MIDI playback. +' : Use FSOUND_INIT_GLOBALFOCUS with FSOUND_Init to make sound audible no matter +' which window is in focus. (FSOUND_OUTPUT_DSOUND only) +' + +Public Declare Function FSOUND_Init Lib "fmod.dll" Alias "_FSOUND_Init@12" (ByVal mixrate As Long, ByVal maxchannels As Long, ByVal flags As FSOUND_INITMODES) As Byte +Public Declare Function FSOUND_Close Lib "fmod.dll" Alias "_FSOUND_Close@0" () As Long + +' +' Runtime system level functions +' + +Public Declare Function FSOUND_Update Lib "fmod.dll" Alias "_FSOUND_Update@0" () As Long + +Public Declare Function FSOUND_SetSpeakerMode Lib "fmod.dll" Alias "_FSOUND_SetSpeakerMode@4" (ByVal speakermode As FSOUND_SPEAKERMODES) As Long +Public Declare Function FSOUND_SetSFXMasterVolume Lib "fmod.dll" Alias "_FSOUND_SetSFXMasterVolume@4" (ByVal volume As Long) As Long +Public Declare Function FSOUND_SetPanSeperation Lib "fmod.dll" Alias "_FSOUND_SetPanSeperation@4" (ByVal pansep As Single) As Long +Public Declare Function FSOUND_File_SetCallbacks Lib "fmod.dll" Alias "_FSOUND_File_SetCallbacks@20" (ByVal OpenCallback As Long, ByVal CloseCallback As Long, ByVal ReadCallback As Long, ByVal SeekCallback As Long, ByVal TellCallback As Long) As Long + +' +' System information functions. +' + +Public Declare Function FSOUND_GetError Lib "fmod.dll" Alias "_FSOUND_GetError@0" () As FMOD_ERRORS +Public Declare Function FSOUND_GetVersion Lib "fmod.dll" Alias "_FSOUND_GetVersion@0" () As Single +Public Declare Function FSOUND_GetOutput Lib "fmod.dll" Alias "_FSOUND_GetOutput@0" () As FSOUND_OUTPUTTYPES +Public Declare Function FSOUND_GetOutputHandle Lib "fmod.dll" Alias "_FSOUND_GetOutputHandle@0" () As Long +Public Declare Function FSOUND_GetDriver Lib "fmod.dll" Alias "_FSOUND_GetDriver@0" () As Long +Public Declare Function FSOUND_GetMixer Lib "fmod.dll" Alias "_FSOUND_GetMixer@0" () As FSOUND_MIXERTYPES +Public Declare Function FSOUND_GetNumDrivers Lib "fmod.dll" Alias "_FSOUND_GetNumDrivers@0" () As Long +Public Declare Function FSOUND_GetDriverName Lib "fmod.dll" Alias "_FSOUND_GetDriverName@4" (ByVal id As Long) As Long +Public Declare Function FSOUND_GetDriverCaps Lib "fmod.dll" Alias "_FSOUND_GetDriverCaps@8" (ByVal id As Long, ByRef caps As Long) As Byte +Public Declare Function FSOUND_GetOutputRate Lib "fmod.dll" Alias "_FSOUND_GetOutputRate@0" () As Long +Public Declare Function FSOUND_GetMaxChannels Lib "fmod.dll" Alias "_FSOUND_GetMaxChannels@0" () As Long +Public Declare Function FSOUND_GetMaxSamples Lib "fmod.dll" Alias "_FSOUND_GetMaxSamples@0" () As Long +Public Declare Function FSOUND_GetSpeakerMode Lib "fmod.dll" Alias "_FSOUND_GetSpeakerMode@0" () As Long +Public Declare Function FSOUND_GetSFXMasterVolume Lib "fmod.dll" Alias "_FSOUND_GetSFXMasterVolume@0" () As Long +Public Declare Function FSOUND_GetNumHWChannels Lib "fmod.dll" Alias "_FSOUND_GetNumHWChannels@12" (ByRef num2d As Long, ByRef num3d As Long, ByRef total As Long) +Public Declare Function FSOUND_GetChannelsPlaying Lib "fmod.dll" Alias "_FSOUND_GetChannelsPlaying@0" () As Long +Public Declare Function FSOUND_GetCPUUsage Lib "fmod.dll" Alias "_FSOUND_GetCPUUsage@0" () As Single +Public Declare Sub FSOUND_GetMemoryStats Lib "fmod.dll" Alias "_FSOUND_GetMemoryStats@8" (ByRef currentalloced As Long, ByRef maxalloced As Long) + +'/* =================================== */ +'/* Sample management / load functions. */ +'/* =================================== */ + + +' Sample creation and management functions +' Note : Use FSOUND_LOADMEMORY flag with FSOUND_Sample_Load to load from memory. +' Use FSOUND_LOADRAW flag with FSOUND_Sample_Load to treat as as raw pcm data. + + +Public Declare Function FSOUND_Sample_Load Lib "fmod.dll" Alias "_FSOUND_Sample_Load@20" (ByVal index As Long, ByVal name As String, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long +Public Declare Function FSOUND_Sample_Alloc Lib "fmod.dll" Alias "_FSOUND_Sample_Alloc@28" (ByVal index As Long, ByVal length As Long, ByVal mode As Long, ByVal deffreq As Long, ByVal defvol As Long, ByVal defpan As Long, ByVal defpri As Long) As Long +Public Declare Function FSOUND_Sample_Free Lib "fmod.dll" Alias "_FSOUND_Sample_Free@4" (ByVal sptr As Long) As Long +Public Declare Function FSOUND_Sample_Upload Lib "fmod.dll" Alias "_FSOUND_Sample_Upload@12" (ByVal sptr As Long, ByRef srcdata As Long, ByVal mode As Long) As Byte +Public Declare Function FSOUND_Sample_Lock Lib "fmod.dll" Alias "_FSOUND_Sample_Lock@28" (ByVal sptr As Long, ByVal offset As Long, ByVal length As Long, ByRef ptr1 As Long, ByRef ptr2 As Long, ByRef len1 As Long, ByRef len2 As Long) As Byte +Public Declare Function FSOUND_Sample_Unlock Lib "fmod.dll" Alias "_FSOUND_Sample_Unlock@20" (ByVal sptr As Long, ByVal sptr1 As Long, ByVal sptr2 As Long, ByVal len1 As Long, ByVal len2 As Long) As Byte + + +' Sample control functions + + +Public Declare Function FSOUND_Sample_SetMode Lib "fmod.dll" Alias "_FSOUND_Sample_SetMode@8" (ByVal sptr As Long, ByVal mode As FSOUND_MODES) As Byte +Public Declare Function FSOUND_Sample_SetLoopPoints Lib "fmod.dll" Alias "_FSOUND_Sample_SetLoopPoints@12" (ByVal sptr As Long, ByVal loopstart As Long, ByVal loopend As Long) As Byte +Public Declare Function FSOUND_Sample_SetDefaults Lib "fmod.dll" Alias "_FSOUND_Sample_SetDefaults@20" (ByVal sptr As Long, ByVal deffreq As Long, ByVal defvol As Long, ByVal defpan As Long, ByVal defpri As Long) As Byte +Public Declare Function FSOUND_Sample_SetDefaultsEx Lib "fmod.dll" Alias "_FSOUND_Sample_SetDefaultsEx@32" (ByVal sptr As Long, ByVal deffreq As Long, ByVal defvol As Long, ByVal defpan As Long, ByVal defpri As Long, ByVal varfreq As Long, ByVal varvol As Long, ByVal varpan As Long) As Byte +Public Declare Function FSOUND_Sample_SetMinMaxDistance Lib "fmod.dll" Alias "_FSOUND_Sample_SetMinMaxDistance@12" (ByVal sptr As Long, ByVal min As Single, ByVal max As Single) As Byte +Public Declare Function FSOUND_Sample_SetMaxPlaybacks Lib "fmod.dll" Alias "_FSOUND_Sample_SetMaxPlaybacks@8" (ByVal sptr As Long, ByVal max As Long) As Byte + + +' Sample information functions + + +Public Declare Function FSOUND_Sample_Get Lib "fmod.dll" Alias "_FSOUND_Sample_Get@4" (ByVal sampno As Long) As Long +Public Declare Function FSOUND_Sample_GetName Lib "fmod.dll" Alias "_FSOUND_Sample_GetName@4" (ByVal sptr As Long) As Long +Public Declare Function FSOUND_Sample_GetLength Lib "fmod.dll" Alias "_FSOUND_Sample_GetLength@4" (ByVal sptr As Long) As Long +Public Declare Function FSOUND_Sample_GetLoopPoints Lib "fmod.dll" Alias "_FSOUND_Sample_GetLoopPoints@12" (ByVal sptr As Long, ByRef loopstart As Long, ByRef loopend As Long) As Byte +Public Declare Function FSOUND_Sample_GetDefaults Lib "fmod.dll" Alias "_FSOUND_Sample_GetDefaults@20" (ByVal sptr As Long, ByRef deffreq As Long, ByRef defvol As Long, ByRef defpan As Long, ByRef defpri As Long) As Byte +Public Declare Function FSOUND_Sample_GetDefaultsEx Lib "fmod.dll" Alias "_FSOUND_Sample_GetDefaultsEx@32" (ByVal sptr As Long, ByRef deffreq As Long, ByRef defvol As Long, ByRef defpan As Long, ByRef defpri As Long, ByRef varfreq As Long, ByRef varvol As Long, ByRef varpan As Long) As Byte +Public Declare Function FSOUND_Sample_GetMode Lib "fmod.dll" Alias "_FSOUND_Sample_GetMode@4" (ByVal sptr As Long) As Long +Public Declare Function FSOUND_Sample_GetMinMaxDistance Lib "fmod.dll" Alias "_FSOUND_Sample_GetMinMaxDistance@12" (ByVal sptr As Long, ByRef min As Single, ByRef max As Single) As Byte + +'/* ============================ */ +'/* Channel control functions. */ +'/* ============================ */ + + +' Playing and stopping sounds. +' Note : Use FSOUND_FREE as the channel variable, to let FMOD pick a free channel for you. +' Use FSOUND_ALL as the channel variable to control ALL channels with one function call! + + +Public Declare Function FSOUND_PlaySound Lib "fmod.dll" Alias "_FSOUND_PlaySound@8" (ByVal channel As Long, ByVal sptr As Long) As Long +Public Declare Function FSOUND_PlaySoundEx Lib "fmod.dll" Alias "_FSOUND_PlaySoundEx@16" (ByVal channel As Long, ByVal sptr As Long, ByVal dsp As Long, ByVal startpaused As Byte) As Long +Public Declare Function FSOUND_StopSound Lib "fmod.dll" Alias "_FSOUND_StopSound@4" (ByVal channel As Long) As Byte + + +' Functions to control playback of a channel. +' Note : FSOUND_ALL can be used on most of these functions as a channel value. + + +Public Declare Function FSOUND_SetFrequency Lib "fmod.dll" Alias "_FSOUND_SetFrequency@8" (ByVal channel As Long, ByVal freq As Long) As Byte +Public Declare Function FSOUND_SetVolume Lib "fmod.dll" Alias "_FSOUND_SetVolume@8" (ByVal channel As Long, ByVal Vol As Long) As Byte +Public Declare Function FSOUND_SetVolumeAbsolute Lib "fmod.dll" Alias "_FSOUND_SetVolumeAbsolute@8" (ByVal channel As Long, ByVal Vol As Long) As Byte +Public Declare Function FSOUND_SetPan Lib "fmod.dll" Alias "_FSOUND_SetPan@8" (ByVal channel As Long, ByVal pan As Long) As Byte +Public Declare Function FSOUND_SetSurround Lib "fmod.dll" Alias "_FSOUND_SetSurround@8" (ByVal channel As Long, ByVal surround As Long) As Byte +Public Declare Function FSOUND_SetMute Lib "fmod.dll" Alias "_FSOUND_SetMute@8" (ByVal channel As Long, ByVal mute As Byte) As Byte +Public Declare Function FSOUND_SetPriority Lib "fmod.dll" Alias "_FSOUND_SetPriority@8" (ByVal channel As Long, ByVal Priority As Long) As Byte +Public Declare Function FSOUND_SetReserved Lib "fmod.dll" Alias "_FSOUND_SetReserved@8" (ByVal channel As Long, ByVal reserved As Long) As Byte +Public Declare Function FSOUND_SetPaused Lib "fmod.dll" Alias "_FSOUND_SetPaused@8" (ByVal channel As Long, ByVal Paused As Byte) As Byte +Public Declare Function FSOUND_SetLoopMode Lib "fmod.dll" Alias "_FSOUND_SetLoopMode@8" (ByVal channel As Long, ByVal loopmode As Long) As Byte +Public Declare Function FSOUND_SetCurrentPosition Lib "fmod.dll" Alias "_FSOUND_SetCurrentPosition@8" (ByVal channel As Long, ByVal offset As Long) As Byte +Public Declare Function FSOUND_3D_SetAttributes Lib "fmod.dll" Alias "_FSOUND_3D_SetAttributes@12" (ByVal channel As Long, ByRef Pos As Single, ByRef vel As Single) As Byte +Public Declare Function FSOUND_3D_SetMinMaxDistance Lib "fmod.dll" Alias "_FSOUND_3D_SetMinMaxDistance@12" (ByVal channel As Long, ByVal min As Single, ByVal max As Single) As Byte + +' +' Channel information functions. +' + +Public Declare Function FSOUND_IsPlaying Lib "fmod.dll" Alias "_FSOUND_IsPlaying@4" (ByVal channel As Long) As Byte +Public Declare Function FSOUND_GetFrequency Lib "fmod.dll" Alias "_FSOUND_GetFrequency@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetVolume Lib "fmod.dll" Alias "_FSOUND_GetVolume@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetAmplitude Lib "fmod.dll" Alias "_FSOUND_GetAmplitude@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetPan Lib "fmod.dll" Alias "_FSOUND_GetPan@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetSurround Lib "fmod.dll" Alias "_FSOUND_GetSurround@4" (ByVal channel As Long) As Byte +Public Declare Function FSOUND_GetMute Lib "fmod.dll" Alias "_FSOUND_GetMute@4" (ByVal channel As Long) As Byte +Public Declare Function FSOUND_GetPriority Lib "fmod.dll" Alias "_FSOUND_GetPriority@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetReserved Lib "fmod.dll" Alias "_FSOUND_GetReserved@4" (ByVal channel As Long) As Byte +Public Declare Function FSOUND_GetPaused Lib "fmod.dll" Alias "_FSOUND_GetPaused@4" (ByVal channel As Long) As Byte +Public Declare Function FSOUND_GetLoopMode Lib "fmod.dll" Alias "_FSOUND_GetLoopMode@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetCurrentPosition Lib "fmod.dll" Alias "_FSOUND_GetCurrentPosition@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetCurrentSample Lib "fmod.dll" Alias "_FSOUND_GetCurrentSample@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetCurrentLevels Lib "fmod.dll" Alias "_FSOUND_GetCurrentLevels@12" (ByVal channel As Long, ByRef l As Single, ByRef r As Single) As Byte +Public Declare Function FSOUND_GetNumSubChannels Lib "fmod.dll" Alias "_FSOUND_GetNumSubChannels@4" (ByVal channel As Long) As Long +Public Declare Function FSOUND_GetSubChannel Lib "fmod.dll" Alias "_FSOUND_GetSubChannel@8" (ByVal channel As Long, ByVal subchannel As Long) As Long +Public Declare Function FSOUND_3D_GetAttributes Lib "fmod.dll" Alias "_FSOUND_3D_GetAttributes@12" (ByVal channel As Long, ByRef Pos As Single, ByRef vel As Single) As Byte +Public Declare Function FSOUND_3D_GetMinMaxDistance Lib "fmod.dll" Alias "_FSOUND_3D_GetMinMaxDistance@12" (ByVal channel As Long, ByRef min As Single, ByRef max As Single) As Byte + +'/* ========================== */ +'/* Global 3D sound functions. */ +'/* ========================== */ + +' +' See also 3d sample and channel based functions above. +' Call FSOUND_Update once a frame to process 3d information. +' + +Public Declare Function FSOUND_3D_Listener_SetCurrent Lib "fmod.dll" Alias "_FSOUND_3D_Listener_SetCurrent@8" (ByVal current As Long) As Long +Public Declare Function FSOUND_3D_Listener_SetAttributes Lib "fmod.dll" Alias "_FSOUND_3D_Listener_SetAttributes@32" (ByVal Pos As Single, ByVal vel As Single, ByVal fx As Single, ByVal fy As Single, ByVal fz As Single, ByVal tx As Single, ByVal ty As Single, ByVal tz As Single) As Long +Public Declare Function FSOUND_3D_Listener_GetAttributes Lib "fmod.dll" Alias "_FSOUND_3D_Listener_GetAttributes@32" (ByRef Pos As Single, ByRef vel As Single, ByRef fx As Single, ByRef fy As Single, ByRef fz As Single, ByRef tx As Single, ByRef ty As Single, ByRef tz As Single) As Long +Public Declare Function FSOUND_3D_SetDopplerFactor Lib "fmod.dll" Alias "_FSOUND_3D_SetDopplerFactor@4" (ByVal fscale As Single) As Long +Public Declare Function FSOUND_3D_SetDistanceFactor Lib "fmod.dll" Alias "_FSOUND_3D_SetDistanceFactor@4" (ByVal fscale As Single) As Long +Public Declare Function FSOUND_3D_SetRolloffFactor Lib "fmod.dll" Alias "_FSOUND_3D_SetRolloffFactor@4" (ByVal fscale As Single) As Long + +'/* =================== */ +'/* FX functions. */ +'/* =================== */ + + +' Functions to control DX8 only effects processing. +' +' - FX enabled samples can only be played once at a time, not multiple times at once. +' - Sounds have to be created with FSOUND_HW2D or FSOUND_HW3D for this to work. +' - FSOUND_INIT_ENABLESYSTEMCHANNELFX can be used to apply hardware effect processing to the +' global mixed output of FMOD's software channels. +' - FSOUND_FX_Enable returns an FX handle that you can use to alter fx parameters. +' - FSOUND_FX_Enable can be called multiple times in a row, even on the same FX type, +' it will return a unique handle for each FX. +' - FSOUND_FX_Enable cannot be called if the sound is playing or locked. +' - FSOUND_FX_Disable must be called to reset/clear the FX from a channel. + + +Public Declare Function FSOUND_FX_Enable Lib "fmod.dll" Alias "_FSOUND_FX_Enable@8" (ByVal channel As Long, ByVal fx As FSOUND_FX_MODES) As Long +Public Declare Function FSOUND_FX_Disable Lib "fmod.dll" Alias "_FSOUND_FX_Disable@4" (ByVal channel As Long) As Byte + +Public Declare Function FSOUND_FX_SetChorus Lib "fmod.dll" Alias "_FSOUND_FX_SetChorus@32" (ByVal fxid As Long, ByVal WetDryMix As Single, ByVal Depth As Single, ByVal Feedback As Single, ByVal Frequency As Single, ByVal Waveform As Long, ByVal Delay As Single, ByVal Phase As Long) As Byte +Public Declare Function FSOUND_FX_SetCompressor Lib "fmod.dll" Alias "_FSOUND_FX_SetCompressor@28" (ByVal fxid As Long, ByVal Gain As Single, ByVal Attack As Single, ByVal Release As Single, ByVal Threshold As Single, ByVal Ratio As Single, ByVal Predelay As Single) As Byte +Public Declare Function FSOUND_FX_SetDistortion Lib "fmod.dll" Alias "_FSOUND_FX_SetDistortion@24" (ByVal fxid As Long, ByVal Gain As Single, ByVal Edge As Single, ByVal PostEQCenterFrequency As Single, ByVal PostEQBandwidth As Single, ByVal PreLowpassCutoff As Single) As Byte +Public Declare Function FSOUND_FX_SetEcho Lib "fmod.dll" Alias "_FSOUND_FX_SetEcho@24" (ByVal fxid As Long, ByVal WetDryMix As Single, ByVal Feedback As Single, ByVal LeftDelay As Single, ByVal RightDelay As Single, ByVal PanDelay As Long) As Byte +Public Declare Function FSOUND_FX_SetFlanger Lib "fmod.dll" Alias "_FSOUND_FX_SetFlanger@32" (ByVal fxid As Long, ByVal WetDryMix As Single, ByVal Depth As Single, ByVal Feedback As Single, ByVal Frequency As Single, ByVal Waveform As Long, ByVal Delay As Single, ByVal Phase As Long) As Byte +Public Declare Function FSOUND_FX_SetGargle Lib "fmod.dll" Alias "_FSOUND_FX_SetGargle@12" (ByVal fxid As Long, ByVal RateHz As Long, ByVal WaveShape As Long) As Byte +Public Declare Function FSOUND_FX_SetI3DL2Reverb Lib "fmod.dll" Alias "_FSOUND_FX_SetI3DL2Reverb@52" (ByVal fxid As Long, ByVal Room As Long, ByVal RoomHF As Long, ByVal RoomRolloffFactor As Single, ByVal DecayTime As Single, ByVal DecayHFRatio As Single, ByVal Reflections As Long, ByVal ReflectionsDelay As Single, ByVal Reverb As Long, ByVal ReverbDelay As Single, ByVal Diffusion As Single, ByVal Density As Single, ByVal HFReference As Single) As Byte +Public Declare Function FSOUND_FX_SetParamEQ Lib "fmod.dll" Alias "_FSOUND_FX_SetParamEQ@16" (ByVal fxid As Long, ByVal Center As Single, ByVal Bandwidth As Single, ByVal Gain As Single) As Byte +Public Declare Function FSOUND_FX_SetWavesReverb Lib "fmod.dll" Alias "_FSOUND_FX_SetWavesReverb@20" (ByVal fxid As Long, ByVal InGain As Single, ByVal ReverbMix As Single, ByVal ReverbTime As Single, ByVal HighFreqRTRatio As Single) As Byte + +' ========================= */ +' File Streaming functions. */ +' ========================= */ + +' +' Note : Use FSOUND_LOADMEMORY flag with FSOUND_Stream_Open to stream from memory. +' Use FSOUND_LOADRAW flag with FSOUND_Stream_Open to treat stream as raw pcm data. +' Use FSOUND_MPEGACCURATE flag with FSOUND_Stream_Open to open mpegs in 'accurate mode' for settime/gettime/getlengthms. +' Use FSOUND_FREE as the 'channel' variable, to let FMOD pick a free channel for you. +' + +Public Declare Function FSOUND_Stream_SetBufferSize Lib "fmod.dll" Alias "_FSOUND_Stream_SetBufferSize@4" (ByVal ms As Long) As Byte + +Public Declare Function FSOUND_Stream_Open Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByVal filename As String, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long +Public Declare Function FSOUND_Stream_Open2 Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByRef data As Byte, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long +Public Declare Function FSOUND_Stream_Create Lib "fmod.dll" Alias "_FSOUND_Stream_Create@20" (ByVal callback As Long, ByVal length As Long, ByVal mode As Long, ByVal samplerate As Long, ByVal userdata As Long) As Long +Public Declare Function FSOUND_Stream_Close Lib "fmod.dll" Alias "_FSOUND_Stream_Close@4" (ByVal stream As Long) As Byte + +Public Declare Function FSOUND_Stream_Play Lib "fmod.dll" Alias "_FSOUND_Stream_Play@8" (ByVal channel As Long, ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_PlayEx Lib "fmod.dll" Alias "_FSOUND_Stream_PlayEx@16" (ByVal channel As Long, ByVal stream As Long, ByVal dsp As Long, ByVal startpaused As Byte) As Long +Public Declare Function FSOUND_Stream_Stop Lib "fmod.dll" Alias "_FSOUND_Stream_Stop@4" (ByVal stream As Long) As Byte + +Public Declare Function FSOUND_Stream_SetPosition Lib "fmod.dll" Alias "_FSOUND_Stream_SetPosition@8" (ByVal stream As Long, ByVal positition As Long) As Byte +Public Declare Function FSOUND_Stream_GetPosition Lib "fmod.dll" Alias "_FSOUND_Stream_GetPosition@4" (ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_SetTime Lib "fmod.dll" Alias "_FSOUND_Stream_SetTime@8" (ByVal stream As Long, ByVal ms As Long) As Byte +Public Declare Function FSOUND_Stream_GetTime Lib "fmod.dll" Alias "_FSOUND_Stream_GetTime@4" (ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_GetLength Lib "fmod.dll" Alias "_FSOUND_Stream_GetLength@4" (ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_GetLengthMs Lib "fmod.dll" Alias "_FSOUND_Stream_GetLengthMs@4" (ByVal stream As Long) As Long + +Public Declare Function FSOUND_Stream_SetMode Lib "fmod.dll" Alias "_FSOUND_Stream_SetMode@8" (ByVal stream As Long, ByVal mode As Long) As Byte +Public Declare Function FSOUND_Stream_GetMode Lib "fmod.dll" Alias "_FSOUND_Stream_GetMode@4" (ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_SetLoopPoints Lib "fmod.dll" Alias "_FSOUND_Stream_SetLoopPoints@12" (ByVal stream As Long, ByVal loopstartpcm As Long, ByVal loopendpcm As Long) As Byte +Public Declare Function FSOUND_Stream_SetLoopCount Lib "fmod.dll" Alias "_FSOUND_Stream_SetLoopCount@8" (ByVal stream As Long, ByVal count As Long) As Byte +Public Declare Function FSOUND_Stream_GetOpenState Lib "fmod.dll" Alias "_FSOUND_Stream_GetOpenState@4" (ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_GetSample Lib "fmod.dll" Alias "_FSOUND_Stream_GetSample@4" (ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_CreateDSP Lib "fmod.dll" Alias "_FSOUND_Stream_CreateDSP@16" (ByVal stream As Long, ByVal callback As Long, ByVal Priority As Long, ByVal userdata As Long) As Long + +Public Declare Function FSOUND_Stream_SetEndCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetEndCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte +Public Declare Function FSOUND_Stream_SetSyncCallback Lib "fmod.dll" Alias "_FSOUND_Stream_SetSyncCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte + +Public Declare Function FSOUND_Stream_AddSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_AddSyncPoint@12" (ByVal stream As Long, ByVal pcmoffset As Long, ByVal name As String) As Long +Public Declare Function FSOUND_Stream_DeleteSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_DeleteSyncPoint@4" (ByVal point As Long) As Byte +Public Declare Function FSOUND_Stream_GetNumSyncPoints Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumSyncPoints@4" (ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_GetSyncPoint Lib "fmod.dll" Alias "_FSOUND_Stream_GetSyncPoint@8" (ByVal stream As Long, ByVal index As Long) As Long +Public Declare Function FSOUND_Stream_GetSyncPointInfo Lib "fmod.dll" Alias "_FSOUND_Stream_GetSyncPointInfo@8" (ByVal point As Long, ByRef pcmoffset As Long) As Long + +Public Declare Function FSOUND_Stream_SetSubStream Lib "fmod.dll" Alias "_FSOUND_Stream_SetSubStream@8" (ByVal stream As Long, ByVal index As Long) As Byte +Public Declare Function FSOUND_Stream_GetNumSubStreams Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumSubStreams@4" (ByVal stream As Long) As Long +Public Declare Function FSOUND_Stream_SetSubStreamSentence Lib "fmod.dll" Alias "_FSOUND_Stream_SetSubStreamSentence@12" (ByVal stream As Long, ByRef sentencelist As Long, ByVal numitems As Long) As Byte + +Public Declare Function FSOUND_Stream_GetNumTagFields Lib "fmod.dll" Alias "_FSOUND_Stream_GetNumTagFields@8" (ByVal stream As Long, ByRef num As Long) As Byte +Public Declare Function FSOUND_Stream_GetTagField Lib "fmod.dll" Alias "_FSOUND_Stream_GetTagField@24" (ByVal stream As Long, ByVal num As Long, ByRef tagtype As Long, ByRef name As Long, ByRef value As Long, ByRef length As Long) As Byte +Public Declare Function FSOUND_Stream_FindTagField Lib "fmod.dll" Alias "_FSOUND_Stream_FindTagField@20" (ByVal stream As Long, ByVal tagtype As Long, ByVal name As String, ByRef value As Long, ByRef length As Long) As Byte + +' +' Internet streaming functions +' + +Public Declare Function FSOUND_Stream_Net_SetProxy Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetProxy@4" (ByVal proxy As String) As Byte +Public Declare Function FSOUND_Stream_Net_GetLastServerStatus Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetLastServerStatus@0" () As Long +Public Declare Function FSOUND_Stream_Net_SetBufferProperties Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetBufferProperties@12" (ByVal buffersize As Long, ByVal prebuffer_percent As Long, ByVal rebuffer_percent As Long) As Byte +Public Declare Function FSOUND_Stream_Net_GetBufferProperties Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetBufferProperties@12" (ByRef buffersize As Long, ByRef prebuffer_percent As Long, ByRef rebuffer_percent As Long) As Byte +Public Declare Function FSOUND_Stream_Net_SetMetadataCallback Lib "fmod.dll" Alias "_FSOUND_Stream_Net_SetMetadataCallback@12" (ByVal stream As Long, ByVal callback As Long, ByVal userdata As Long) As Byte +Public Declare Function FSOUND_Stream_Net_GetStatus Lib "fmod.dll" Alias "_FSOUND_Stream_Net_GetStatus@20" (ByVal stream As Long, ByRef status As Long, ByRef bufferpercentused As Long, ByRef bitrate As Long, ByRef flags As Long) As Byte + +'/* =================== */ +'/* CD audio functions. */ +'/* =================== */ + + +' Note : 0 = default cdrom. Otherwise specify the drive letter, for example. 'D'. + + +Public Declare Function FSOUND_CD_Play Lib "fmod.dll" Alias "_FSOUND_CD_Play@8" (ByVal drive As Byte, ByVal Track As Long) As Byte +Public Declare Function FSOUND_CD_SetPlayMode Lib "fmod.dll" Alias "_FSOUND_CD_SetPlayMode@8" (ByVal drive As Byte, ByVal mode As FSOUND_CDPLAYMODES) As Long +Public Declare Function FSOUND_CD_Stop Lib "fmod.dll" Alias "_FSOUND_CD_Stop@4" (ByVal drive As Byte) As Byte +Public Declare Function FSOUND_CD_SetPaused Lib "fmod.dll" Alias "_FSOUND_CD_SetPaused@8" (ByVal drive As Byte, ByVal Paused As Byte) As Byte +Public Declare Function FSOUND_CD_SetVolume Lib "fmod.dll" Alias "_FSOUND_CD_SetVolume@8" (ByVal drive As Byte, ByVal volume As Long) As Byte +Public Declare Function FSOUND_CD_SetTrackTime Lib "fmod.dll" Alias "_FSOUND_CD_SetTrackTime@8" (ByVal drive As Byte, ByVal ms As Long) As Byte +Public Declare Function FSOUND_CD_OpenTray Lib "fmod.dll" Alias "_FSOUND_CD_OpenTray@8" (ByVal drive As Byte, ByVal openState As Byte) As Byte + +Public Declare Function FSOUND_CD_GetPaused Lib "fmod.dll" Alias "_FSOUND_CD_GetPaused@4" (ByVal drive As Byte) As Byte +Public Declare Function FSOUND_CD_GetTrack Lib "fmod.dll" Alias "_FSOUND_CD_GetTrack@4" (ByVal drive As Byte) As Long +Public Declare Function FSOUND_CD_GetNumTracks Lib "fmod.dll" Alias "_FSOUND_CD_GetNumTracks@4" (ByVal drive As Byte) As Long +Public Declare Function FSOUND_CD_GetVolume Lib "fmod.dll" Alias "_FSOUND_CD_GetVolume@4" (ByVal drive As Byte) As Long +Public Declare Function FSOUND_CD_GetTrackLength Lib "fmod.dll" Alias "_FSOUND_CD_GetTrackLength@8" (ByVal drive As Byte, ByVal Track As Long) As Long +Public Declare Function FSOUND_CD_GetTrackTime Lib "fmod.dll" Alias "_FSOUND_CD_GetTrackTime@4" (ByVal drive As Byte) As Long + +'/* ============== */ +'/* DSP functions. */ +'/* ============== */ + + +' DSP Unit control and information functions. +' These functions allow you access to the mixed stream that FMOD uses to play back sound on. + + +Public Declare Function FSOUND_DSP_Create Lib "fmod.dll" Alias "_FSOUND_DSP_Create@12" (ByVal callback As Long, ByVal Priority As Long, ByVal param As Long) As Long +Public Declare Function FSOUND_DSP_Free Lib "fmod.dll" Alias "_FSOUND_DSP_Free@4" (ByVal unit As Long) As Long +Public Declare Function FSOUND_DSP_SetPriority Lib "fmod.dll" Alias "_FSOUND_DSP_SetPriority@8" (ByVal unit As Long, ByVal Priority As Long) As Long +Public Declare Function FSOUND_DSP_GetPriority Lib "fmod.dll" Alias "_FSOUND_DSP_GetPriority@4" (ByVal unit As Long) As Long +Public Declare Function FSOUND_DSP_SetActive Lib "fmod.dll" Alias "_FSOUND_DSP_SetActive@8" (ByVal unit As Long, ByVal active As Integer) As Long +Public Declare Function FSOUND_DSP_GetActive Lib "fmod.dll" Alias "_FSOUND_DSP_GetActive@4" (ByVal unit As Long) As Byte + + +' Functions to get hold of FSOUND 'system DSP unit' handles + + +Public Declare Function FSOUND_DSP_GetClearUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetClearUnit@0" () As Long +Public Declare Function FSOUND_DSP_GetSFXUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetSFXUnit@0" () As Long +Public Declare Function FSOUND_DSP_GetMusicUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetMusicUnit@0" () As Long +Public Declare Function FSOUND_DSP_GetFFTUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetFFTUnit@0" () As Long +Public Declare Function FSOUND_DSP_GetClipAndCopyUnit Lib "fmod.dll" Alias "_FSOUND_DSP_GetClipAndCopyUnit@0" () As Long + + +' Miscellaneous DSP functions +' Note for the spectrum analysis function to work, you have to enable the FFT DSP unit with +' the following code FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE); +' It is off by default to save cpu usage. + + +Public Declare Function FSOUND_DSP_MixBuffers Lib "fmod.dll" Alias "_FSOUND_DSP_MixBuffers@28" (ByVal destbuffer As Long, ByVal srcbuffer As Long, ByVal length As Long, ByVal freq As Long, ByVal Vol As Long, ByVal pan As Long, ByVal mode As Long) As Byte +Public Declare Function FSOUND_DSP_ClearMixBuffer Lib "fmod.dll" Alias "_FSOUND_DSP_ClearMixBuffer@0" () As Long +Public Declare Function FSOUND_DSP_GetBufferLength Lib "fmod.dll" Alias "_FSOUND_DSP_GetBufferLength@0" () As Long +Public Declare Function FSOUND_DSP_GetBufferLengthTotal Lib "fmod.dll" Alias "_FSOUND_DSP_GetBufferLengthTotal@0" () As Long +Public Declare Function FSOUND_DSP_GetSpectrum Lib "fmod.dll" Alias "_FSOUND_DSP_GetSpectrum@0" () As Long + +'/* =================================================================================== */ +'/* Reverb functions. (eax2/eax3 reverb) (ONLY SUPPORTED ON WIN32 W/ FSOUND_HW3D FLAG) */ +'/* =================================================================================== */ + + +' See top of file for definitions and information on the reverb parameters. + +'The FSOUND_REVERB_PRESETS have not been included in VB yet so they cannot yet be used here... +Public Declare Function FSOUND_Reverb_SetProperties Lib "fmod.dll" Alias "_FSOUND_Reverb_SetProperties@4" (ByRef prop As FSOUND_REVERB_PROPERTIES) As Byte +Public Declare Function FSOUND_Reverb_GetProperties Lib "fmod.dll" Alias "_FSOUND_Reverb_GetProperties@4" (ByRef prop As FSOUND_REVERB_PROPERTIES) As Byte +Public Declare Function FSOUND_Reverb_SetChannelProperties Lib "fmod.dll" Alias "_FSOUND_Reverb_SetChannelProperties@8" (ByVal channel As Long, ByRef prop As FSOUND_REVERB_CHANNELPROPERTIES) As Byte +Public Declare Function FSOUND_Reverb_GetChannelProperties Lib "fmod.dll" Alias "_FSOUND_Reverb_GetChannelProperties@8" (ByVal channel As Long, ByRef prop As FSOUND_REVERB_CHANNELPROPERTIES) As Byte + +'/* ===================================================== */ +'/* Recording functions (ONLY SUPPORTED IN WIN32, WINCE) */ +'/* ===================================================== */ + + +' Recording initialization functions + + +Public Declare Function FSOUND_Record_SetDriver Lib "fmod.dll" Alias "_FSOUND_Record_SetDriver@4" (ByVal outputtype As Long) As Byte +Public Declare Function FSOUND_Record_GetNumDrivers Lib "fmod.dll" Alias "_FSOUND_Record_GetNumDrivers@0" () As Long +Public Declare Function FSOUND_Record_GetDriverName Lib "fmod.dll" Alias "_FSOUND_Record_GetDriverName@4" (ByVal id As Long) As Long +Public Declare Function FSOUND_Record_GetDriver Lib "fmod.dll" Alias "_FSOUND_Record_GetDriver@0" () As Long + + +' Recording functionality. Only one recording session will work at a time. + + +Public Declare Function FSOUND_Record_StartSample Lib "fmod.dll" Alias "_FSOUND_Record_StartSample@8" (ByVal sample As Long, ByVal loopit As Boolean) As Byte +Public Declare Function FSOUND_Record_Stop Lib "fmod.dll" Alias "_FSOUND_Record_Stop@0" () As Byte +Public Declare Function FSOUND_Record_GetPosition Lib "fmod.dll" Alias "_FSOUND_Record_GetPosition@0" () As Long + +'/* ========================================================================================== */ +'/* FMUSIC API (MOD,S3M,XM,IT,MIDI PLAYBACK) */ +'/* ========================================================================================== */ + + +' Song management / playback functions. + + +Public Declare Function FMUSIC_LoadSong Lib "fmod.dll" Alias "_FMUSIC_LoadSong@4" (ByVal name As String) As Long +Public Declare Function FMUSIC_LoadSongEx Lib "fmod.dll" Alias "_FMUSIC_LoadSongEx@24" (ByVal name As String, ByVal offset As Long, ByVal length As Long, ByVal mode As FSOUND_MODES, ByRef sentencelist As Long, ByVal numitems As Long) As Long +Public Declare Function FMUSIC_LoadSongEx2 Lib "fmod.dll" Alias "_FMUSIC_LoadSongEx@24" (ByRef data As Byte, ByVal offset As Long, ByVal length As Long, ByVal mode As FSOUND_MODES, ByRef sentencelist As Long, ByVal numitems As Long) As Long +Public Declare Function FMUSIC_GetOpenState Lib "fmod.dll" Alias "_FMUSIC_GetOpenState@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_FreeSong Lib "fmod.dll" Alias "_FMUSIC_FreeSong@4" (ByVal module As Long) As Byte +Public Declare Function FMUSIC_PlaySong Lib "fmod.dll" Alias "_FMUSIC_PlaySong@4" (ByVal module As Long) As Byte +Public Declare Function FMUSIC_StopSong Lib "fmod.dll" Alias "_FMUSIC_StopSong@4" (ByVal module As Long) As Byte +Public Declare Function FMUSIC_StopAllSongs Lib "fmod.dll" Alias "_FMUSIC_StopAllSongs@0" () As Long + +Public Declare Function FMUSIC_SetZxxCallback Lib "fmod.dll" Alias "_FMUSIC_SetZxxCallback@8" (ByVal module As Long, ByVal callback As Long) As Byte +Public Declare Function FMUSIC_SetRowCallback Lib "fmod.dll" Alias "_FMUSIC_SetRowCallback@12" (ByVal module As Long, ByVal callback As Long, ByVal rowstep As Long) As Byte +Public Declare Function FMUSIC_SetOrderCallback Lib "fmod.dll" Alias "_FMUSIC_SetOrderCallback@12" (ByVal module As Long, ByVal callback As Long, ByVal rowstep As Long) As Byte +Public Declare Function FMUSIC_SetInstCallback Lib "fmod.dll" Alias "_FMUSIC_SetInstCallback@12" (ByVal module As Long, ByVal callback As Long, ByVal instrument As Long) As Byte + +Public Declare Function FMUSIC_SetSample Lib "fmod.dll" Alias "_FMUSIC_SetSample@12" (ByVal module As Long, ByVal sampno As Long, ByVal sptr As Long) As Byte +Public Declare Function FMUSIC_SetUserData Lib "fmod.dll" Alias "_FMUSIC_SetUserData@8" (ByVal module As Long, ByVal userdata As Long) As Byte +Public Declare Function FMUSIC_OptimizeChannels Lib "fmod.dll" Alias "_FMUSIC_OptimizeChannels@12" (ByVal module As Long, ByVal maxchannels As Long, ByVal minvolume As Long) As Byte + + +' Runtime song functions + + +Public Declare Function FMUSIC_SetReverb Lib "fmod.dll" Alias "_FMUSIC_SetReverb@4" (ByVal Reverb As Byte) As Byte +Public Declare Function FMUSIC_SetLooping Lib "fmod.dll" Alias "_FMUSIC_SetLooping@8" (ByVal module As Long, ByVal looping As Byte) As Byte +Public Declare Function FMUSIC_SetOrder Lib "fmod.dll" Alias "_FMUSIC_SetOrder@8" (ByVal module As Long, ByVal order As Long) As Byte +Public Declare Function FMUSIC_SetPaused Lib "fmod.dll" Alias "_FMUSIC_SetPaused@8" (ByVal module As Long, ByVal Pause As Byte) As Byte +Public Declare Function FMUSIC_SetMasterVolume Lib "fmod.dll" Alias "_FMUSIC_SetMasterVolume@8" (ByVal module As Long, ByVal volume As Long) As Byte +Public Declare Function FMUSIC_SetMasterSpeed Lib "fmod.dll" Alias "_FMUSIC_SetMasterSpeed@8" (ByVal module As Long, ByVal speed As Single) As Byte +Public Declare Function FMUSIC_SetPanSeperation Lib "fmod.dll" Alias "_FMUSIC_SetPanSeperation@8" (ByVal module As Long, ByVal pansep As Single) As Byte + + +' Static song information functions + + +Public Declare Function FMUSIC_GetName Lib "fmod.dll" Alias "_FMUSIC_GetName@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetType Lib "fmod.dll" Alias "_FMUSIC_GetType@4" (ByVal module As Long) As FMUSIC_TYPES +Public Declare Function FMUSIC_GetNumOrders Lib "fmod.dll" Alias "_FMUSIC_GetNumOrders@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetNumPatterns Lib "fmod.dll" Alias "_FMUSIC_GetNumPatterns@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetNumInstruments Lib "fmod.dll" Alias "_FMUSIC_GetNumInstruments@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetNumSamples Lib "fmod.dll" Alias "_FMUSIC_GetNumSamples@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetNumChannels Lib "fmod.dll" Alias "_FMUSIC_GetNumChannels@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetSample Lib "fmod.dll" Alias "_FMUSIC_GetSample@8" (ByVal module As Long, ByVal sampno As Long) As Long +Public Declare Function FMUSIC_GetPatternLength Lib "fmod.dll" Alias "_FMUSIC_GetPatternLength@8" (ByVal module As Long, ByVal orderno As Long) As Long + + +' Runtime song information + + +Public Declare Function FMUSIC_IsFinished Lib "fmod.dll" Alias "_FMUSIC_IsFinished@4" (ByVal module As Long) As Byte +Public Declare Function FMUSIC_IsPlaying Lib "fmod.dll" Alias "_FMUSIC_IsPlaying@4" (ByVal module As Long) As Byte +Public Declare Function FMUSIC_GetMasterVolume Lib "fmod.dll" Alias "_FMUSIC_GetMasterVolume@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetGlobalVolume Lib "fmod.dll" Alias "_FMUSIC_GetGlobalVolume@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetOrder Lib "fmod.dll" Alias "_FMUSIC_GetOrder@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetPattern Lib "fmod.dll" Alias "_FMUSIC_GetPattern@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetSpeed Lib "fmod.dll" Alias "_FMUSIC_GetSpeed@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetBPM Lib "fmod.dll" Alias "_FMUSIC_GetBPM@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetRow Lib "fmod.dll" Alias "_FMUSIC_GetRow@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetPaused Lib "fmod.dll" Alias "_FMUSIC_GetPaused@4" (ByVal module As Long) As Byte +Public Declare Function FMUSIC_GetTime Lib "fmod.dll" Alias "_FMUSIC_GetTime@4" (ByVal module As Long) As Long +Public Declare Function FMUSIC_GetRealChannel Lib "fmod.dll" Alias "_FMUSIC_GetRealChannel@8" (ByVal module As Long, ByVal modchannel As Long) As Long +Public Declare Function FMUSIC_GetUserData Lib "fmod.dll" Alias "_FMUSIC_GetUserData@4" (ByVal module As Long) As Long + +'************ +'* Windows Declarations (Added by Adion) +'************ +'Required for GetStringFromPointer +Private Declare Function ConvCStringToVBString Lib "kernel32" Alias "lstrcpyA" (ByVal lpsz As String, ByVal pt As Long) As Long ' Notice the As Long return value replacing the As String given by the API Viewer. +'Required for the FFT/Spectral functions +Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal length As Long) + +'************ +'* FUNCTIONS (Added by Adion) +'************ +'Usage: myerrorstring = FSOUND_GetErrorString(FSOUND_GetError) +Public Function FSOUND_GetErrorString(ByVal errorcode As Long) As String + Select Case errorcode + Case FMOD_ERR_NONE: FSOUND_GetErrorString = "No errors" + Case FMOD_ERR_BUSY: FSOUND_GetErrorString = "Cannot call this command after FSOUND_Init. Call FSOUND_Close first." + Case FMOD_ERR_UNINITIALIZED: FSOUND_GetErrorString = "This command failed because FSOUND_Init was not called" + Case FMOD_ERR_PLAY: FSOUND_GetErrorString = "Playing the sound failed." + Case FMOD_ERR_INIT: FSOUND_GetErrorString = "Error initializing output device." + Case FMOD_ERR_ALLOCATED: FSOUND_GetErrorString = "The output device is already in use and cannot be reused." + Case FMOD_ERR_OUTPUT_FORMAT: FSOUND_GetErrorString = "Soundcard does not support the features needed for this soundsystem (16bit stereo output)" + Case FMOD_ERR_COOPERATIVELEVEL: FSOUND_GetErrorString = "Error setting cooperative level for hardware." + Case FMOD_ERR_CREATEBUFFER: FSOUND_GetErrorString = "Error creating hardware sound buffer." + Case FMOD_ERR_FILE_NOTFOUND: FSOUND_GetErrorString = "File not found" + Case FMOD_ERR_FILE_FORMAT: FSOUND_GetErrorString = "Unknown file format" + Case FMOD_ERR_FILE_BAD: FSOUND_GetErrorString = "Error loading file" + Case FMOD_ERR_MEMORY: FSOUND_GetErrorString = "Not enough memory " + Case FMOD_ERR_VERSION: FSOUND_GetErrorString = "The version number of this file format is not supported" + Case FMOD_ERR_INVALID_PARAM: FSOUND_GetErrorString = "An invalid parameter was passed to this function" + Case FMOD_ERR_NO_EAX: FSOUND_GetErrorString = "Tried to use an EAX command on a non EAX enabled channel or output." + Case FMOD_ERR_CHANNEL_ALLOC: FSOUND_GetErrorString = "Failed to allocate a new channel" + Case FMOD_ERR_RECORD: FSOUND_GetErrorString = "Recording is not supported on this machine" + Case FMOD_ERR_MEDIAPLAYER: FSOUND_GetErrorString = "Required Mediaplayer codec is not installed" + Case FMOD_ERR_CDDEVICE: FSOUND_GetErrorString = "An error occured trying to open the specified CD device" + Case Else: FSOUND_GetErrorString = "Unknown error" + End Select +End Function + +'Thanks to KarLKoX for the following function +'Example: MyDriverName = GetStringFromPointer(FSOUND_GetDriverName(count)) +Public Function GetStringFromPointer(ByVal lpString As Long) As String +Dim NullCharPos As Long +Dim szBuffer As String + + szBuffer = String(255, 0) + ConvCStringToVBString szBuffer, lpString + ' Look for the null char ending the C string + NullCharPos = InStr(szBuffer, vbNullChar) + GetStringFromPointer = Left(szBuffer, NullCharPos - 1) +End Function + +'These functions are added by Adion +Public Function GetSingleFromPointer(ByVal lpSingle As Long) As Single +'A Single is 4 bytes, so we copy 4 bytes +CopyMemory GetSingleFromPointer, ByVal lpSingle, 4 +End Function +'Warning: You should set the fft dsp to active before retreiving the spectrum +'Also make sure the array you pass is dimensioned and ready to use +'FSOUND_DSP_SetActive FSOUND_DSP_GetFFTUnit, 1 +Public Function GetSpectrum(ByRef Spectrum() As Single) +Dim nrOfVals As Long, lpSpectrum As Long +Dim a As Long +If UBound(Spectrum) > 511 Then nrOfVals = 512 Else nrOfVals = UBound(Spectrum) + 1 +lpSpectrum = FSOUND_DSP_GetSpectrum +CopyMemory Spectrum(0), ByVal lpSpectrum, nrOfVals * 4 +End Function diff --git a/lib/fmodapi375win/documentation/FMOD.chm b/lib/fmodapi375win/documentation/FMOD.chm new file mode 100644 index 0000000..989cc5e Binary files /dev/null and b/lib/fmodapi375win/documentation/FMOD.chm differ diff --git a/lib/fmodapi375win/documentation/Revision.txt b/lib/fmodapi375win/documentation/Revision.txt new file mode 100644 index 0000000..142f5ad --- /dev/null +++ b/lib/fmodapi375win/documentation/Revision.txt @@ -0,0 +1,1436 @@ + +====================================================================================== +REVISION HISTORY : FireMOD : Copyright (c) Firelight Technologies, Pty, Ltd, 1994-2005 + http://www.fmod.org +====================================================================================== + + Added feature or noticable improvement + - Bug fix or something removed + * Changed or Information +====================================================================================== + +15/12/05 3.75 +------------ + ++ PSP - Added PSP support! Contact sales@fmod.org for evaluation versions! ++ XBOX - Added FSOUND_INIT_XBOX_REMOVEHEADROOM for 2D sounds to disable the xbox + directsound 6db attenuation on all voices (to avoid clipping). + +- ALL - Fixed rare timing crash, mainly on HyperThreaded or Multi-Processor + machines, when calling FSOUND_Stream_SetPosition or FSOUND_Stream_Play. +- ALL - Sounds not starting paused properly issue fixed. +- ALL - Stability increase calling stream related commands from a sync callback. +- ALL - IMA ADPCM compressed multichannel FSB files with channel count = 2 + played as static fixed. +- ALL - Removed any references to ctype.h so linux has an easier time linking + on old glibc versions. +- ALL - .IT format - Pitch envelope under 'amiga frequencies' issue fixed. +- ALL - .IT format - Pan envelope not panning left issue fixed. +- ALL - .IT format - some songs with extremely high pitch notes were being + clamped by fmod's internal setfrequency function, so that has been + fixed. +- ALL - Fixed stream not opening with FSOUND_NONBLOCKING if + FSOUND_OUTPUT_NOSOUND_NONREALTIME was the output mode. +- ALL - Fixed rare stream crash if FSOUND_NONBLOCKING was used and ran out + of memory. +- ALL - Fixed ogg vorbis seeking causing odd audible playback for a few ms. +- ALL - Removed stall on FSOUND_Stream_SetSubStream or + FSOUND_Stream_SetSubStreamSentence if other streams were playing + simultaneously. +- ALL - Fixed FSOUND_SetMute not taking FSOUND_SetVolumeAbsolute into account + when unmuting. +- ALL - Fixed recording returning an error if fmod was closed then reinitialized +- ALL - Fixed rare failures in FSOUND_Sample_Load if a stream was openened + beforehand. +- LINUX - More OSS and ALSA compatibility fixes, should handle most cards without + a problem now. +- LINUX - Fixed lock on cd device after FSOUND_Close was called so tray wouldnt + eject. +- LINUX - ALSA output now cooperates with other applications better. +- WIN32/ + WIN64/ + WINCE - Fixed thread leak if recording was started and stopped. +- WINCE - Fixed last few milliseconds of mp3 files not playing. +- WINCE - Fixed new streams not being able to be started if memory card or + removable media was removed during playback. +- WINCE - Fixed memory leak. +- PS2 - Mute wasn't muting hardware voices properly. +- PS2 - Free up streams in FSOUND_Close to avoid hang. +- PS2 - Fixed memory leak when using FSOUND_NONBLOCKING and sample list feature + in FMUSIC_LoadSongEx. +- PS2 - Removed rare chance of buzzing noise if FSOUND_SetSpeakerMode was set + and FSOUND_Init had 0 software channels specified. +- PS2 - Fixed FSOUND_STEREOPAN coming out in right speaker with mono sounds. +- PS2 - Unblocked FSOUND_Stream_SetEndCallback from possibly causing a stall. +- MAC - Fixed critical section issues on OS9. +- XBOX - Fixed loop point clicking on PCM based hardware sounds. +- FSBANK - Fixed command line version not returning correct error code to dos. + Also stopped messagebox popping up when -h was specified. + +* WIN32 - CDDA streams now return -3 from FSOUND_Stream_GetOpenState when cd is + ejected. +* PS2 - FSOUND_IsDiskBusy now accepts a parameter to determine if a stream is + in the middle of a close (because stream close can cause blocking in + other functions if they are called while a stream is closing) + +11/11/04 3.741 (Mac only) +------------------------- + +- MAC - Fixed problems with playing Ogg Vorbis files. +- MAC - Fixed threading issues which was causing problems in mac classic. +- MAC - Added "Classic" target to all examples. + +18/10/04 3.74 +------------- + ++ GC - Added FSOUND_GC_PrepareForReset (see fmodgc.h) to prepare for software reset. + This kills streams so FSOUND_Close can be called safely even with the tray + door open. ++ GC - Added FSOUND_GetFreeHWRam to find out how much ARAM is free. ++ GC - Memory footprint lowered. ++ XBOX - FSOUND_Stream_OpenFromHandle added to allow dashboard tracks to be played + after using XOpenSoundtrackSong. + +- ALL - FSOUND_Stream_Play is now faster. +- ALL - Fixed FSOUND_SIGNED / FSOUND_UNSIGNED being ignored when FSOUND_LOADRAW in + FSOUND_Sample_Load/Ex. +- ALL - Stream fix when a stream opened with FSOUND_NONBLOCKING runs out of memory. +- ALL - Memory leak fixed in certain error situations trying to open a stream. +- ALL - Remove rare stream crash. +- ALL - Corruption when using compressed streams and stream loop points in rare cases + fixed. +- ALL - FSOUND_SetVolumeAbsolute not working on software mixed 3D voices or PS2/GC + hardware 3D voices. +- ALL - Fixed S3M arpeggio. +- ALL - Fixed an issue where on some platforms (xbox/gc/dsound) hardware voices would + enter an inconsistent state if channel that had played and ended was paused. +- WIN32 - ASIO Crash fix. +- LINUX - Fixed hang on OSS output if another device was using the same device. +- LINUX - Fixed crash when using ALSA by upgrading to the latest ALSA library. + (It was an ALSA crash not fmod!) +- MAC - Fixed crash on OS9 support. +- XBOX - FSOUND_IsPlaying / FSOUND_GetNumChannelsPlaying fixed when FSOUND_SetPaused + was used. +- XBOX - Sounds going quiet if FSOUND_Reverb_SetChannelProperties was called on 2d + channels fix. Now reverb channel properties are ignored if it is a 2d voice, + as the properties related to a 3d environment anyway. +- PS2 - Fixed crash on streams with loop points in VAG format. +- PS2 - Fixed stream priorities being 0 instead of 256 due to a sifcmd optimization + which lead to the undesirable effect of streams being stealable by the + channel priority system. +- GC - 3D sound rolloff algorithm updated to be consistant with other platforms. +- GC - Fixed unpaused sounds playing through all of ARAM in some cases. +- GC - Fixed audible glitch upon startup in certain cases. +- FSBANK - Fixed program stealing window focus when in hidden mode. + +* ALL - FMUSIC_SetSample now allows hardware samples specified for music files. This + means you can do things like use hardware VAG samples on PS2 in mod files. +* ALL - Renamed stream2 to userstream. +* PS2 - Exposed FSOUND_SetDiskBusy on IOP interface for IOP programmers. +* GC - Reduced memory fragmentation. + +01/06/04 3.73 +------------- + ++ ALL - FSOUND_CD_TrayOpen added. Now close or open is specified manually. ++ WIN32 - Added CD TOC retrieval as an FMOD tag. CDDB diskid generation added + to CDDA example. ++ WIN32 - Extended ASF/WMA tag support added. + +- ALL - FSOUND_Stream_GetTime and stream syncpoint fixes. +- WIN32 - CDDA pausing between tracks fix. +- FSBANK - Command line calls and list file parsing fix. +- GC - Memory alignment crash fix +- PS2 - FSOUND_Init/Close restart fix if FSOUND_INIT_PS2_USEVOLUMERAMPING was specified. +- ALL - FSOUND_CD_Eject removed in favour of FSOUND_CD_TrayOpen. + +* FSBANK - If FSOUND_HW3D is specified on a stereo sample an error is displayed. + + +23/04/04 3.72 +------------- + ++ WIN64 - AMD64 version of fmod available! fmod64.dll. + Runs in Windows XP 64 / Windows Server 2003. ++ ALL - FSOUND_Sample_SetDefaultsEx / FSOUND_Sample_GetDefaultsEx added. + Now includes random variation settings for frequency, volume and pan! ++ ALL - FSOUND_3D_SetMinMaxDistance / FSOUND_3D_GetMinMaxDistance added for per channel + min/max distance control. ++ ALL - 'fsb' example added. Shows loading of an FSB file as a non blocking sample bank, + then plays back the contents using the new random variation ++ WIN32 - Faster DirectSound support, due to many driver calls eliminated. This was + probably the cause of worse performance in FSOUND_HW3D mode than using the + FMOD software mixer. The software mixing mode probably still wins, but it + is better than it used to be. ++ WIN32 - WMA, ASF and WMV now run through FMOD DSP engine / streamer! You can now load + WMA files as samples, do DSP effects and spectrum analysis on these files. ++ WIN32 - ASIO output channels made enumerable and selectable through FSOUND_SetDriver. ++ PS2 - Optimizations on EE<->IOP communication with more EE side caching ++ PS2 - Added FSOUND_IOP_Alloc/Free. ++ PS2 - Added FSOUND_SPU2_Alloc/Free. ++ PS2 - Added FSOUND_SetADSR and FSOUND_SetADSRKeyoff ++ PS2 - Added FSOUND_SetSifCommandInfo, and a similar IOP mechanism for users wanting + to make FMOD cooperate with their own EE<->IOP sif command handlers. ++ PS2 - Stream2 example now shows VAG/ADPCM Hardware playback as well as PCM playback + and has an improved interface. ++ PS2 - 'streamwithdata' example added. This shows using FSOUND_SetDiskBusy, and also + loads game data at the same time without affecting the framerate. ++ PS2 - ShellMpeg example added! This example makes the Sony Shell mpeg movie player + example use FMOD via PCM or ADPCM using a custom FMOD stream. ++ PS2 - Added FMUSIC_SetRowCallback, FMUSIC_SetOrderCallback, FMUSIC_SetZxxCallback and + FMUSIC_SetInstCallback support. ++ PS2 - Added fmodps2iop.h to expose FMOD file and memory routines to IOP programmers. ++ XBOX - Reverb on 2d voices is now possible by calling FSOUND_Reverb_SetChannelProperties. ++ XBOX - FSOUND_Output_XBox_GetEffectImageDesc added in fmodxbox.h ++ CE - FSOUND_File_HasFatalErrorOccurred and FSOUND_HasPowerOnOccurred added in fmodce.h. + ++ FSBANK - Now available as a programmers library! Make your own FSB files without + fsbank.exe! See fsbank.lib, fsbank.h and fsbank.chm. ++ FSBANK - FSBank now allows list files to specify sample defaults and randomization parameters per sound. + +- ALL - FSOUND_Sample_SetMaxPlaybacks fixed when using hardware samples. +- ALL - Voice stealing fix with FSOUND_FREE. +- ALL - FSOUND_IsPlaying / endcallbacks on streams not reacting in time when + FSOUND_INIT_STREAM_FROM_MAIN_THREAD bugfix. +- ALL - mod/s3m/xm fix with pattern loop. +- ALL - mod/s3m/xm/it. Non looping songs now play the very last row instead of cutting it off. +- ALL - .it files now respect the FMUSIC_SetLooping command! +- ALL - FMUSIC_SetOrder now cleans up/resets old channels so skipping to a new part of the song + doesn't cause weird playback issues. +- ALL - FMUSIC_GetRealChannel fix for non playing music channels. +- ALL - Loop points on natively compressed sounds (xadpcm,gcadpcm,vag) working again. +- ALL - ADPCM compressed FSB support fixed. +- WIN32 - Analogue and Digital CDROM support fixes. +- WIN32 - FSOUND_HW3D support now drops back to directsound software buffers instead of fmod + software mixed buffers to remove the issue of latency and possible skipping on + some soundcards due to bad drivers. It avoids the need to have to play with the + mixer buffersize (FSOUND_SetBufferSize). 32 'hardware' voices are now reported + if the card actually has no voices. +- GC - Bugfixes. Stereo sound fixes, crash fixes, pause/unpause fixes and more. +- PS2 - IRX files symbol stripped, now around 130k smaller for each file. +- PS2 - FSOUND_GetPaused fixed with streams that are started paused. +- PS2 - FSOUND_SetDiskBusy now does not block other FMOD commands if executed from another + thread asynchronously. (ie if the game has a threaded filesystem). +- PS2 - Memory saving. 200k on the EE. +- LINUX - Ensoniq 1371 latency fix. +- LINUX - FSOUND_Init stalls/timeouts removed from various dodgy soundcards. +- LINUX - OSS Recording bugs fixed. +- CE - Streams now stop gracefully instead of hanging the thread if a poweron occurs and the file handle + to the stream on a CF card or external medium is lost. +- FSBANK - Many bugfixes. + +* ALL - FSOUND_GetNumHardwareChannels renamed to FSOUND_GetNumHWChannels to give more + information including 2d and 3d channels seperately. +* ALL - FSB files now allow mixture of mono and stereo sounds in the one bank. + FSOUND_Stream_SetSubStreamSentence will fail if it encounters a sentence with mixed + formats but functions like FSOUND_Stream_SetSubStream will work. +* ALL - FSOUND_INIT_ENABLEOUTPUTFX renamed to FSOUND_INIT_ENABLESYSTEMCHANNELFX. + +14/11/03 3.71 +------------- ++ WIN32 - CDDA support. Now you can perform cd ripping, spectrum analysis or DSP effects + on CD audio. See FSOUND_Stream_Open and FSOUND_Stream_SetSubStream. ++ PS2 - New FSOUND_SPEAKERMODE_PROLOGIC2_INTERIOR speakermode added as an alternative + to FSOUND_SPEAKERMODE_PROLOGIC2. This method cuts number of sound playbacks to + 24 at once instead of 48, but supports interior panning. Probably not needed in + most games. + +- ALL - FSOUND_Close and stream thread safety fixes for extra stability especially when + using end callbacks. +- ALL - Buffered file system fix to avoid strangely playing streams. +- ALL - Using FSOUND_Stream_SetTime in conjunction with FSOUND_FORCEMONO fix. +- ALL - (except CE and PS2) - Chirping noise fix when not using FSOUND_MPEGACCURATE when + seeking in an mp3. +- ALL - Possible OXM format memory leaks removed. +- WIN32 - WMA tag support fix. +- WIN32 - MP3 static fixed, when playing 2 mp3s at once or loading an mp3 sample while + streaming an mp3 simultaneously, on hyperthreaded cpus. +- LINUX - FSOUND_Close hang fixed. +- PS2 - Sync callback support added +- PS2 - IOP memory leak in the kernel if FSOUND_Init and FSOUND_Close was called +- PS2 - Corruption noise removed in streams if the stream buffersize wasnt big enough and + a stream tried to restart after buffer underrun. +- PS2 - Prologic 2 support fixes in the original PL2 mode. +- CE - Small glitch noise removed when stopping and starting an mp3 stream. +- MAC - linker issues resolved with mach-o build on certain versions of OSX. +- MAC/GC - endian issue fixed with noisy samples in .IT files. + +* ALL - specifying FSOUND_8BITS in loading a sample will now force the sample depth + down to 8bits to save memory. OXM files now also downgrade decoded oggs back + to 8bit when loading if the original XM had them stored as 8bit. + +4/9/03 3.70 +------------- + ++ ALL - Shoutcast / Icecast / HTTP streaming support added! (mp3/ogg vorbis only). ++ ALL - Tag support, I3DV1, I3DV2, Ogg Tags, ASF/WMA tags now readable through api. ++ PS2 - Prologic 2 support now allows use of all 48 hardware channels, instead of 24. ++ PS2 - Delay and Feedback parameters on spu2 hardware reverb now supported through + EchoTime and EchoDepth parameters respectively. ++ WIN32 - FMOD Media Player updated with some new features. Lowpass cpu usage bug fixed. ++ ALL - NetStream example added to make it simpler to understand buffering logic etc. ++ ALL - Saving the recorded result to a wav file added. Shows how to Lock/Unlock a + sample. ++ ALL - FSOUND_Stream_*Sync* API changed around a bit / renamed. Now user points are + stored as a pointer instead of an index, and the 256 limit is removed. ++ WINCE - FSOUND_DSP_GetSpectrum now works! Integer FFT implemented for non FPU devices. + +- ALL - WAV/AIFF only. If a file had loop points embedded, then the mode (ie FSOUND_2D) + was being ignored, fixed. +- ALL - Memory leak fixed if any FSOUND_Stream_*Sync* functions were called with + FSOUND_NONBLOCKING and the stream wasnt ready yet. They now fail if not ready. +- WIN32 - WMA and FSOUND_NONBLOCKING now works. +- XBOX - 360kb or so of memory saved! Also DSSTDFX.BIN is no longer needed. +- PS2 - Ejected or corrupted CDs now recover smoothly on stream playback without making a noise. +- PS2 - FSOUND_Reverb_SetChannelProperties fix which was causing sound to dissapear. +- PS2 - Return values for most channel commands fixed, they were returning the wrong value. +- PS2 - Streams being truncated wth different stream length/buffersize combinations fixed. +- PS2 - FSOUND_GetPaused fixed. +- PS2 - Many other bugfixes. +- MAC - Recording bugfix dependent on OSX version. +- WINCE - fixed mp3 loading as sample bug, for files with corruption in them. + +* ALL - FMUSIC_LoadSongEx now takes an offset parameter for pak/wad/data file loading. +* ALL - FSOUND_Stream_OpenFile is now called FSOUND_Stream_Open and also takes an + offset parameter for pak/wad/data file loading. + +9/6/03 3.63 +------------- ++ ALL - FSBank updated. Now all platforms support compressed FSB formats. + Command line supported added. Source files can now be specified via a text + file, allowing ordering of sounds within fsb files. ++ ALL - FSB format now supports sample banks to hold any sound format that fmod can + load with FSOUND_Sample_Load, so for example you could have 1 fsb with + multiple mp3, ogg and wav files stored within it. ++ ALL - FSOUND_Stream_OpenFile with FSOUND_MPEGACCURATE is now 25% faster! ++ ALL - FSOUND_Stream_SetLoopCount added. ++ ALL - FSOUND_NONBLOCKING support added to FMUSIC_LoadSongEx! Now sample banks can + be loaded in the background. Use new FMUSIC_GetOpenState to poll status. ++ PS2 - Dolby Prologic 2 support added! Use FSOUND_SetSpeakerMode and + FSOUND_SPEAKERMODE_PROLOGIC2. Note that this mode uses 2 hardware voices + for every fmod channel, so the number of channels is effectively halved + from 48 to 24 when using this speaker mode. ++ PS2 - FSOUND_Update now 30-40% faster! ++ PS2 - File routines now split into fmodfile.irx so users can quickly compile or + hook into their own IOP file routines. ++ ALL - FSOUND_INIT_STREAM_FROM_MAIN_THREAD added. This causes FSOUND_Update to + drive the streamer thread. This is mainly because OS8/Macintosh doesnt + like streaming inside an MPTask, which is being worked on. This will work + around it. + +- WIN32 - DirectX 8/9 bug fixed which could cause a crash with FX or recording. +- ALL - FSOUND_Stream_SetTime is now sample accurate with mp3. (it previously + seeked and rounded the position to the nearest mpeg block). +- ALL - MP3 'chirp' noises when seeking (using FSOUND_Stream_SetTime or + FSOUND_Stream_SetPosition) reduced or removed completely. +- PS2 - FSOUND_IsPlaying bug fixes, Prologic 2 support! Hardware click removal! +- PS2 - Greater volume accuracy which removes 'wobbly' sound when using small + mindistances in 3D sound. +- MAC - conflict with cocoa libraries and the symbol _realloc removed. +- ALL - Strange doppler effect when sounds went outside maxdistance fixed. +- ALL - FSOUND_Stream_SynchPoint fixes. +- PS2 - FSB 16byte memleak fixed. +- ALL - AIFF loop point support fixed. +- WINCE - Loading MP3 as sample crash fix. +- WINCE - FSOUND_GetLengthMs fixed with MP3 files. +- FSBANK - Mixing 8 & 16bit sounds dissalowed. A stream is created in a particular + format (based on the first sample in an FSB), and if the first sound was + 8 bit but the rest were 16bit, the result would be noisy 16bit sounds. + +* ALL - win32/mac mainly. FSOUND_Update now yields, causes operating task switch + for smoother multitasking. You should call this function once a frame. +* MAC - fmod_cfm.shlb now only exports the relevant fmod symbols and not the MSL stuff. + +28/02/03 3.62 +------------- ++ GC - GameCube support added! ++ ALL - Added DirectX 9 support. You can now change frequency with + FSOUND_ENABLEFX enabled sounds. ++ ALL - Cross platform IMA ADPCM wav file support! Now you can use ADPCM + compression without windows codecs, and on any platform. ++ ALL - Recording support added to Mac and Linux ports! ++ ALL - FSOUND_Stream_SetMode and FSOUND_Stream_GetMode added to allow control + during playback, such as looping. ++ ALL - FSOUND_Stream_SetSubStreamSentence added! This allows for seamless + stitching/sentencing of streams. VERY useful for things like commentary + where you want parametized audio. FSB format only. ++ ALL - FSOUND_CD_SetTrackTime added. ++ PS2 - Now TRC compliant for sony submissions. ++ PS2 - Added multi-channel interleaved stream support! (FSB format only). If + stereo is 2 interleave channels (L/R), this format allows up to 16 + interleaved channels at once that play simultaneously. This eliminates + seeking and improves CD bandwidth, and also allows interactive music with + tracks that stay in perfect sync. ++ PS2 - FSOUND_Reverb_SetChannelAttributes supported, using Room parameter to make + channel wet/dry. ++ PS2 - Stereo and even 'multichannel' (see above) sample support in hardware. + (FSB format only). ++ WIN32 - New example 'multiple' shows how to load fmod dynamically, and also play + sounds out of 2 soundcards at the same time! ++ WINCE - New complete set of examples! 3d, simple, simplest etc are all included. ++ LINUX - Better compatibility for old cards. ALSA mode now allows device + enumeration. Electic Fence tested. ++ WIN32 - 24 and 32 bit PCM wav files supported! + +- ALL - FSOUND_SetSubStream fixed when in FSOUND_NONBLOCKING mode and mulitiple + calls are issued at once. +- ALL - FSOUND_Stream_SetEndCallback more accurate. +- PS2 - 'Corrupted' stream fix when usage of hardware channels were maxed out. +- PS2 - FSOUND_Stream_PlayEx was accidently blocking, fixed. +- PS2 - Multiple Listeners fix. +- PS2 - FSOUND_SetSFXMasterVolume fix for FSB banks. +- ALL - Stream timing, mod timing, and stream endcallbacks are now more accurate. +- MAC - OS8/9 support working again. + +* ALL - .FSB support is now cross platform. PS2, GameCube and XBox allow compressed + FSB data. +* WIN32 - Made fmod.h and examples more cygwin friendly. +* ALL - FMUSIC_LoadSongMemory is now changed to FMUSIC_LoadSongEx. This function + handles loading from memory and more. +* ALL - Frequency/Volume/Pan/3d position cached to reduce WIN32 driver call overhead? +* LINUX - fmoddyn.h updated and useable for linux. + +18/12/02 3.61 +------------- ++ ALL - Added FMUSIC_SetUserData and FMUSIC_GetUserData ++ ALL - Added FSOUND_3D_Listener_SetCurrent for multiple listener support! ++ ALL - Optimized Ogg Vorbis. Ogg decoding is now 2x faster! + Decoding is nearly 2x quicker than mp3! ++ WIN32 - A3D support re-added as an output mode only, for compatibility. ++ PS2 - Added FSOUND_Stream_SetSubStream/FSOUND_Stream_GetNumSubStreams, for FMOD + .FSB bank files are supported on PS2 Only. Cross platform support is coming. ++ WINCE - Added Ogg Vorbis support via fixed point Tremor API. ++ ALL - Added support for Neil Graham's .XM to .OXM converter. This tool converts + XM samples into ogg files, making them dramatically smaller. ++ WIN32 - Added dynamic loading header fmoddyn.h. This allows you to create multiple + instances of fmod = multiple soundcard output. ++ ALL - Added FSOUND_Stream_SetLoopPoints. ++ ALL - Added FSOUND_Stream_GetOpenState for determining the state of a non blocking stream open. ++ ALL - Added FSOUND_Stream_AddSynchPoint, FSOUND_Stream_DeleteSynchPoint, + FSOUND_Stream_GetNumSynchPoints for sync point manipulation. + Previously they were only available in .WAV or .AIFF files. ++ ALL - Added FSOUND_OUTPUT_NOSOUND_NONREALTIME. Calling FSOUND_Update drives the + software engine as fast as you like. + +- LINUX - Latency fixes. +- LINUX - OSS output now allows /dev/dsp* enumeration. +- PS2 - Numerous fixed and speedups. +- XBOX - Fixed WMA looping. +- WINCE - Added more power off/on support for some iPAQ models that didn't work before. +- WIN32 - Improved ASIO support! More drivers work now that didn't work before. +- WIN32 - CD playback bugfixes. +- WIN32 - MIDI 'caching' bug fixed. +- WIN32 - FSOUND_ALL support now works with WMA channels. +- WIN32 - Pan clicks removed from FSOUND_MIXER_QUALITY_FPU +- WINCE - FSOUND_Stream_GetTime / SetTime / GetLengthMs more accurate for mp3. +- ALL - Lots of memory optimizations. FMOD now uses less memory than ever. + +* FSOUND_3D_Listener_SetDopplerFactor renamed to FSOUND_3D_SetDopplerFactor. +* FSOUND_3D_Listener_SetDistanceFactor renamed to FSOUND_3D_SetDistanceFactor. +* FSOUND_3D_Listener_SetRolloffFactor renamed to FSOUND_3D_SetRolloffFactor. +* FSOUND_3D_Update renamed to FSOUND_Update + +16/08/02 3.6 (WIN32/CE/Linux/Mac/PS2/Xbox Release) +------------- + ++ PS2 - PlayStation 2 support added! ++ XBOX - XBox support added! ++ MAC - Macintosh support added! ++ LINUX - Major rewrite + support for ALSA 0.9! Vortex2 support now working 100%. ++ ALL - Added FSOUND_Sample_SetMaxPlaybacks. ++ ALL - 'Constant power pan' added to software engine for better sounding pans. ++ ALL - FSOUND_NONBLOCKING flag added for opening streams. (streams will open in background) ++ ALL - AIFF Support added with full loop point and sync marker support. ++ ALL - Ogg Vorbis support upgraded to 1.0 final codebase! ++ ALL - FMUSIC_SetLooping added. Music loops by default, so call to stop it looping. ++ ALL - FSOUND_GetCurrentLevels added which returns a seperate left and right VU level. ++ WIN32 - FSOUND_FX_Disable added, so that FSOUND_FX_Enable doesnt have to be called each time. ++ WIN32 - MP2 support optimized, significantly faster. ++ WIN32 & + WINCE - Wave-In recording support added. Now recording works in NT and PocketPC! ++ WINCE - BIDI Looping and negative frequencies now supported. ++ WINCE - Smartphone, CE 2.11 and BE-300 support added. + +- ALL - Better MP3 format detection. +- ALL - WAV sync markers now sorted if they are stored in the wav file out of order. +- ALL - 3d sound and setvolume bug fixed. +- ALL - XM apreggio was upside down on linear frequency tunes bug fixed. +- ALL - FSOUND_SetFrequency. negative followed by positive frequency now works properly. +- ALL - FSOUND_GetCurrentVU removed in favour of FSOUND_GetCurrentLevels. +- WIN32 - Midi fixes. FMUSIC_IsFinished fixed, FMUSIC_StopSong fixed, FMUSIC_LoadSongMemory fixed. +- WIN32 - A3D/Geometry support removed. Geometry may re-appear via FMOD instead of A3D support. +- WIN32 - Fixed DX8 FX (FSOUND_FX_xxx) support. +- WIN32 - Fixed CD Playback functions. +- WINCE - Better support for Casio E115G device. Use 200ms buffer for these devices. +- WINCE - Seeking through SetTime/SetPosition bugfix especially with FSOUND_MPEGACCURATE. +- LINUX - Removed CD access at FSOUND_Init. + +* ALL - maxdistance behaviour unified on all platforms. +* ALL - FSOUND_SPEAKERMODE_5POINT1 is now separated to FSOUND_SPEAKERMODE_DOLBYDIGITAL and + FSOUND_SPEAKERMODE_DTS. +* ALL - Changed FSOUND_INIT_ACCURATEGETCURRENTVU to FSOUND_INIT_ACCURATEVULEVELS. +* WIN32 - Stopping or playing a sound now does not reset the FX list. You have to manually + do this with FSOUND_FX_Disable. This reduces cpu usage if wanting to start and stop + the sound repeatedly. + +11/03/02 3.51 (CE Only release) +------------- ++ WINCE - FSOUND_GetCurrentVU support added ++ WINCE - Optimizations - All remaining emulated floats removed - now pure fixed point! + +- ALL - Memory usage reduced on MOD/S3M/XM/IT playback by up to 200-300kb per instance. +- ALL - Other small fixes. +- WINCE - FSOUND_Init failing on some PocketPC devices fixed. + +* ALL - FSOUND_FORCEMONO enabled by default when a stream or sample is attempted to be + opened with FSOUND_HW3D, so the user doesnt have to specify it manually. + +14/02/02 3.5 +------------- ++ FMOD CE Only. Mono mixers added! (FSOUND_MIXER_MONO and FSOUND_MIXER_QUALITY_MONO). + 30% faster than stereo! ++ EAX3 support added! Advanced reverb api now also supporting occlusion and obstruction. ++ FMOD CE Only. Automatic power off/on recovery! FMOD audio will resume as soon as the power + is turned back on the Pocket PC device with no programmer intervention! ++ Ogg Vorbis version update to 1.0 RC3. ++ New tutorials in the documentation! The basics, DSP tutorial, DX8 FX tutorial and spectrum + analysis. Documentation index revamped and updated. ++ FSOUND_SetMemorySystem added. Allows the user to fexibly control memory allocated by FMOD. ++ Multiple CDROM support added. Pass 0 for default, or 'D','E' etc to select the cd drive. ++ FSOUND_Stream_SetBufferSize added. Useful for streaming from CD when the default size isnt + big enough, and causes audio skips because the cd is being held up. ++ FSOUND_SetFrequency supports negative frequencies. Play sounds backwards! ++ FMOD media player allows seeking in mods and streams by clicking on progress bar ++ Linux version brought up to date. Thanks to SUSE distro guys for helping out. ++ FSOUND_GetCurrentVU latency adjusted (via FSOUND_Init flag), and now emulates a software + mixer giving perfect VU feedback. + +- Sound skips with streams removed by bigger default stream buffersize. (also on CE) +- Divide by 0 in linux version removed. +- Bug fixed where an item appeared on the windows taskbar for FMOD's cdrom handling code. +- Time accuracy bug fixed which affected gettime functions and sync callbacks. +- Fixed distortion on mp3 playback under FMOD CE. +- FSOUND_SetMute using FSOUND_ALL bugfix. +- DirectShow assert removed when an error occured loading wma. +- EAX1 support removed (superceeded by EAX2/EAX3). + +* FSOUND_FX api now allows multiple instances of the same effect per channel. +* Ability to 3d position stereo soures removed in software mode. Streams and samples now default + to FSOUND_STEREOPAN so they are louder. Use FSOUND_FORCEMONO on streams/samples to make them + 3d. +* Intel performance primitives for ARM were tested but removed due to insignificant speed increase. + +13/09/01 3.4 +------------ ++ DX8 fx support ++ Windows CE / PocketPC support added for handhelds! (such as compaq ipaq/casio/jornada etc). + CE support is considered in beta. See the forum at http://www.fmod.org for beta feedback. ++ Ogg Vorbis decoder upgraded to Version 1.0. 1.0 is a large quality improvement! ++ FSOUND_SetCurrentPosition added. ++ FSOUND_GetOutputHandle added to return dsound / waveout / a3d pointer. ++ FSOUND_SetSpeakerMode added. Get true dolby digital/DTS surround output through supported hardware! ++ FSOUND_DSP_GetFFTUnit and FSOUND_DSP_GetSpectrum added. It is now possible to get a spectrum + analysis of FMOD's mixer output in realtime. Great for graphics, beat detection and note detection. ++ FSOUND_PlaySoundEx added. Has 'paused' flag that allows the user to optinally start the sound + paused, set any attribute, and then unpause it later to start it playing. Also can takes + a DSP unit handle, which means channels can now attached or grouped to specific DSP units. ++ FSOUND_DSP_GetBufferLengthTotal for help with DSP buffersize calculations. ++ FSOUND_FORCEMONO flag added for samples/streams. Force stereo sounds to play as mono. ++ FSOUND_ENABLEFX flag added for samples/streams. Enables a sample/stream to use DX8 FX. ++ FSOUND_2DHW flag added for samples/streams. Allows 2d hardware acceleration. ++ "file://" support added for streams. ++ new sample in /samples/dsp added. This shows how to use the new DSP feature of + FSOUND_PlaySoundEx to have wet/dry effects, and also the FSOUND_FX_xxx API on hardware voices. + +- FSOUND_PlaySound3DAttrib removed due to FSOUND_PlaySoundEx. +- FSOUND_Stream_Play3DAttrib removed due to FSOUND_Stream_PlayEx. +- FSOUND_Stream_SetPaused & FSOUND_Stream_GetPaused removed. Use FSOUND_SetPaused, FSOUND_GetPaused instead. +- FSOUND_Stream_SetSynchCallback fix for long files. +- FSOUND_UNMANAGED flag fixed when calling FSOUND_Close. +- Removed small audible glitches or 'chirps' when seeking in an mp3 stream. +- Delay when opening a stream removed. +- Streams now reset's its buffers when FSOUND_Stream_SetTime or FSOUND_Stream_SetPosition is + called. This makes it more cpu intensive to seek, but results in no delays when seeking. +- Small accuracy bugfix in IT replay for looping envelopes. +- fix in delay note + volume envelope for XM. +- A3D Support fixed and working ok again. +- WMA/ASF/etc Support improved. + +* FMUSIC_SetInstCallback behaviour changed to support more than one instrument at a time. + +28/04/01 3.33 +------------- ++ Linux Version update. ++ FSOUND_ALL support added to FSOUND_Reverb_SetMix. + +- EAX2 bugfix with FSOUND_Reverb_GetEnvironmentAdvanced +- Click noise removed from WAV streams if FSOUND_Stream_SetTime was used before Play. +- S3M bugfix for samples with middlec of 0. +- Low quality mixers have been removed. The symbols are there for backwards compatibility + but choosing one will autodetect a quality mixer instead. +- Small bugfix in FPU quality mixer to do with volume ramping. + +* Licensees now get an extensive compile time configuration header to include or exclude as many + fmod features as they like! a stripped FMOD.DLL can be as small as 20k now. + +27/03/01 3.32 +------------- ++ FSOUND_SetVolume, FSOUND_SetPan & FSOUND_IsPlaying support for WMA/ASF/Internet + streams/etc added. Multiple wma's open at once bug fixed. ++ Excellent quality resonant lowpass code added to fmod.exe example. Source available. ++ FSOUND_INIT_GLOBALFOCUS added for directsound output, to allow sound to be heard + even though the window is out of focus. ++ OGG VORBIS - Official beta 4 release included. Previous ver was pre-release beta 4. + +- Recording interface re-enabled. +- MP2 fix - sound coming out one channel for stereo sounds now work properly. +- 3D sound glitch with FSOUND_PlaySound3DAttrib fixed. +- FSOUND_Stream_GetLengthMs returning incorrect results loading multiple mp3's fix. +- exception when loading many wav files fixed. +- MIDI updates - FMUSIC_GetTime works again and support for FMUSIC_IsFinished added +- Possible DX8 related problems removed. +- Better handling of machines with NO soundcard. + +* improved multitasking / buffering = lower cpu usage, more stability for sound output, + especially on weird configs and low spec machines. +* FMOD will now play the audio track out of AVI files - ie DIVX etc :) + +18/02/01 3.31 +------------- ++ WAV Loop point support added! FMOD will now interpret loop points set in soundforge etc. ++ OGG VORBIS - Beta 4 used with FMOD. Fixes problems and has speed benefits. ++ FMUSIC_SetInstCallback added. Get callbacks on mod type instrument numbers. ++ FSOUND_Stream_SetSynchCallback added. Visually drop markers in your wav editing package and + FMOD will callback in time to the points as the sound plays! Great for lipsynching/gfx + demos etc. WAV/RIFF mp3 only. ++ DX8 support added. ++ NT detection added. This will mean WINMM is automatically enabled if FSOUND_Output isnt + called for better performance. All other WIN32 OS'es will use DSOUND. ++ Static library project added for commercial licensees. + +- Extra MP3 error checking, avoids crash on bad mp3 files. (why are there so many?) +- Crash fix on certain combinations of machines with sblive cards. +- WMA / Internet stream support error code fix. +- WAV loader now handles files with 2 data chunks :) +- FSOUND_DSP_ClearMixBuffer now works properly. +- Fixed wobbling row/order/time when you pause a mod. +- small crack noise at the end of looping 8bit wav files fixed. +- FSOUND_Stream_GetTime improved especially with looping streams. +- Zxx sync bug with mod files fixed where more than 1 Zxx was placed on a row. +- XM multiretrig + volume column volume bug fix. + +- LINUX - Oss now opens the socket in nonblocking mode. That should take care of the + lockups some ppl got when another app was using the sound. +- LINUX - Esd now checks (via a select()) if it can send data, blocks if it can't. The + newest Elightment Sound Daemon choked on that one, and it's the Right Thing(tm) to do. + + +* A bug has been found in the win2k sblive drivers to do with volume levels on 3d sounds.. + We suggest you get the newest version. + +17/12/00 3.3 +------------ ++ Linux support added! Big thanks to Magnus Naeslund on this for such a big effort! ++ .MIDI/.RMI support added. (use FMUSIC_LoadSong) ++ .OGG (Ogg Vorbis) support added. (FSOUND_Stream_OpenFile/FSOUND_Sample_Load). ++ .MP2 (mpeg layer 2) support added. (FSOUND_Stream_OpenFile/FSOUND_Sample_Load). ++ .WMA Support added. (FSOUND_Stream_OpenFile). ++ .ASF audio Support added. (FSOUND_Stream_OpenFile). ++ Internet streaming support added! Pass a URL to FSOUND_Stream_OpenFile!!! ++ Volume Ramping ('click removal') added to MMX mixers. All quality mixers now ramp by default. ++ MP3 playback optimized. ++ Delphi and visual basic interface updated. ++ Documentation update. + ++ API changes and new features!!! - ++ FSOUND_Stream_GetLengthMs added. Returns length of stream in milliseconds. ++ FSOUND_Stream_SetTime added. Allows setting the position of a stream in ms. (even VBR mp3s!) ++ FSOUND_Stream_OpenFile added. This combines all the old 'FSOUND_Stream_Open*' commands into 1. ++ FSOUND_Stream_SetEndCallback added. Get a callback when the stream has finished! ++ FSOUND_Stream_GetSample added. Get the internal FSOUND_SAMPLE definition for a stream. ++ FSOUND_Stream_CreateDSP added. Add a DSP effect chain per stream if you want! ++ FSOUND_Stream_Play3DAttrib added. ++ FSOUND_CD_SetVolume and FSOUND_CD_GetVolume added. ++ FSOUND_CD_GetTrackTime added. Returns current track time. ++ FSOUND_CD_GetTrackLength added. Returns track length in milliseconds. ++ FSOUND_Sample_Load replaces all previous FSOUND_Sample_Load* functions. ++ FSOUND_Sample_GetName added. ++ FSOUND_PlaySound3DAttrib added. Replaces FSOUND_3D_PlaySound and FSOUND_PlaySoundAttrib. ++ FSOUND_SetLoopMode added for those who want per channel loop control not per sample. ++ FMUSIC_SetReverb added (for MIDI only currently) + ++ FSOUND_LOADMEMORY flag added which allows sample loading, and STREAMING from a memory pointer. ++ FSOUND_MPEGACCURATE flag added for FSOUND_Stream_SetTime and MP2/MP3. You can use this to get accurate time length, + and set the exact specified time in an MP3 even if it has a Variable BitRate!! (VBR) ++ FSOUND_ALL added to channel and sample flags. This allows 1 function call (to FSOUND_SetVolume + for example) and it will affect ALL channels! The possibilities are cool, such pitchbending all + sounds playing with FSOUND_SetFrequency(FSOUND_ALL, freqval); etc. + + +- Some mod based fixes including better support for corrupted files :} +- Click bug removed on single-shot (non looping) samples for software engine. +- Bug in mmx 8bit sample mixers fixed. +- Streaming files stutter bug upon start removed / lessened. +- MP3 frame filter added to remove corruption/glitches in bad mp3's. +- ADPCM wav file corruption introduced in 3.22 removed. +- FSOUND_Sample_SetLoopPoints bad parameter handling fixed. +- FSOUND_StopAllChannels removed in favour of FSOUND_ALL flag. fmod.dll is still backwards compatible. +- FSOUND_Sample_LoadWav removed in favour of FSOUND_Sample_Load. fmod.dll is still backwards compatible. +- FSOUND_Sample_LoadMpeg removed in favour of FSOUND_Sample_Load. fmod.dll is still backwards compatible. +- FSOUND_Sample_LoadRaw removed in favour of FSOUND_Sample_Load. fmod.dll is still backwards compatible. +- FSOUND_Sample_LoadWavMemory removed in favour of FSOUND_Sample_Load. fmod.dll is still backwards compatible. +- FSOUND_Sample_LoadMpegMemory removed in favour of FSOUND_Sample_Load. fmod.dll is still backwards compatible. +- FSOUND_Stream_Open removed in favour of FSOUND_Stream_OpenFile. fmod.dll is still backwards compatible. +- FSOUND_Stream_OpenWav removed in favour of FSOUND_Stream_OpenFile. fmod.dll is still backwards compatible. +- FSOUND_Stream_OpenMpeg removed in favour of FSOUND_Stream_OpenFile. fmod.dll is still backwards compatible. +- FSOUND_3D_PlaySound removed in favour of FSOUND_PlaySound3DAttrib. fmod.dll is still backwards compatible. +- FSOUND_PlaySoundAttrib removed in favour of FSOUND_PlaySound3DAttrib. fmod.dll is still backwards compatible. +- FSOUND_MIXER_QUALITY_FPU_VOLUMERAMP removed, all quality mixers are volume ramping now. +- FMOD_ERR_INVALID_MIXER error removed in favour of already existing FMOD_ERR_INVALID_PARAM flag. +- FSOUND_GetCurrentVU improved, and bugfixed for stereo samples. +- Other minor bugfixes. + +* Streamer callbacks created with FSOUND_Stream_Create must now return TRUE, or FALSE to terminate the stream. +* FSOUND_MixBuffers renamed to FSOUND_DSP_MixBuffers +* _cdecl calling convention specified for callbacks in case default calling convention is changed (thanks Aristarkh Zagorodnikov) +* changed LCC-WIN32 compiler definition in fmod.h to __LCC__ (not LCCWIN32) so it works better now :) + +05/11/00 3.21 +------------- +* Intermediate update before FMOD 3.3 is released. + ++ New, easier to navigate documentation layout. Recording interface added to documentation :) + +- End of non looping MP3 on rare combination of filelength crash fixed. +- More efficient streaming engine, mp3 and other format playback is even faster than before. +- Master Volume and FSOUND_SetVolumeAbsolute bug fixed. + +04/05/00 3.2 DX3 Patch +----------------------- ++ Improved playback stability with harddisk interruptions occuring in the background. +- DirectX versions *less than* DX7 compatibility problem fixed (most noticable under NT). This was thanks to bug in dsound API (thanks microsoft!) + + +01/05/00 3.2 +------------ +* FSOUND_NORMAL re-defined to (FSOUND_LOOP_OFF | FSOUND_8BITS | FSOUND_MONO), as in some + cases it was being mistaken for a bitfield and or'ed in with other flags when it infact wasnt. (it was 0!) +* FSOUND_EAX interface renamed to FSOUND_Reverb interface. (to fit a3d reverb, software reverb etc not just EAX) + ++ DX7 support added. This adds more hardware voices than previously possible before. ++ EAX 2.0 support added. This means advanced reverb functionality and manual occlusion control. ++ A3D 3.0 support added (FMOD comes with a3dapi.dll now). This adds A3D reverb and advanced reverb support. ++ RECORDING support added. See FSOUND_Record_StartSample, FSOUND_Record_StartWAV etc. ++ FSOUND_MIXER_QUALITY_FPU_VOLUMERAMP mixer added. This removes clicks on sudden volume changes for added quality. ++ MMX quality mixer speed increased AGAIN to crazy speeds! Check out the new comparison charts. ++ 'userdata' parameter added to FSOUND_Stream_Create. ++ FMOD Standalone player/example (fmod.exe). Added 48khz support, MP3,WAV & A3D 3 support! + Reverb added (NR button removed) and lowpass filter declicked. See FMOD.C for the code for all this! ++ New music callbacks! FMUSIC_SetRowCallback, FMUSIC_SetOrderCallback. LATENCY ADJUSTED, so when it calls back on a particular row, it is the row you HEAR. ++ FSOUND_Stream_GetTime smoother and LATENCY ADJUSTED, so when the time displays a value, that is the time into the stream that you HEAR. ++ FMUSIC_GetPatternLength added. (for time calculation purposes) ++ FSOUND_SetMinHardwareChannels and FSOUND_SetMaxHardwareChannels added. Great for controlling 3d Hardware resources. ++ FSOUND_REVERB_IGNOREPARAM added, so you can change specific elements of environmental reverb and ignore others. ++ Delphi interface added! ++ Added fmod_errors.h which contains FMOD_ErrorString. Use this in conjunction with FMOD_GetError to get a string description of the error. + +- PCM .WAV files accidentally did an ACM codec check even if it was PCM. Some machines didn't + have this PCM ACM codec, and so loadwav or openwav failed - ACM check now skipped for PCM files. +- FSOUND_GetCurrentVU fixed! +- 3D - Software engine bugfixed rolloff and distancefactor to make it sound more like DS3D. +- WAV/MP3 - streamer fixes and improvements. +- XM/IT - portamento with multi sample instruments fixed. +- API - FSOUND_Sample_Get somehow dissapeared from the DLL.. back again. +- API - MU-Law functions removed. +- Many other miscellaneous fixes. + +08/01/00 3.11 +------------- ++ RIFF based MP3 files and MP3's with ID3 tags at the start now supported. + +- LoadSongMemory fixed and works again +- Pentium Pro selecting wrong mixer upon autodetect now fixed. +- XM and IT bugfixes. + +24/12/99 3.1 +------------- + +* FMUSIC_OptimizeChannels put back into fmod.h. Im not sure why it dissapeared in the first place :) +* 'stream.exe sample' changed from WAV to a MP3 command line streamer because more people wanted that. +* LoadMemory functions now take a length (length of the buffer). You may have to change your code + to support this (it is not backward compatible with 3.0. I didnt want to add more functions to the + API for such a minor change. + ++ Variable bitrate MP3's now supported! ++ FSOUND_SetHWND added for those who want to specify their own HWND for dsound focus purposes. ++ FSOUND_Stream_GetTime added, for smooth, non lagged, accurate synchronization with stream + playback. + Use this for synchronizing MP3's to your graphics! ++ Added stability to sound output of software engine, for when harddisk accesses occur. + +- 8 bit raw wav streaming bug fixed where output was noisy. +- Streamer start/stop logic bug fixed/improved. (it used to hang on exit if you did several start/stops in a row) +- Small XM bugfix on delay note. +- Fixed startup crash bug. This was caused by BAD DRIVERS. Creative ES1370 sound card drivers + have a bug, and they have the cheek to set the certified bit in the caps. It also reports + 256 hardware 3d channels which is obviously a lie. Thanks to Marcus Aarts, Anders Nilsson and + Shane Stevens for helping me find this one. +- Documentation fixes. + + +12/12/99 3.0 +------------- + +* New timing system, no more update rate, no more mixahead! a lot more stable on shit cards + like awe64, and at the same time, very low latency. +* FSOUND_SetPanSeperation only affects sfx now, not music. +* If mixer is not selected, it defaults to a quality mixer now, not a low quality one like before. +* FSOUND_Geometry_AddPolygon now supplies normal as well AND opening factor. (it takes NULL also) +* FSOUND_3D_Listener_GetAttributes now consistant across all output types. (waveout missed out before) +* FSOUND_SetPaused now works on FSOUND_HW3D buffers. +* FSOUND_SetMute now works on FSOUND_HW3D buffers. +* FSOUND_MixChannel renamed to FSOUND_MixBuffers (it has nothing to do with channels really) +* FSOUND_Listener_SetAttributes does not update 3d info now, FSOUND_3D_Update does. + ++ Added FSOUND_File_SetCallbacks. Use this to make FMOD use your own file operations. ++ Compressed WAV support added ++ MP3 Support added ++ EAX Support added ++ A3D Support added (with full geometry and list support) ++ MMX quality mixer sped up 2-3 times on ppro+ machines! (p6/p2/p3) ++ FSOUND_Driver_GetCaps added.. Now query the capabilities of drivers before calling FSOUND_Init. ++ FSOUND_Stream_Create added - an easier way to stream data. ++ FMUSIC_SetPanSeperation added, for per song pan seperation control. ++ FSOUND_3D_Update added. This is now the global 3d update/flush function, NOT FSOUND_Listener_SetAttributes. ++ FSOUND_Geometry_Material functions implemented ++ Documentation added for geometry stuff, also other documentation updated (playsound, 3d stuff) ++ Software 3D Engine updated! Software sounds used to audibly update on + FSOUND_3D_Emitter_SetAttributes only, and not when the listener was updated. + Now they are updated on neither, they are audibly updated now in FSOUND_3D_Update. + This means you can now move the listener without updating the sources and all the sources will + update automatically! This behaves the same as DS3D now. ++ FSOUND_GEOMETRY_OPENING & FSOUND_GEOMETRY_OPENING_REFERENCE implemented! create doorways. ++ Geometry list functions added. A faster way of processing geometry. + FSOUND_Geometry_AddList(FSOUND_GEOMLIST *geomlist); + FSOUND_Geometry_List_Create(signed char boundingvolume); + FSOUND_Geometry_List_Free(FSOUND_GEOMLIST *geomlist); + FSOUND_Geometry_List_Begin(FSOUND_GEOMLIST *geomlist); + FSOUND_Geometry_List_End(FSOUND_GEOMLIST *geomlist); + FSOUND_Geometry_List_Add(FSOUND_GEOMLIST *geomlist); ++ Added FSOUND_SetBufferSize ++ Added FSOUND_DSP_GetBufferLength + +- FSOUND_Sample_Lock / FSOUND_Sample_Unlock documented properly (oops! :) +- Soak test bug caused wave out to crash after 3 hours of operation.. fixed. +- Fixed bug in FSOUND_Sample_Create +- Some module playback improvements from fmod 2.25. +- IT mod format bug fix. (NNA caused sample vibrato to lose integrity) +- Error code is now set to FMOD_ERR_NONE on all function calls, so you dont parse an error + that was set 10 function calls ago for example. +- NoSound output mode improved. +- Removed FSOUND_SetMixAhead +- Removed FSOUND_SetUpdateRate + +18/10/99 2.25 +------------- +* Version number now included in DLL. (right click on DLL for info) ++ IT - mods composed with IT versions older than 2.0 reenabled. I dont have many + of these songs and it seemed to work straight away and the songs i did have. + They sounded ok, but if there are any problems with old IT mods then mention + them to me and I might try to fix them. (theyre not high on my priority list) +- FMUSIC_SetZxxCallback did not have the correct documentation and just took a + void * as the callback. The actual format of the callback is + callback(FMUSIC_MODULE *mod, unsigned char param). FMUSIC_SetZxxCallback now + forces this. +- IT - Impulse tracker 2.15 compressed samples reenabled :) +- IT - FMOD was interpreting IT's stereo flag for samples, which was erroneously + set by older versions of IT, causing some samples to play twice as fast as they + should. Stereo check removed (IT never supported stereo samples) +- MOD S3M XM IT - Sample offset bug fixed. +- XM IT - minor bugs fixed. +- Closedown stability increased. + +31/08/99 2.24 +------------- +* This is the last FMOD 2.* update unless there are some small niggling bugs. I + need to finish 3.0. +* NOSOUND - FSOUND_OUTPUT_NULL now behaves as if everything is active, therefore + you will get all music callbacks and timers, vu meters, dsp functions and everything + else working correctly etc as if it was playing, but you dont hear anything. +* FMOD ported to N64. +* API - this version is now declared stable. It has been run over with memory leak + tools and numerous memory problems have been found and fixed. +* DSP - Note that the 'length' part of the callback now fluctuates more to increase + output stability, and its maximum size can equal up to the updaterate + mixahead + in milliseconds. +* TOOLS - convert.exe removed. use soundforge or some such program if you want to + convert a wav to a a raw signed datastream. + ++ API - New reference count channel index! The index PlaySound returns now has a + reference count in the top 16bits. This so you can call playsound, store the + return value, then if that channel gets stolen by the priority system, and you + blindy try and keep updating it as if it was from your original playsound, the + new sound wont be affected!! ++ API - FSOUND_Stream_OpenWav added. Now you can stream wav files with ease. This + version still only supports PCM wav, but FMOD 3.0 should change this situation. ++ API - FSOUND_SetSFXMasterVolume & FSOUND_GetSFXMasterVolume added. ++ API - FSOUND_SetVolumeAbsolute added. This volume overrides master volume. Great + if you need to lower the volume of your game effects and make one stand out. ++ MUSIC - FMUSIC_OptimizeChannels added! This function kicks arse if you are trying + to lower channel usage. You give it a 'channels mixed' value, and a 'mod volume' + value, and it wont play sounds in a song that have a lower volume than 'mod volume', + if 'channels mixed' is being exceeded as stated in FSOUND_GetChannelsPlaying. + One example is a game that reduced its maxchannels from 24 to 16 because of this + with no audible difference. (the song had a lot of 'echos' that didnt need to be + audible when things got noisy, so FMOD threw them away.) ++ MUSIC - FMUSIC_GetSample and FMUSIC_SetSample added! This allows you to get control + of samples within a mod! Great if you need to compress samples yourself and then + decompress them back into the mod during your game. This was in 2.23 but i forgot + to mention it here :) ++ STREAM - file streaming example added to the sample directory. Command line driven + and takes a .wav file. + +- 3D - Software doppler effect rewritten, now physically accurate :).. + FSOUND_3D_Listener_SetDopplerFactor() now means something different to the previous + versions. Check the documentation for more on this. +- DRIVER - fixed problem with some peoples machines that have more than 16 + 'soundcards' that i thought would be the maximum. (It is actually just a + hardware card enumerating a whole waveout device for each hardware channel.) +- INTERFACE - command line parameters fixed, and some people not seeing the interface + appear should now be happy. +- IT - channel allocation bug fixed. + +17/08/99 2.23 +-------------- ++ API - FSOUND_UNMANAGED flag added for sample loading/management ++ API - Added FSOUND_DSP_ClearMixBuffer. Use this before doing a biiiiiig harddisk access so you + dont get looping noise/stuttering, (because the harddisk/windows basically bus masters and shuts + down all threads, causing the mixer to stop as well, but the soundcard keeps playing the buffer). +- API - FSOUND_Sample_LoadWav & FSOUND_Sample_LoadWavMemory now return proper error code. +- MIXER - clicks removed from bidi looping sample in quality mixer. +- IT - fixed 2.15 compressed samples now work (oops forgot to call the right decompressor) +- IT - Memory footprint drastically reduced for pattern data (now leaves pattern data compressed and + unpacks on the fly) +- XM - Digitracker saved XM's now work correctly (dont crash, and illegal stuff filtered out) +- XM - envelope bug fixed. +- 3D - divide by 0 bug fixed (when listener and emitter are at the same location) +* API - Sample based functions like FSOUND_Sample_LoadWav etc take an index now, so you can specify + an absolute sample manager index, FSOUND_FREE or FSOUND_UNMANAGED + +18/06/99 2.22 rev 1 +------------------ +- IT - really obscure crash bug fixed. + +18/06/99 2.22 +------------------ +- MOD - accidently broke mod support, fixed +- S3M - fixed bug with bpm's smaller than 20h +- Idle optimization back in + +14/06/99 2.21 +------------------ +* Fix included from 2.2rev1 (registry bug in fmod standalone player) +* VC5 compatible import library included. vc6 only slipped into the last release. ++ IT 'envelope carry' support added. ++ MIXER - big increase in sound stability when harddisk is being accessed!! ++ LCC-WIN32 import library added. +- IT - crash bugfix. (envelopes with loop end before loop start) +- IT - volume bug (not hearing some samples at all) fixed in IT 'sample' mode. +- MOD S3M XM IT - fixed pattern delay bug +- DLL - size of DLL reduced by 12k! + +08/05/99 2.2 rev 1 +------------------ +- INTERFACE - fixed stupid registry bug which cause bad drivers to be initialized + at start up. It caused possible crashing, 000 channels mixed to be displayed + and no sound. + +16/05/99 2.2 +------------ +* FMOD is now a non beta release! +* MIXER - Changing driver on the fly with FSOUND_Driver_Close and + FSOUND_Driver_Init does not stop music playback any more. Everything + continues playing as it had been. +* API - Please read the new documentation on FSOUND_SetUpdateRate and + FSOUND_SetMixAhead!!!! This should remove confusion about what they do + and the issues of cpu usage, response time/latency and sound stability! ++ MIXER - FPU 32bit interpolating high quality mixer added! ++ API - FSOUND_Sample_SetLoopMode added ++ MOD - M!K! mod format supported. ++ INTERFACE - FMOD now saves sound settings in registry. +- API - Safety checking put into FSOUND_SetOutput, FSOUND_SetDriver, + FSOUND_SetMixer, FSOUND_SetUpdateRate and FSOUND_SetMixAhead. These + functions will fail and return an error code if FMOD is active and playing + sounds. You need to close FMOD down to call these functions, then + reinitialize it. FSOUND_Driver_Close and FSOUND_Driver_Init will fail also + if FSOUND has not been initialized with FSOUND_Init. +- MIXER - Fixed rare crash bug when background disk access caused timer + fluctuations. +- MIXER - Fixed rare sound output instability caused by closing and opening + fsound's driver code very quickly in succession. +- MIXER - Fixed crash bug on bidi samples playing backwards, at volume 0, + on the standard blendmode mixer only. (FPU Mixer also) +- MIXER - Fixed horrible fuzzy quality bug with MU-Law compressed samples! +- MIXER - Fixed standard blend mode mixer, which wasnt doing vol0 optimization + on -muted- channels. +- IT - fixed crash bug with mod that reference IT instruments beyond the + number of instruments. +- API - All 'interpolation functions' removed, if you want interpolation select + the FPU interpolating mixer and every sound played will use full 32bit + interpolation. (choosing which channels you want interpolated would end + up being a pain. Most people just want everything interpolated or not) +- CD - various CD player bugs fixed (random play, pause logic etc) +- API - FSOUND_GetCurrentVU now reports correct values for MuLaw compressed + samples. + +09/05/99 2.19b +-------------- +* API release, this includes changes/fixes from 2.18 Update 1 (cdrom fixes) +* Documentation updated +* FMOD is now approaching a non beta state! (no bug reports are coming in) + Beta status will most likely be removed in a few weeks (maybe version 2.20) +* API - FSOUND_SetLatency has been renamed to FSOUND_SetUpdateRate, sorry for + the name change but it is really the incorrect name for what this function does. ++ INTERFACE - Settings now saved in registry. New minimal CD Player panel! ++ CPU usage reduced during idle time. FMOD shuts itself down when nothing is happening. ++ API - FSOUND_Sample_Alloc now allows specification of default priority as well. ++ API - FSOUND_Sample_SetDefaults lets you set a sample's default freq,vol,pan & priority. ++ API - FSOUND_GetCurrentVU added, by request. (useful for vu bars/beat detection?) ++ API - FMUSIC_GetTime added, by request. Useful for exact music synchronization EVERY time. ++ API - FSOUND_GetCurrentSample added, allows you to get the currently playing sample for + a particular channel, useful for comparisons.. ie to see if a particular sample is still + playing on a particular channel. +- API - FSOUND_SetAttributes removed. It was added before due to a request but I + feel it is just API bloat and can be achieved through a macro. + +28/04/99 2.18b Update 1 (player only) +------------------------------------ +* FMOD - player only being updated here, not the API. API releases usually + come on the weekend. (they take more time to prepare) ++ CD - Added continuous, looped and random buttons for playback method. +- CD - All bugs fixed in CD player, all created by BUGS in WIN32 API + functions. (mmsystem & mci commands- some work ok on NT, fail on 95). +- Removed startup dialog box. Defaults to primary device and dsound. Hit config + to change. (maybe use registry later) + +25/04/99 2.18b +-------------- +* API - FSOUND_GetNumChannels renamed to FSOUND_GetMaxChannels ++ CD - New CD commands and support. FSOUND's CD system is a NON POLLING non + intrusive system (unlike windows cd player), for smooth background performance. + Tracks can now be looped, stopped and continued. ++ INTERFACE - new filters! Preverb filter(!) and Noise reduction. ++ INTERFACE - CD Player added. + +17/04/99 2.17b +-------------- +* API - FSOUNDVC.LIB now VC5.0 compatible. +- XM - Fixed crash on sample offset. +- API - FMUSIC_SetPaused fixed. +- MIXER - Fixed MULAW mixer. Remember MULAW only works when a song has 16bit + samples (it converts them to mulaw), otherwise it isn't any different. It + only works for the blend mode mixer as well. The MMX mixers are fast enough + not to need mulaw. + +11/04/99 2.16b +-------------- ++ API - DSP Engine implemented and added! New functions: + FSOUND_DSP_Create,FSOUND_DSP_Free,FSOUND_DSP_SetPriority, + FSOUND_DSP_GetPriority,FSOUND_DSP_SetActive, + FSOUND_DSP_GetActive,FSOUND_DSP_GetClearUnit, + FSOUND_DSP_GetSFXUnit,FSOUND_DSP_GetMusicUnit + FSOUND_DSP_GetClipAndCopyUnit. + See FSOUND_DSP_Create for documentation on this new feature. ++ API - Added FSOUND_MixChannel - now you have direct access to + FSOUND's optimized mixers! +- MOD, S3M, XM, IT - Fixed loader bug introduced in 2.15! (to do + with load from memory system.) +- XM - Found and fixed a sample offset bug introduced a few + versions ago, with 16bit samples. +- API - Echo engine and functions removed - DSP engine is now to + be used. +- API - Fixed bug in FMUSIC_SetOrder. +- API - Fixed bug in FSOUND_GetMixer, it was returning + FSOUND_MIXER_AUTODETECT if that was used in FSOUND_SetMixer, + instead of the actual mixer it was using. +- INTERFACE - loader bug fixed. + +28/03/99 2.15b +-------------- ++ API - Watcom now supported. Watcom users link in the + FSOUNDW.LIB import library. ++ API - Added FMUSIC_LoadSongMemory, now load mod/s3m/xm/it + files from memory handles / resources. ++ API - Added FSOUND_LoadWavMemory, now load wav files from + memory handles / resources. +- API - Fixed bug in FSOUND_Sample_Alloc which allocated samples + with length = 0, and hence no sound came out when played. +- SAMPLE - fixed bugs in fmod sample code. + +21/03/99 2.14b +-------------- +* FSOUND / FMUSIC is now a DLL. The reason is to use a dll is + to make it easier to link on different compilers, and it really + is for aesthetic reasons only to have it as a .lib. (ie 1 exe + releases) and im not interested. +* Examples cleaned up, they dont specify unused .libs any more. +- WAVEOUT - bugfixed, works on NT now, and now actually uses + setmixahead settings. You will have to use large mixaheads + (80-100 and higher on my tests) for WaveOut, or the sound will + break up. There is nothing you can do about this. +- DSOUND - works on NT now (DX3). This is the same as waveout + (dsound3 for nt is a waveout wrapper). You will have to use + large mixahead values (80-100ms and higher on my tests), or it + may break up. ++ API - FSOUND_SetAttributes added ++ API - FSOUND_PlaySoundAttrib added + +14/03/99 2.13b +-------------- +* Programmers API finally released! see + http://www.zip.com.au/~fl for more details! ++ MIXER Stereo sample mixers added. Old way of spawning 2 new + channels is gone.. Under MMX a stereo channel is actually + faster than mono! ++ S3M, XM, IT - Zxx callback now supported. Programmers can set + a callback function for whenever the Z effect is issued from a + song, for synchronizing effects etc. .MOD is not supported. ++ STREAMERS - Streamer API Added for playing very large files. + Currently only supports raw, but mulaw, adpcm and mp3 streamers + are coming. ++ MOD, S3M, XM, IT - Master volume added to API. + This is a true scalar instead of just modifying the song's + global volume like before (ie the song might have adjusted the + global volume after you set it) ++ INTERFACE - Master volume slider added. +- MIXER - Fixed extremely rare crash bug. +- MIXER - volumes were ever so slightly out, ie a channel + panned full right still had about 0.4% (not much) of the sound + playing in the left channel instead of 0% as it should have. +- MISC - many small fixes. + +04/02/99 2.12b +-------------- +- Fixed linear freq problem introduced due to linear freq + optimization, I just removed it now for accuracy sake. +* a little bit more stable? + +02/02/99 2.11b +-------------- +- Fixed BPM problem on all formats. Now loop songs should play ok. +- Fixed sample offset on all formats (oops sorry sample offset was + disabled on mod/s3m/xm since 2.06 accidentaly! noone seemed to + notice hahaha) + +31/01/99 2.10b +-------------- +- Minor Direct Sound bugs fixed. + +30/01/99 2.09b +-------------- +- IT bug fixed with instrument numbers and no note. (most + formats dont retrigger the note in this case, but IT does if + the sample has finished playing, and not before.) +- S3M Bug found in loader. (popped up only due to impulse + tracker saved s3ms). +- IT fixed porta wihout any previous note.. porta on on a + channel that has no channel playing will trigger a new note. +- DRIVER direct sound should work more reliably on NT using + directX. +- INTERFACE fixed song list box bug. Delete happily now without + problems. +- INTERFACE config box now remembers what you last set when you + hit config, and wont change any settings if you hit 'cancel' + (it used to select nosound before) +- DRIVER code now detects incompatible cpu's and exits with an + error instead of crashing? +- XM/IT replay sped up. Linear frequencies processed a lot + faster now. + +26/01/99 2.08b +-------------- ++ DRIVERS added capability to switch drivers on the fly. Use + the 'Config' Button on the interface to change output + devices, soundcards, mixing rates or mixing routines. ++ MIXER added Mu-Law support! This is only for NON-MMX mixing, + and improves the speed of 16bit sample mixing dramatically, with + only a small loss in sample quality. (simulates 12bit accuracy) +- MIXER fixed ugly bug (crashes/noise) with 8bit BIDI looping + samples on standard blend mode mixer. + +24/01/99 2.07b +-------------- ++ IT added volume byte portamentos ++ IT added S6x - Pattern delay by ticks ++ IT added volume byte vibrato ++ IT added sample vibrato +- IT fixed effect S73, S74, S75, S76, S77, S78. These commands + are meant to alter the behaviour of an instrument, except i was + permanently modifying the instrument instead of just altering it + for the note currently being played!! oops.. +- IT / XM - turn off envelopes that have less than 2 points. + (apparently sometimes files can have this) +- IT fixed Hxy Kxy Uxy (vibrato/finevibrato).. if Hxy is followed + by U00 then it continues to be a normal vibrato, even if it says + fine vibrato.. same for Uxy followed by H00.. it continues with + a fine vibrato even if it says normal vibrato.. The y part of + the command needs to have something in it to change vibrato + types. (dumb impulse tracker bug) +- IT fixed volume slide bug in Kxy Lxy +- IT foreground / background channel logic is more accuate now with + NNA's and effect commands. +- MOD, S3M, XM, IT - now checks internal signatures for file verification + as some people were trying to load mod's etc that were renamed to s3m! + yeah yeah thanks a lot otto ;) +- IT fixed S00 - any Sxy command gets remembered and replayed if it + is followed with S00.. (crono - not just SDx and SCx like you said) +- DSOUND fixed init/shutdown code to be cleaner. + + +20/01/99 2.06b +-------------- +- XM fixed BPM issue.. seems FT2's timer is a bit faster than it + really should be.. (roughly 2bpm) mega-sample-loop songs sound + ok now. +- IT another pattern loader crash bug fixed (should be the last) +- IT fixed Gxx bug (portamento).. IT forgets it porta target + after it reaches it. (TheHornet again) +- IT fixed Oxy (sample Offset) bug + +18/01/99 2.05b +-------------- +* MIXER Using large latency again just for fmod.exe with dsound, + to improve stability (im working on it) +- IT Fixed signed/unsigned sample detection in loader +- IT Disabled pitch envelopes for IT's using IIR filters so they + wont sound awful. +- XM Fixed crash bug in loader. + +17/01/99 2.04b +-------------- +* Mixer buffer management totally rewritten, might be a *tiny* + bit slower (becuase of caching), but it is a lot more flexible + and stable. Built in preparation of the DSP plugin API. +* Halved size of both MMX mixer routines (to do with surround) +* API ready to use. Now at beta test stage +* Thanks to TheHornet for his doc on it 'nuances' that were too + subtle to find through normal testing. (bugs found with (***)) +* New more consistant mixer thread management. ++ Volume 0 optimizations! Average mods will now use about 30% + less cpu time (depends on the song) ++ Standard blend mode mixer sped up for 8bit samples ++ Windows Multimedia WaveOut support added. At the moment it + works well but the latency is too long for game sfx. It is + more stable than the direct sound driver (less garbling / + breakups) ++ .WAV sample support added. ++ Stereo sample support added. ++ IT added linear frequencies. ++ IT added panbrello ++ IT added support for 'compatible Gxx' in IT's options +- MIXER Fixed volume 0 optimization hang bug. +- IT fixed effected E/F/G to use the same memory. +- IT fixed SDx delay note bug (SD0 == SD1) (***) +- IT fixed SCx note cut bug (SC0 == SC1) (***) +- IT fixed Qxy retrig (now retrigs across multiple notes like + IT.. other formats ignore retrig if it is higher than the + speed of the song) +- IT fixed Gxx / Lxy (portamento). was 2x too slow. +- IT fixed Vibrato for 'old effects'.. with old effects it is + 2x deeper and does not get updated on tick 0. +- MIXER OOPS! i had '#define ROLLED' left uncommented in my P6 + MMX mixer since version 2.0 or so!! it wasnt using unrolled + loops. Now it is roughly 1.6 times faster! (from 5% to 3% cpu + usage on a p2-266 for mixing 32channels at once) + +14/11/98 2.03b +-------------- ++ Added stability to mixer, removed 150ms crap from 2.02 + +07/11/98 2.02b +-------------- +* ALL players use a new dynamic channel allocation system +- consider MOD, S3M & XM under beta again. (MAY have + broken something!) +* MIXER in an attempt for added stability, for this standalone + player, a different approach is used.. it has a huge + latency (150ms) and takes a bit more cpu time, but shouldnt + break up as much .. for the game library the old method + still stands. (150ms is way too long to wait for a sound + effect to trigger.. so fmod uses 50ms latency for games etc) ++ IT Added NNA's ++ IT Added DCT/DCA's. ++ MIXER Added echo post effect.. hardcoded 50ms echo for now. ++ IT Added Pan Envelope ++ IT Added all volume column effects except for porta commands & + vibrato ++ INTERFACE Added drag and drop. Drag tunes from explorer into + the player to load ++ INTERFACE also command line fileloading (ie associate the exe + in explorer with mod,s3m,xm,it then just doubleclick files + to load them) ++ IT Added most other effects +- ALL Fixed some crashing for songs that specify sample id's that + dont exist. +- XM & IT Fixed Envelope bug - loops were playing 1 tick too long :) +- S3M fixed arpeggio bug causing 0 frequencies (divide by 0) +- IT fixed pattern break and pattern jump .. both params are + hex unlike all other formats. +- IT fixed arpeggio depth +- IT enabled end of song marker.. it was crashing on this b4 +- INTERFACE Fixed memory leak.. it would slowly leak memory in + realtime until windows ran out of resources and crashed! :) +- IT fixed porta bugs.. oops i was portamento'ing 2x too fast +- IT fixed instrument bug. it was updating all nna channel's + envelopes etc, using only the most recent nna's instrument + definition, instead of the instrument that should have been + associated with each individual nna channel. +- IT fixed set pan (Xxx) bug +- IT fixed invalid pattern bug with patterns defined that are + larger than the number of patterns specified in the file. +- IT fixed vibrato (Hxy) bug +- IT fixed big NNA bug.. i was performing NNA's based on the + new instrument's nna flags instead of the one it was + cutting off! +- IT fixed the past nna s7x effects.. now the number of channels + mixed on the interface matches exactly that of impulse + trackers! + +20/10/98 2.01b +-------------- ++ IT Added preliminary volume envelope support (no sustain loops) ++ IT Added channel volume slide ++ IT Added noteoff & notecut (not the effect, the note type) + +19/10/98 2.00b +-------------- +* First private release Version, includes MOD, S3M and XM and IT + support. New software mixers, win32 only. Removed 669,FAR & + MTM support, old interface is gone, new win32 interface.. + jeezus has it been 3 years? im getting too old for this shit:) +* IT Support is REALLY basic.. roughly 30% done. +- XM Fixed bug with envelope loopend. + + + +/|\ + | + | + | + | + + + +30/11/95 1.06 +------------- +* Released with FMODDOC 2, including full source code ++ Totally new fast scrolling interface, some keys have changed. ++ 32channel .MOD support added. (ie dope.mod type, etc) ++ 9 octaves supported now (C-0,B-8), including 7 octaves .MOD ++ No more 64kb sample limit (4gig sample on a GUS? :) ++ MTM support added ++ 669 support added - what an awful format! ++ extended 669 support added - just as bad :) ++ 16 bit support added (err for mtm? ahh well xm will come) ++ Clipping samples at loopend points to save GUS memory ++ S3M support added +- Bugfix where all music came out in left channel on SOME cards + (none I have heard:). Thanks to Brad Thomas for the fix. +- 2 GUS bugs fixed (reported wrong dram size & dram corruption) +* now checks if the samples are too big for the card. +- Voices now play almost simultaneously instead of 1 after the + other like before ++ Added Technicality-Index (tm) meter! Truly a cool feature. ++ Knocked 52% of DRAM upload time! YES it is *2* times faster!! + (eg when.s3m even loads *3* seconds faster than cmod does) +* - FIXED at last. FMOD will now NOT crash (fingers crossed :) +- removed clicking from looping samples +- Vibrato fixed properly this time and is 100%. +* Calculated new volume table. Not so noisy. Less distortion. ++ WildCard Support added! ++ S3M Stereo Control effect SAx added ++ Solo Channel feature added and many other muting features +- Fixed S3M retrig bug ++ Vibrato/Tremolo WaveControl finished properly ++ Keyboard LED flashing added! Lights flash to channels 1-3. +- tempo bug fixed, timing system changed so BPM can drop to 24 ++ FAR support added +* Sample loader redone and >64kb bug fixed, also pattern storage + method changed. +* Panning changed, now values from 0 to 255 to suit FT2. +- Pattern Loop bug fixed, I didnt know pattern loop stored + seperate values for each channel. +- pattern jump + pattern break bug fixed now all those weird + backwards tunes work RIGHT. ++ Added S3M's Fast Volume Slide bug, err feature :) +++ NOW PMODE! Load any sized tune you like now and still have + heaps of memory left ++ NEW tracker screen. Watch pattern data like a tracker +- Keyboard LED flashing removed, caused crashes on some + peoples computers.. sigh it was rather cool. ++ NEW technical info screen. Watch a lot of meaningless info + appear on the screen. Good for developers to check against. +- .MOD bug fixed, now those extremely high and low octaves + supported PROPERLY.. (unlike some cMOD players;) +- sample offset bug fixed. ++ Dynamic interface installed, now any screen can be called up + from any other screen, instead of just from the main screen + like before. +* Error handling changed for a lot better stability. ++ File Selector included for all those losers who wanted it :) ++ Added effect Ixy - Tremor - perfect I think unlike other + players.. compared against Scream Tracker 3 +- Fixed >64kb sample loading bug - was causing crashes +- Fixed MTM loader bug after about 6 hours of tearing out hair +* File Selector now accessable while song is still playing, + press escape to return to the main interface. +- sample uploader recoded, fixed. 16 bit samples now load + a lot better (this is actually from 1.07 which isnt released + yet and probably wont be for a while ;) +- a zillion little other bugs fixed. + +13/6/95 1.05 +------------- +- GUS looping clicks removed. +- Mute bug fixed. Wouldnt unmute unused channles. + +10/6/95 1.04 +------------- +- fixed another crash bug ++ Added cool new pan cycling effect! Hit 'c' to try it. + +7/6/95 1.03 +------------- +- Fixed interface bug (was printing ^g's in sample names) ++ Added effect 8xy (Panning) +- Fixed crash bug maybe.. I think I did, people complained of + the interface crashing.. I've never seen it crash but I found + I was mixing 'new' and 'malloc'.. fixed. ++ Added effect 7xy (Tremolo) - woopee ;) ++ Added mute channels ++ Added panning keys '(' and ')' to set default panning. + +30/5/95 1.02 +------------- +* major internal storage changes! ++ More memory in dos shell! around 30kb on average sized tunes. +* A lot faster. +- Pattern break fixed. Tested on backward.mod by FireLight +- Now mixes at 44.1khz like it should instead of 30khz..oops :} ++ Added effect EEx (Pattern Delay). ++ Added effect E6x (Pattern Loop). +- Retrig fixed now 100% protracker. + +5/4/95 1.01 +------------- +- fixed crash bug / increased speed by not calculating unused + channels. (I don't think i released this version though) + +6/3/95 1.00 +------------- +* FIRST PUBLIC RELEASE (In FireStorm 2 Music Disk) +- Vibrato bug fixed, now works I think :). +* Interface Completely changed looks much nicer now ++ speed of interface increased greatly + +============================================================================== + diff --git a/lib/libpng/include/libpng12/png.h b/lib/libpng/include/libpng12/png.h new file mode 100644 index 0000000..9fc8cef --- /dev/null +++ b/lib/libpng/include/libpng12/png.h @@ -0,0 +1,3687 @@ +/* png.h - header file for PNG reference library + * + * libpng version 1.2.37 - June 4, 2009 + * Copyright (c) 1998-2009 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Authors and maintainers: + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.2.37 - June 4, 2009: Glenn + * See also "Contributing Authors", below. + * + * Note about libpng version numbers: + * + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: + * + * source png.h png.h shared-lib + * version string int version + * ------- ------ ----- ---------- + * 0.89c "1.0 beta 3" 0.89 89 1.0.89 + * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] + * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] + * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] + * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] + * 0.97c 0.97 97 2.0.97 + * 0.98 0.98 98 2.0.98 + * 0.99 0.99 98 2.0.99 + * 0.99a-m 0.99 99 2.0.99 + * 1.00 1.00 100 2.1.0 [100 should be 10000] + * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] + * 1.0.1 png.h string is 10001 2.1.0 + * 1.0.1a-e identical to the 10002 from here on, the shared library + * 1.0.2 source version) 10002 is 2.V where V is the source code + * 1.0.2a-b 10003 version, except as noted. + * 1.0.3 10003 + * 1.0.3a-d 10004 + * 1.0.4 10004 + * 1.0.4a-f 10005 + * 1.0.5 (+ 2 patches) 10005 + * 1.0.5a-d 10006 + * 1.0.5e-r 10100 (not source compatible) + * 1.0.5s-v 10006 (not binary compatible) + * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) + * 1.0.6d-f 10007 (still binary incompatible) + * 1.0.6g 10007 + * 1.0.6h 10007 10.6h (testing xy.z so-numbering) + * 1.0.6i 10007 10.6i + * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) + * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) + * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) + * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) + * 1.0.7 1 10007 (still compatible) + * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 + * 1.0.8rc1 1 10008 2.1.0.8rc1 + * 1.0.8 1 10008 2.1.0.8 + * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 + * 1.0.9rc1 1 10009 2.1.0.9rc1 + * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 + * 1.0.9rc2 1 10009 2.1.0.9rc2 + * 1.0.9 1 10009 2.1.0.9 + * 1.0.10beta1 1 10010 2.1.0.10beta1 + * 1.0.10rc1 1 10010 2.1.0.10rc1 + * 1.0.10 1 10010 2.1.0.10 + * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 + * 1.0.11rc1 1 10011 2.1.0.11rc1 + * 1.0.11 1 10011 2.1.0.11 + * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 + * 1.0.12rc1 2 10012 2.1.0.12rc1 + * 1.0.12 2 10012 2.1.0.12 + * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) + * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 + * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 + * 1.2.0rc1 3 10200 3.1.2.0rc1 + * 1.2.0 3 10200 3.1.2.0 + * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 + * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 + * 1.2.1 3 10201 3.1.2.1 + * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 + * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 + * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 + * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 + * 1.0.13 10 10013 10.so.0.1.0.13 + * 1.2.2 12 10202 12.so.0.1.2.2 + * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 + * 1.2.3 12 10203 12.so.0.1.2.3 + * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 + * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 + * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 + * 1.0.14 10 10014 10.so.0.1.0.14 + * 1.2.4 13 10204 12.so.0.1.2.4 + * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 + * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 + * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 + * 1.0.15 10 10015 10.so.0.1.0.15 + * 1.2.5 13 10205 12.so.0.1.2.5 + * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 + * 1.0.16 10 10016 10.so.0.1.0.16 + * 1.2.6 13 10206 12.so.0.1.2.6 + * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 + * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 + * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 + * 1.0.17 10 10017 10.so.0.1.0.17 + * 1.2.7 13 10207 12.so.0.1.2.7 + * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 + * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 + * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 + * 1.0.18 10 10018 10.so.0.1.0.18 + * 1.2.8 13 10208 12.so.0.1.2.8 + * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 + * 1.2.9beta4-11 13 10209 12.so.0.9[.0] + * 1.2.9rc1 13 10209 12.so.0.9[.0] + * 1.2.9 13 10209 12.so.0.9[.0] + * 1.2.10beta1-8 13 10210 12.so.0.10[.0] + * 1.2.10rc1-3 13 10210 12.so.0.10[.0] + * 1.2.10 13 10210 12.so.0.10[.0] + * 1.2.11beta1-4 13 10211 12.so.0.11[.0] + * 1.0.19rc1-5 10 10019 10.so.0.19[.0] + * 1.2.11rc1-5 13 10211 12.so.0.11[.0] + * 1.0.19 10 10019 10.so.0.19[.0] + * 1.2.11 13 10211 12.so.0.11[.0] + * 1.0.20 10 10020 10.so.0.20[.0] + * 1.2.12 13 10212 12.so.0.12[.0] + * 1.2.13beta1 13 10213 12.so.0.13[.0] + * 1.0.21 10 10021 10.so.0.21[.0] + * 1.2.13 13 10213 12.so.0.13[.0] + * 1.2.14beta1-2 13 10214 12.so.0.14[.0] + * 1.0.22rc1 10 10022 10.so.0.22[.0] + * 1.2.14rc1 13 10214 12.so.0.14[.0] + * 1.0.22 10 10022 10.so.0.22[.0] + * 1.2.14 13 10214 12.so.0.14[.0] + * 1.2.15beta1-6 13 10215 12.so.0.15[.0] + * 1.0.23rc1-5 10 10023 10.so.0.23[.0] + * 1.2.15rc1-5 13 10215 12.so.0.15[.0] + * 1.0.23 10 10023 10.so.0.23[.0] + * 1.2.15 13 10215 12.so.0.15[.0] + * 1.2.16beta1-2 13 10216 12.so.0.16[.0] + * 1.2.16rc1 13 10216 12.so.0.16[.0] + * 1.0.24 10 10024 10.so.0.24[.0] + * 1.2.16 13 10216 12.so.0.16[.0] + * 1.2.17beta1-2 13 10217 12.so.0.17[.0] + * 1.0.25rc1 10 10025 10.so.0.25[.0] + * 1.2.17rc1-3 13 10217 12.so.0.17[.0] + * 1.0.25 10 10025 10.so.0.25[.0] + * 1.2.17 13 10217 12.so.0.17[.0] + * 1.0.26 10 10026 10.so.0.26[.0] + * 1.2.18 13 10218 12.so.0.18[.0] + * 1.2.19beta1-31 13 10219 12.so.0.19[.0] + * 1.0.27rc1-6 10 10027 10.so.0.27[.0] + * 1.2.19rc1-6 13 10219 12.so.0.19[.0] + * 1.0.27 10 10027 10.so.0.27[.0] + * 1.2.19 13 10219 12.so.0.19[.0] + * 1.2.20beta01-04 13 10220 12.so.0.20[.0] + * 1.0.28rc1-6 10 10028 10.so.0.28[.0] + * 1.2.20rc1-6 13 10220 12.so.0.20[.0] + * 1.0.28 10 10028 10.so.0.28[.0] + * 1.2.20 13 10220 12.so.0.20[.0] + * 1.2.21beta1-2 13 10221 12.so.0.21[.0] + * 1.2.21rc1-3 13 10221 12.so.0.21[.0] + * 1.0.29 10 10029 10.so.0.29[.0] + * 1.2.21 13 10221 12.so.0.21[.0] + * 1.2.22beta1-4 13 10222 12.so.0.22[.0] + * 1.0.30rc1 10 10030 10.so.0.30[.0] + * 1.2.22rc1 13 10222 12.so.0.22[.0] + * 1.0.30 10 10030 10.so.0.30[.0] + * 1.2.22 13 10222 12.so.0.22[.0] + * 1.2.23beta01-05 13 10223 12.so.0.23[.0] + * 1.2.23rc01 13 10223 12.so.0.23[.0] + * 1.2.23 13 10223 12.so.0.23[.0] + * 1.2.24beta01-02 13 10224 12.so.0.24[.0] + * 1.2.24rc01 13 10224 12.so.0.24[.0] + * 1.2.24 13 10224 12.so.0.24[.0] + * 1.2.25beta01-06 13 10225 12.so.0.25[.0] + * 1.2.25rc01-02 13 10225 12.so.0.25[.0] + * 1.0.31 10 10031 10.so.0.31[.0] + * 1.2.25 13 10225 12.so.0.25[.0] + * 1.2.26beta01-06 13 10226 12.so.0.26[.0] + * 1.2.26rc01 13 10226 12.so.0.26[.0] + * 1.2.26 13 10226 12.so.0.26[.0] + * 1.0.32 10 10032 10.so.0.32[.0] + * 1.2.27beta01-06 13 10227 12.so.0.27[.0] + * 1.2.27rc01 13 10227 12.so.0.27[.0] + * 1.0.33 10 10033 10.so.0.33[.0] + * 1.2.27 13 10227 12.so.0.27[.0] + * 1.0.34 10 10034 10.so.0.34[.0] + * 1.2.28 13 10228 12.so.0.28[.0] + * 1.2.29beta01-03 13 10229 12.so.0.29[.0] + * 1.2.29rc01 13 10229 12.so.0.29[.0] + * 1.0.35 10 10035 10.so.0.35[.0] + * 1.2.29 13 10229 12.so.0.29[.0] + * 1.0.37 10 10037 10.so.0.37[.0] + * 1.2.30beta01-04 13 10230 12.so.0.30[.0] + * 1.0.38rc01-08 10 10038 10.so.0.38[.0] + * 1.2.30rc01-08 13 10230 12.so.0.30[.0] + * 1.0.38 10 10038 10.so.0.38[.0] + * 1.2.30 13 10230 12.so.0.30[.0] + * 1.0.39rc01-03 10 10039 10.so.0.39[.0] + * 1.2.31rc01-03 13 10231 12.so.0.31[.0] + * 1.0.39 10 10039 10.so.0.39[.0] + * 1.2.31 13 10231 12.so.0.31[.0] + * 1.2.32beta01-02 13 10232 12.so.0.32[.0] + * 1.0.40rc01 10 10040 10.so.0.40[.0] + * 1.2.32rc01 13 10232 12.so.0.32[.0] + * 1.0.40 10 10040 10.so.0.40[.0] + * 1.2.32 13 10232 12.so.0.32[.0] + * 1.2.33beta01-02 13 10233 12.so.0.33[.0] + * 1.2.33rc01-02 13 10233 12.so.0.33[.0] + * 1.0.41rc01 10 10041 10.so.0.41[.0] + * 1.2.33 13 10233 12.so.0.33[.0] + * 1.0.41 10 10041 10.so.0.41[.0] + * 1.2.34beta01-07 13 10234 12.so.0.34[.0] + * 1.0.42rc01 10 10042 10.so.0.42[.0] + * 1.2.34rc01 13 10234 12.so.0.34[.0] + * 1.0.42 10 10042 10.so.0.42[.0] + * 1.2.34 13 10234 12.so.0.34[.0] + * 1.2.35beta01-03 13 10235 12.so.0.35[.0] + * 1.0.43rc01-02 10 10043 10.so.0.43[.0] + * 1.2.35rc01-02 13 10235 12.so.0.35[.0] + * 1.0.43 10 10043 10.so.0.43[.0] + * 1.2.35 13 10235 12.so.0.35[.0] + * 1.2.36beta01-05 13 10236 12.so.0.36[.0] + * 1.2.36rc01 13 10236 12.so.0.36[.0] + * 1.0.44 10 10044 10.so.0.44[.0] + * 1.2.36 13 10236 12.so.0.36[.0] + * 1.2.37beta01-03 13 10237 12.so.0.37[.0] + * 1.2.37rc01 13 10237 12.so.0.37[.0] + * 1.2.37 13 10237 12.so.0.37[.0] + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcNN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng.txt or libpng.3 for more information. The PNG specification + * is available as a W3C Recommendation and as an ISO Specification, + * defines should NOT be changed. + */ +#define PNG_INFO_gAMA 0x0001 +#define PNG_INFO_sBIT 0x0002 +#define PNG_INFO_cHRM 0x0004 +#define PNG_INFO_PLTE 0x0008 +#define PNG_INFO_tRNS 0x0010 +#define PNG_INFO_bKGD 0x0020 +#define PNG_INFO_hIST 0x0040 +#define PNG_INFO_pHYs 0x0080 +#define PNG_INFO_oFFs 0x0100 +#define PNG_INFO_tIME 0x0200 +#define PNG_INFO_pCAL 0x0400 +#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ + +/* This is used for the transformation routines, as some of them + * change these values for the row. It also should enable using + * the routines for other purposes. + */ +typedef struct png_row_info_struct +{ + png_uint_32 width; /* width of row */ + png_uint_32 rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_byte pixel_depth; /* bits per pixel (depth * channels) */ +} png_row_info; + +typedef png_row_info FAR * png_row_infop; +typedef png_row_info FAR * FAR * png_row_infopp; + +/* These are the function types for the I/O functions and for the functions + * that allow the user to override the default I/O functions with his or her + * own. The png_error_ptr type should match that of user-supplied warning + * and error functions, while the png_rw_ptr type should match that of the + * user read/write data functions. + */ +typedef struct png_struct_def png_struct; +typedef png_struct FAR * png_structp; + +typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); +typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); +typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); +typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, + int)); +typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, + int)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, + png_uint_32, int)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, + png_row_infop, png_bytep)); +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) +typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); +#endif +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); +#endif + +/* Transform masks for the high-level interface */ +#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ +#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ +#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ +#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ +#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ +#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ +#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ +#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ +#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ +#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ +#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ +#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only, deprecated */ +/* Added to libpng-1.2.34 */ +#define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800 /* WRITE only */ +#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* WRITE only */ + +/* Flags for MNG supported features */ +#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 +#define PNG_FLAG_MNG_FILTER_64 0x04 +#define PNG_ALL_MNG_FEATURES 0x05 + +typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); +typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); + +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application, except to store + * the jmp_buf. + */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmpbuf; /* used in png_error */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ + png_error_ptr warning_fn; /* function for printing warnings */ + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + z_stream zstream; /* pointer to decompression structure (below) */ + png_bytep zbuf; /* buffer for zlib */ + png_size_t zbuf_size; /* size of zbuf */ + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_uint_32 rowbytes; /* size of row in bytes */ + png_uint_32 irowbytes; /* size of current interlaced row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row */ + png_bytep row_buf; /* buffer to save current (unfiltered) row */ +#ifndef PNG_NO_WRITE_FILTER + png_bytep sub_row; /* buffer to save "sub" row when filtering */ + png_bytep up_row; /* buffer to save "up" row when filtering */ + png_bytep avg_row; /* buffer to save "avg" row when filtering */ + png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ +#endif + png_row_info row_info; /* used for transformation routines */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + png_uint_16 num_trans; /* number of transparency values */ + png_byte chunk_name[5]; /* null-terminated name of current chunk */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ + png_byte usr_channels; /* channels at start of write */ + png_byte sig_bytes; /* magic bytes read/written from start of file */ + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +#ifdef PNG_LEGACY_SUPPORTED + png_byte filler; /* filler byte for pixel expansion */ +#else + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif +#endif + +#if defined(PNG_bKGD_SUPPORTED) + png_byte background_gamma_type; +# ifdef PNG_FLOATING_POINT_SUPPORTED + float background_gamma; +# endif + png_color_16 background; /* background color in screen gamma space */ +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif +#endif /* PNG_bKGD_SUPPORTED */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_flush_ptr output_flush_fn;/* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float gamma; /* file gamma value */ + float screen_gamma; /* screen gamma value (display_exponent) */ +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans; /* transparency values for paletted files */ + png_color_16 trans_values; /* transparency values for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +# if defined(PNG_TEXT_SUPPORTED) + png_size_t current_text_size; /* current size of text input data */ + png_size_t current_text_left; /* how much text left to read in input */ + png_charp current_text; /* current text chunk buffer */ + png_charp current_text_ptr; /* current location in current_text */ +# endif /* PNG_TEXT_SUPPORTED */ +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* for the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + png_bytep palette_lookup; /* lookup table for dithering */ + png_bytep dither_index; /* index translation for palette files */ +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) + png_uint_16p hist; /* histogram */ +#endif + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_charp time_buffer; /* String to hold RFC 1123 time text */ +#endif + +/* New members added in libpng-1.0.6 */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) + png_voidp user_chunk_ptr; + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + int num_chunk_list; + png_bytep chunk_list; +#endif + +/* New members added in libpng-1.0.3 */ +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_byte rgb_to_gray_status; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ + defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* changed from png_byte to png_uint_32 at version 1.2.0 */ +#ifdef PNG_1_0_X + png_byte mng_features_permitted; +#else + png_uint_32 mng_features_permitted; +#endif /* PNG_1_0_X */ +#endif + +/* New member added in libpng-1.0.7 */ +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_fixed_point int_gamma; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_byte filter_type; +#endif + +#if defined(PNG_1_0_X) +/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ + png_uint_32 row_buf_size; +#endif + +/* New members added in libpng-1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +# if !defined(PNG_1_0_X) +# if defined(PNG_MMX_CODE_SUPPORTED) + png_byte mmx_bitdepth_threshold; + png_uint_32 mmx_rowbytes_threshold; +# endif + png_uint_32 asm_flags; +# endif +#endif + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +/* New member added in libpng-1.0.13 and 1.2.0 */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* The following three members were added at version 1.0.14 and 1.2.4 */ + png_bytep dither_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is */ + /* in the palette */ + png_bytep palette_to_index; /* which original index points to this */ + /* palette color */ +#endif + +/* New members added in libpng-1.0.16 and 1.2.6 */ + png_byte compression_type; + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_uint_32 user_width_max; + png_uint_32 user_height_max; +#endif + +/* New member added in libpng-1.0.25 and 1.2.17 */ +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + /* storage for unknown chunk that the library doesn't recognize. */ + png_unknown_chunk unknown_chunk; +#endif + +/* New members added in libpng-1.2.26 */ + png_uint_32 old_big_row_buf_size, old_prev_row_size; + +/* New member added in libpng-1.2.30 */ + png_charp chunkdata; /* buffer for reading chunk data */ + +}; + + +/* This triggers a compiler error in png.c, if png.c and png.h + * do not agree upon the version number. + */ +typedef png_structp version_1_2_37; + +typedef png_struct FAR * FAR * png_structpp; + +/* Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng.txt for the + * full explanation, see example.c for the summary. This just provides + * a simple one line description of the use of each function. + */ + +/* Returns the version number of the library */ +extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); + +/* Tell lib we have already handled the first magic bytes. + * Handling more than 8 bytes from the beginning of the file is an error. + */ +extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, + int num_bytes)); + +/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a + * PNG file. Returns zero if the supplied bytes match the 8-byte PNG + * signature, and non-zero otherwise. Having num_to_check == 0 or + * start > 7 will always fail (ie return non-zero). + */ +extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, + png_size_t num_to_check)); + +/* Simple signature checking function. This is the same as calling + * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). + */ +extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); + +/* Allocate and initialize png_ptr struct for reading, and any other memory. */ +extern PNG_EXPORT(png_structp,png_create_read_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +/* Allocate and initialize png_ptr struct for writing, and any other memory */ +extern PNG_EXPORT(png_structp,png_create_write_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +#ifdef PNG_WRITE_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_WRITE_SUPPORTED +extern PNG_EXPORT(void,png_set_compression_buffer_size) + PNGARG((png_structp png_ptr, png_uint_32 size)); +#endif + +/* Reset the compression stream */ +extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); + +/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_structp,png_create_read_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +extern PNG_EXPORT(png_structp,png_create_write_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +#endif + +/* Write a PNG chunk - size, type, (optional) data, CRC. */ +extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_bytep data, png_size_t length)); + +/* Write the start of a PNG chunk - length and chunk name. */ +extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_uint_32 length)); + +/* Write the data of a PNG chunk started with png_write_chunk_start(). */ +extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ +extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); + +/* Allocate and initialize the info structure */ +extern PNG_EXPORT(png_infop,png_create_info_struct) + PNGARG((png_structp png_ptr)); + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize the info structure (old interface - DEPRECATED) */ +extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); +#undef png_info_init +#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ + png_sizeof(png_info)); +#endif + +extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, + png_size_t png_info_struct_size)); + +/* Writes all the PNG information before the image. */ +extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the information before the actual image data. */ +extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) + PNGARG((png_structp png_ptr, png_timep ptime)); +#endif + +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ +#if defined(PNG_WRITE_tIME_SUPPORTED) +/* convert from a struct tm to png_time */ +extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, + struct tm FAR * ttime)); + +/* convert from time_t to png_time. Uses gmtime() */ +extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, + time_t ttime)); +#endif /* PNG_WRITE_tIME_SUPPORTED */ +#endif /* _WIN32_WCE */ + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ +extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); +#if !defined(PNG_1_0_X) +extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp + png_ptr)); +#endif +extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated */ +extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); +#endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Use blue, green, red order for pixels. */ +extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* Expand the grayscale to 24-bit RGB if necessary. */ +extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* Reduce RGB to grayscale. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, + int error_action, double red, double green )); +#endif +extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green )); +extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp + png_ptr)); +#endif + +extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, + png_colorp palette)); + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ +extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +/* The values of the PNG_FILLER_ defines should NOT be changed */ +#define PNG_FILLER_BEFORE 0 +#define PNG_FILLER_AFTER 1 +/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ +#if !defined(PNG_1_0_X) +extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +#endif +#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swap bytes in 16-bit depth files. */ +extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ +extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Swap packing order of pixels in bytes. */ +extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Converts files to legal bit depths. */ +extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, + png_color_8p true_bits)); +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Have the code handle the interlacing. Returns the number of passes. */ +extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +/* Invert monochrome files */ +extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Handle alpha and tRNS by replacing with a background color. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)); +#endif +#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +#define PNG_BACKGROUND_GAMMA_SCREEN 1 +#define PNG_BACKGROUND_GAMMA_FILE 2 +#define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip the second byte of information from a 16-bit depth file. */ +extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Turn on dithering, and reduce the palette to the number of colors available. */ +extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_uint_16p histogram, int full_dither)); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Handle gamma correction. Screen_gamma=(display_exponent) */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, + double screen_gamma, double default_file_gamma)); +#endif +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ +/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ +extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, + int empty_plte_permitted)); +#endif +#endif + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +/* Set how many lines between output flushes - 0 for no flushing */ +extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); +/* Flush the current PNG output buffer */ +extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); +#endif + +/* optional update palette with requested transformations */ +extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); + +/* optional call to update the users info structure */ +extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read one or more rows of image data. */ +extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); +#endif + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read a row of data. */ +extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, + png_bytep row, + png_bytep display_row)); +#endif + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the whole image into memory at once. */ +extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, + png_bytepp image)); +#endif + +/* write a row of image data */ +extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, + png_bytep row)); + +/* write a few rows of image data */ +extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_uint_32 num_rows)); + +/* write the image data */ +extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* writes the end of the PNG file. */ +extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the end of the PNG file. */ +extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +/* free any memory associated with the png_info_struct */ +extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, + png_infopp info_ptr_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp + png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); + +/* free all memory used by the read (old method - NOT DLL EXPORTED) */ +/* Debian note: exporting as it is required by legacy applications */ +extern PNG_EXPORT(void,png_read_destroy) PNGARG((png_structp png_ptr, png_infop info_ptr, + png_infop end_info_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_write_struct) + PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); + +/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ +/* Debian note: exporting as it is required by legacy applications */ +extern PNG_EXPORT(void,png_write_destroy) PNGARG((png_structp png_ptr)); + +/* set the libpng method of handling chunk CRC errors */ +extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, + int crit_action, int ancil_action)); + +/* Values for png_set_crc_action() to say how to handle CRC errors in + * ancillary and critical chunks, and whether to use the data contained + * therein. Note that it is impossible to "discard" data in a critical + * chunk. For versions prior to 0.90, the action was always error/quit, + * whereas in version 0.90 and later, the action for CRC errors in ancillary + * chunks is warn/discard. These values should NOT be changed. + * + * value action:critical action:ancillary + */ +#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ +#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ +#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ +#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ +#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ +#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ + +/* These functions give the user control over the scan-line filtering in + * libpng and the compression methods used by zlib. These functions are + * mainly useful for testing, as the defaults should work with most users. + * Those users who are tight on memory or want faster performance at the + * expense of compression can modify them. See the compression library + * header file (zlib.h) for an explination of the compression functions. + */ + +/* set the filtering method(s) used by libpng. Currently, the only valid + * value for "method" is 0. + */ +extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, + int filters)); + +/* Flags for png_set_filter() to say which filters to use. The flags + * are chosen so that they don't conflict with real filter types + * below, in case they are supplied instead of the #defined constants. + * These values should NOT be changed. + */ +#define PNG_NO_FILTERS 0x00 +#define PNG_FILTER_NONE 0x08 +#define PNG_FILTER_SUB 0x10 +#define PNG_FILTER_UP 0x20 +#define PNG_FILTER_AVG 0x40 +#define PNG_FILTER_PAETH 0x80 +#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ + PNG_FILTER_AVG | PNG_FILTER_PAETH) + +/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. + * These defines should NOT be changed. + */ +#define PNG_FILTER_VALUE_NONE 0 +#define PNG_FILTER_VALUE_SUB 1 +#define PNG_FILTER_VALUE_UP 2 +#define PNG_FILTER_VALUE_AVG 3 +#define PNG_FILTER_VALUE_PAETH 4 +#define PNG_FILTER_VALUE_LAST 5 + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ +/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ + * defines, either the default (minimum-sum-of-absolute-differences), or + * the experimental method (weighted-minimum-sum-of-absolute-differences). + * + * Weights are factors >= 1.0, indicating how important it is to keep the + * filter type consistent between rows. Larger numbers mean the current + * filter is that many times as likely to be the same as the "num_weights" + * previous filters. This is cumulative for each previous row with a weight. + * There needs to be "num_weights" values in "filter_weights", or it can be + * NULL if the weights aren't being specified. Weights have no influence on + * the selection of the first row filter. Well chosen weights can (in theory) + * improve the compression for a given image. + * + * Costs are factors >= 1.0 indicating the relative decoding costs of a + * filter type. Higher costs indicate more decoding expense, and are + * therefore less likely to be selected over a filter with lower computational + * costs. There needs to be a value in "filter_costs" for each valid filter + * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't + * setting the costs. Costs try to improve the speed of decompression without + * unduly increasing the compressed image size. + * + * A negative weight or cost indicates the default value is to be used, and + * values in the range [0.0, 1.0) indicate the value is to remain unchanged. + * The default values for both weights and costs are currently 1.0, but may + * change if good general weighting/cost heuristics can be found. If both + * the weights and costs are set to 1.0, this degenerates the WEIGHTED method + * to the UNWEIGHTED method, but with added encoding time/computation. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, + int heuristic_method, int num_weights, png_doublep filter_weights, + png_doublep filter_costs)); +#endif +#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ + +/* Heuristic used for row filter selection. These defines should NOT be + * changed. + */ +#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ +#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ +#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ +#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ + +/* Set the library compression level. Currently, valid values range from + * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 + * (0 - no compression, 9 - "maximal" compression). Note that tests have + * shown that zlib compression levels 3-6 usually perform as well as level 9 + * for PNG images, and do considerably fewer caclulations. In the future, + * these values may not correspond directly to the zlib compression levels. + */ +extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, + int level)); + +extern PNG_EXPORT(void,png_set_compression_mem_level) + PNGARG((png_structp png_ptr, int mem_level)); + +extern PNG_EXPORT(void,png_set_compression_strategy) + PNGARG((png_structp png_ptr, int strategy)); + +extern PNG_EXPORT(void,png_set_compression_window_bits) + PNGARG((png_structp png_ptr, int window_bits)); + +extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, + int method)); + +/* These next functions are called for input/output, memory, and error + * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, + * and call standard C I/O routines such as fread(), fwrite(), and + * fprintf(). These functions can be made to use other I/O routines + * at run time for those applications that need to handle I/O in a + * different manner by calling png_set_???_fn(). See libpng.txt for + * more information. + */ + +#if !defined(PNG_NO_STDIO) +/* Initialize the input/output for the PNG file to the default functions. */ +extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); +#endif + +/* Replace the (error and abort), and warning functions with user + * supplied functions. If no messages are to be printed you must still + * write and use replacement functions. The replacement error_fn should + * still do a longjmp to the last setjmp location if you are using this + * method of error handling. If error_fn or warning_fn is NULL, the + * default function will be used. + */ + +extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); + +/* Return the user pointer associated with the error functions */ +extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); + +/* Replace the default data output functions with a user supplied one(s). + * If buffered output is not used, then output_flush_fn can be set to NULL. + * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time + * output_flush_fn will be ignored (and thus can be NULL). + * It is probably a mistake to use NULL for output_flush_fn if + * write_data_fn is not also NULL unless you have built libpng with + * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's + * default flush function, which uses the standard *FILE structure, will + * be used. + */ +extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); + +/* Replace the default data input function with a user supplied one. */ +extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr read_data_fn)); + +/* Return the user pointer associated with the I/O functions */ +extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, + png_read_status_ptr read_row_fn)); + +extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_USER_MEM_SUPPORTED +/* Replace the default memory allocation functions with user supplied one(s). */ +extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +/* Return the user pointer associated with the memory functions */ +extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr read_user_transform_fn)); +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr write_user_transform_fn)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp + png_ptr, png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); +/* Return the user pointer associated with the user transform functions */ +extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp + png_ptr)); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +/* Sets the function callbacks for the push reader, and a pointer to a + * user-defined structure available to the callback functions. + */ +extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, + png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn)); + +/* returns the user pointer associated with the push read functions */ +extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) + PNGARG((png_structp png_ptr)); + +/* function to be called when data becomes available */ +extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); + +/* function that combines rows. Not very much different than the + * png_combine_row() call. Is this even used????? + */ +extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, + png_bytep old_row, png_bytep new_row)); +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, + png_uint_32 size)); + +#if defined(PNG_1_0_X) +# define png_malloc_warn png_malloc +#else +/* Added at libpng version 1.2.4 */ +extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, + png_uint_32 size)); +#endif + +/* frees a pointer allocated by png_malloc() */ +extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); + +#if defined(PNG_1_0_X) +/* Function to allocate memory for zlib. */ +extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, + uInt size)); + +/* Function to free memory for zlib */ +extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); +#endif + +/* Free data that was allocated internally */ +extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 free_me, int num)); +#ifdef PNG_FREE_ME_SUPPORTED +/* Reassign responsibility for freeing existing data, whether allocated + * by libpng or by the application */ +extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, + png_infop info_ptr, int freer, png_uint_32 mask)); +#endif +/* assignments for png_data_freer */ +#define PNG_DESTROY_WILL_FREE_DATA 1 +#define PNG_SET_WILL_FREE_DATA 1 +#define PNG_USER_WILL_FREE_DATA 2 +/* Flags for png_ptr->free_me and info_ptr->free_me */ +#define PNG_FREE_HIST 0x0008 +#define PNG_FREE_ICCP 0x0010 +#define PNG_FREE_SPLT 0x0020 +#define PNG_FREE_ROWS 0x0040 +#define PNG_FREE_PCAL 0x0080 +#define PNG_FREE_SCAL 0x0100 +#define PNG_FREE_UNKN 0x0200 +#define PNG_FREE_LIST 0x0400 +#define PNG_FREE_PLTE 0x1000 +#define PNG_FREE_TRNS 0x2000 +#define PNG_FREE_TEXT 0x4000 +#define PNG_FREE_ALL 0x7fff +#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ + +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, + png_uint_32 size)); +extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, + png_voidp ptr)); +#endif + +extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, + png_voidp s1, png_voidp s2, png_uint_32 size)); + +extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, + png_voidp s1, int value, png_uint_32 size)); + +#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ +extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, + int check)); +#endif /* USE_FAR_KEYWORD */ + +#ifndef PNG_NO_ERROR_TEXT +/* Fatal error in PNG image of libpng - can't continue */ +extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); + +/* The same, but the chunk name is prepended to the error string. */ +extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); +#else +/* Fatal error in PNG image of libpng - can't continue */ +extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)); +#endif + +#ifndef PNG_NO_WARNINGS +/* Non-fatal error in libpng. Can continue, but may have a problem. */ +extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +#ifdef PNG_READ_SUPPORTED +/* Non-fatal error in libpng, chunk name is prepended to message. */ +extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); +#endif /* PNG_READ_SUPPORTED */ +#endif /* PNG_NO_WARNINGS */ + +/* The png_set_ functions are for storing values in the png_info_struct. + * Similarly, the png_get_ calls are used to read values from the + * png_info_struct, either storing the parameters in the passed variables, or + * setting pointers into the png_info_struct where the data is stored. The + * png_get_ functions return a non-zero value if the data was available + * in info_ptr, or return zero and do not change any of the parameters if the + * data was not available. + * + * These functions should be used instead of directly accessing png_info + * to avoid problems with future changes in the size and internal layout of + * png_info_struct. + */ +/* Returns "flag" if chunk data is valid in info_ptr. */ +extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 flag)); + +/* Returns number of bytes needed to hold a transformed row. */ +extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* Returns row_pointers, which is an array of pointers to scanlines that was +returned from png_read_png(). */ +extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, +png_infop info_ptr)); +/* Set row_pointers, which is an array of pointers to scanlines for use +by png_write_png(). */ +extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers)); +#endif + +/* Returns number of color channels in image. */ +extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Returns image width in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image height in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image bit_depth. */ +extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image color_type. */ +extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image filter_type. */ +extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image interlace_type. */ +extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image compression_type. */ +extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image resolution in pixels per meter, from pHYs chunk data. */ +extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns pixel aspect ratio, computed from pHYs chunk data. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +#endif + +/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ +extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +/* Returns pointer to signature string read from PNG header */ +extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p *background)); +#endif + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p background)); +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point + *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point + *int_blue_x, png_fixed_point *int_blue_y)); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double white_x, double white_y, double red_x, + double red_y, double green_x, double green_y, double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *file_gamma)); +#endif +extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_file_gamma)); +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double file_gamma)); +#endif +extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p *hist)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p hist)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); + +extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, + int *unit_type)); +#endif + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, + int *type, int *nparams, png_charp *units, png_charpp *params)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_charp units, png_charpp params)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp *palette, int *num_palette)); + +extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp palette, int num_palette)); + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p *sig_bit)); +#endif + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p sig_bit)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *intent)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen)); + /* Note to maintainer: profile should be png_bytepp */ +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tpp entries)); +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) +/* png_get_text also returns the number of text chunks in *num_text */ +extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp *text_ptr, int *num_text)); +#endif + +/* + * Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + +#if defined(PNG_TEXT_SUPPORTED) +extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep *mod_time)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep mod_time)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep *trans, int *num_trans, + png_color_16p *trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep trans, int num_trans, + png_color_16p trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +#endif + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, double *width, double *height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED */ + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* provide a list of chunks and how they are to be handled, if the built-in + handling or default unknown chunk handling is not desired. Any chunks not + listed will be handled in the default manner. The IHDR and IEND chunks + must not be listed. + keep = 0: follow default behaviour + = 1: do not keep + = 2: keep only if safe-to-copy + = 3: keep even if unsafe-to-copy +*/ +extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp + png_ptr, int keep, png_bytep chunk_list, int num_chunks)); +extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); +extern PNG_EXPORT(void, png_set_unknown_chunk_location) + PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); +extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp + png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); +#endif +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep + chunk_name)); +#endif + +/* Png_free_data() will turn off the "valid" flag for anything it frees. + If you need to turn it off for a chunk that your application has freed, + you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ +extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, + png_infop info_ptr, int mask)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* The "params" pointer is currently not used and is for future expansion. */ +extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +#endif + +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + */ +#ifdef PNG_DEBUG +#if (PNG_DEBUG > 0) +#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +#include +#if (PNG_DEBUG > 1) +#ifndef _DEBUG +# define _DEBUG +#endif +#ifndef png_debug +#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) +#endif +#ifndef png_debug1 +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) +#endif +#ifndef png_debug2 +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) +#endif +#endif +#else /* PNG_DEBUG_FILE || !_MSC_VER */ +#ifndef PNG_DEBUG_FILE +#define PNG_DEBUG_FILE stderr +#endif /* PNG_DEBUG_FILE */ + +#if (PNG_DEBUG > 1) +/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on + * non-ISO compilers */ +# ifdef __STDC__ +# ifndef png_debug +# define png_debug(l,m) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ + } +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ + } +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ + } +# endif +# else /* __STDC __ */ +# ifndef png_debug +# define png_debug(l,m) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format); \ + } +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1); \ + } +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1,p2); \ + } +# endif +# endif /* __STDC __ */ +#endif /* (PNG_DEBUG > 1) */ + +#endif /* _MSC_VER */ +#endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +#define png_debug(l, m) +#endif +#ifndef png_debug1 +#define png_debug1(l, m, p1) +#endif +#ifndef png_debug2 +#define png_debug2(l, m, p1, p2) +#endif + +extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); + +#ifdef PNG_MNG_FEATURES_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp + png_ptr, png_uint_32 mng_features_permitted)); +#endif + +/* For use in png_set_keep_unknown, added to version 1.2.6 */ +#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 +#define PNG_HANDLE_CHUNK_NEVER 1 +#define PNG_HANDLE_CHUNK_IF_SAFE 2 +#define PNG_HANDLE_CHUNK_ALWAYS 3 + +/* Added to version 1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if defined(PNG_MMX_CODE_SUPPORTED) +#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 +#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 +#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 +#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 +#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 +#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 +#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ + +#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) +#define PNG_MMX_WRITE_FLAGS ( 0 ) + +#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ + | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ + | PNG_MMX_READ_FLAGS \ + | PNG_MMX_WRITE_FLAGS ) + +#define PNG_SELECT_READ 1 +#define PNG_SELECT_WRITE 2 +#endif /* PNG_MMX_CODE_SUPPORTED */ + +#if !defined(PNG_1_0_X) +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) + PNGARG((int flag_select, int *compilerID)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) + PNGARG((int flag_select)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flags) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) + PNGARG((png_structp png_ptr)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_asm_flags) + PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_mmx_thresholds) + PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold)); + +#endif /* PNG_1_0_X */ + +#if !defined(PNG_1_0_X) +/* png.c, pnggccrd.c, or pngvcrd.c */ +extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); +#endif /* PNG_1_0_X */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + +/* Strip the prepended error numbers ("#nnn ") from error and warning + * messages before passing them to the error or warning handler. */ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp + png_ptr, png_uint_32 strip_mode)); +#endif + +/* Added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp + png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); +extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp + png_ptr)); +extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp + png_ptr)); +#endif + + +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ + +#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +/* With these routines we avoid an integer divide, which will be slower on + * most machines. However, it does take more operations than the corresponding + * divide method, so it may be slower on a few RISC systems. There are two + * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. + * + * Note that the rounding factors are NOT supposed to be the same! 128 and + * 32768 are correct for the NODIV code; 127 and 32767 are correct for the + * standard method. + * + * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] + */ + + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 - \ + (png_uint_16)(alpha)) + (png_uint_16)128); \ + (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } + +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(png_uint_32)(65535L - \ + (png_uint_32)(alpha)) + (png_uint_32)32768L); \ + (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } + +#else /* standard method using integer division */ + +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + (png_uint_16)127) / 255) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ + (png_uint_32)32767) / (png_uint_32)65535L) + +#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ + +/* Inline macros to do direct reads of bytes from the input buffer. These + * require that you are using an architecture that uses PNG byte ordering + * (MSB first) and supports unaligned data storage. I think that PowerPC + * in big-endian mode and 680x0 are the only ones that will support this. + * The x86 line of processors definitely do not. The png_get_int_32() + * routine also assumes we are using two's complement format for negative + * values, which is almost certainly true. + */ +#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) +# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) +# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) +# define png_get_int_32(buf) ( *((png_int_32p) (buf))) +#else +extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); +extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); +extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); +#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ +extern PNG_EXPORT(png_uint_32,png_get_uint_31) + PNGARG((png_structp png_ptr, png_bytep buf)); +/* No png_get_int_16 -- may be added if there's a real need for it. */ + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). + */ +extern PNG_EXPORT(void,png_save_uint_32) + PNGARG((png_bytep buf, png_uint_32 i)); +extern PNG_EXPORT(void,png_save_int_32) + PNGARG((png_bytep buf, png_int_32 i)); + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +extern PNG_EXPORT(void,png_save_uint_16) + PNGARG((png_bytep buf, unsigned int i)); +/* No png_save_int_16 -- may be added if there's a real need for it. */ + +/* ************************************************************************* */ + +/* These next functions are used internally in the code. They generally + * shouldn't be used unless you are writing code to add or replace some + * functionality in libpng. More information about most functions can + * be found in the files where the functions are located. + */ + + +/* Various modes of operation, that are visible to applications because + * they are used for unknown chunk location. + */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_HAVE_IDAT 0x04 +#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ +#define PNG_HAVE_IEND 0x10 + +#if defined(PNG_INTERNAL) + +/* More modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. + */ +#define PNG_HAVE_gAMA 0x20 +#define PNG_HAVE_cHRM 0x40 +#define PNG_HAVE_sRGB 0x80 +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ + +/* flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_DITHER 0x0040 +#define PNG_BACKGROUND 0x0080 +#define PNG_BACKGROUND_EXPAND 0x0100 + /* 0x0200 unused */ +#define PNG_16_TO_8 0x0400 +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000L +#define PNG_PACKSWAP 0x10000L +#define PNG_SWAP_ALPHA 0x20000L +#define PNG_STRIP_ALPHA 0x40000L +#define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L +#define PNG_RGB_TO_GRAY_ERR 0x200000L +#define PNG_RGB_TO_GRAY_WARN 0x400000L +#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ + /* 0x800000L Unused */ +#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ +#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ + /* 0x4000000L unused */ + /* 0x8000000L unused */ + /* 0x10000000L unused */ + /* 0x20000000L unused */ + /* 0x40000000L unused */ + +/* flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_SHIFT 8 +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_SHIFT 3 +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 +#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 +#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 +#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 +#define PNG_FLAG_ZLIB_FINISHED 0x0020 +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_FREE_PLTE 0x1000 +#define PNG_FLAG_FREE_TRNS 0x2000 +#define PNG_FLAG_FREE_HIST 0x4000 +#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L +#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L +#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L +#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ +#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ + /* 0x800000L unused */ + /* 0x1000000L unused */ + /* 0x2000000L unused */ + /* 0x4000000L unused */ + /* 0x8000000L unused */ + /* 0x10000000L unused */ + /* 0x20000000L unused */ + /* 0x40000000L unused */ + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* save typing and make code easier to understand */ + +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* Added to libpng-1.2.6 JB */ +#define PNG_ROWBYTES(pixel_bits, width) \ + ((pixel_bits) >= 8 ? \ + ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ + (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) + +/* PNG_OUT_OF_RANGE returns true if value is outside the range + ideal-delta..ideal+delta. Each argument is evaluated twice. + "ideal" and "delta" should be constants, normally simple + integers, "value" a variable. Added to libpng-1.2.6 JB */ +#define PNG_OUT_OF_RANGE(value, ideal, delta) \ + ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* place to hold the signature string for a PNG file. */ +#ifdef PNG_USE_GLOBAL_ARRAYS + PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8]; +#else +#endif +#endif /* PNG_NO_EXTERN */ + +/* Constant strings for known chunk types. If you need to add a chunk, + * define the name here, and add an invocation of the macro in png.c and + * wherever it's needed. + */ +#define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} +#define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} +#define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} +#define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} +#define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} +#define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} +#define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} +#define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} +#define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} +#define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} +#define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} +#define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} +#define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} +#define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} +#define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} +#define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} +#define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} +#define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} +#define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} +#define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} + +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5]; +#endif /* PNG_USE_GLOBAL_ARRAYS */ + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize png_ptr struct for reading, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_read_struct instead). + */ +extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); +#undef png_read_init +#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); +#endif + +extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize png_ptr struct for writing, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_write_struct instead). + */ +extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); +#undef png_write_init +#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); +#endif + +extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Allocate memory for an internal libpng struct */ +PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); + +/* Free memory from internal libpng struct */ +PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); + +PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr + malloc_fn, png_voidp mem_ptr)); +PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, + png_free_ptr free_fn, png_voidp mem_ptr)); + +/* Free any memory that info_ptr points to and reset struct. */ +PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_1_0_X +/* Function to allocate memory for zlib. */ +PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); + +/* Function to free memory for zlib */ +PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); + +#ifdef PNG_SIZE_T +/* Function to convert a sizeof an item to png_sizeof item */ + PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); +#endif + +/* Next four functions are used internally as callbacks. PNGAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ + +PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif + +PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if !defined(PNG_NO_STDIO) +PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); +#endif +#endif +#else /* PNG_1_0_X */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif +#endif /* PNG_1_0_X */ + +/* Reset the CRC variable */ +PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); + +/* Write the "data" buffer to whatever output you are using. */ +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, + png_size_t length)); + +/* Decompress data in a chunk that uses compression */ +#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_size_t chunklength, + png_size_t prefix_length, png_size_t *data_length)); +#endif + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, + png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +#endif + +/* simple function to write the signature */ +PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); + +/* write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, + png_uint_32 height, + int bit_depth, int color_type, int compression_method, int filter_method, + int interlace_method)); + +PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, + png_uint_32 num_pal)); + +PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point + file_gamma)); +#endif +#endif + +#if defined(PNG_WRITE_sBIT_SUPPORTED) +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, + int color_type)); +#endif + +#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, + double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_WRITE_sRGB_SUPPORTED) +PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, + int intent)); +#endif + +#if defined(PNG_WRITE_iCCP_SUPPORTED) +PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, + png_charp name, int compression_type, + png_charp profile, int proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, + png_sPLT_tp palette)); +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, + png_color_16p values, int number, int color_type)); +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, + png_color_16p values, int color_type)); +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, + int num_hist)); +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, + png_charp key, png_charpp new_key)); +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len)); +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len, int compression)); +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, + int compression, png_charp key, png_charp lang, png_charp lang_key, + png_charp text)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ +PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type)); +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, + png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params)); +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type)); +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, + png_timep mod_time)); +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, + int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, + int unit, png_charp width, png_charp height)); +#endif +#endif +#endif + +/* Called when finished processing a row of data */ +PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); + +/* Internal use only. Called before first row of data */ +PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#endif + +/* combine a row of data, dealing with alpha, etc. if requested */ +PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, + int mask)); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +/* expand an interlaced row */ +/* OLD pre-1.0.9 interface: +PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations)); + */ +PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* grab pixels out of a row for an interlaced pass */ +PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass)); +#endif + +/* unfilter a row */ +PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); + +/* Choose the best filter to use and filter the row data */ +PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, + png_row_infop row_info)); + +/* Write out the filtered row. */ +PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, + png_bytep filtered_row)); +/* finish a row while reading, dealing with interlacing passes, etc. */ +PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); + +/* initialize the row buffers, etc. */ +PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); +/* optional call to update the users info structure */ +PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* these are the functions that do the transformations */ +#if defined(PNG_READ_FILLER_SUPPORTED) +PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop + row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p sig_bits)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, + png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); + +# if defined(PNG_CORRECT_PALETTE_SUPPORTED) +PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette)); +# endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) +PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth)); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p bit_depth)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background, + png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift)); +#else +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background)); +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift)); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, + png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); +PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, + png_bytep row, png_color_16p trans_value)); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* decode the IHDR chunk */ +PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); + +#if defined(PNG_READ_bKGD_SUPPORTED) +PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_gAMA_SUPPORTED) +PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_iCCP_SUPPORTED) +extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sPLT_SUPPORTED) +extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_sRGB_SUPPORTED) +PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tRNS_SUPPORTED) +PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); + +PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, + png_bytep chunk_name)); + +/* handle the transformations for reading and writing */ +PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); + +PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, + png_uint_32 length)); +PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); +PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if defined(PNG_MMX_CODE_SUPPORTED) +/* png.c */ /* PRIVATE */ +PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); +#endif +#endif + +#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_pHYs_SUPPORTED) +PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ + +/* Read the chunk header (length + type name) */ +PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); + +/* Added at libpng version 1.2.34 */ +#if defined(PNG_cHRM_SUPPORTED) +PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif + +/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#endif /* PNG_INTERNAL */ + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +/* do not put anything past this line */ +#endif /* PNG_H */ diff --git a/lib/libpng/include/libpng12/pngconf.h b/lib/libpng/include/libpng12/pngconf.h new file mode 100644 index 0000000..025368d --- /dev/null +++ b/lib/libpng/include/libpng12/pngconf.h @@ -0,0 +1,1496 @@ + +/* pngconf.h - machine configurable file for libpng + * + * libpng version 1.2.37 - June 4, 2009 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2009 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* Any machine specific code is near the front of this file, so if you + * are configuring libpng for a machine, you may want to read the section + * starting here down to where it starts to typedef png_color, png_text, + * and png_info. + */ + +#ifndef PNGCONF_H +#define PNGCONF_H + +#define PNG_1_2_X + +/* + * PNG_USER_CONFIG has to be defined on the compiler command line. This + * includes the resource compiler for Windows DLL configurations. + */ +#ifdef PNG_USER_CONFIG +# ifndef PNG_USER_PRIVATEBUILD +# define PNG_USER_PRIVATEBUILD +# endif +#include "pngusr.h" +#endif + +/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ +#ifdef PNG_CONFIGURE_LIBPNG +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#endif + +/* + * Added at libpng-1.2.8 + * + * If you create a private DLL you need to define in "pngusr.h" the followings: + * #define PNG_USER_PRIVATEBUILD + * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." + * #define PNG_USER_DLLFNAME_POSTFIX + * e.g. // private DLL "libpng13gx.dll" + * #define PNG_USER_DLLFNAME_POSTFIX "gx" + * + * The following macros are also at your disposal if you want to complete the + * DLL VERSIONINFO structure. + * - PNG_USER_VERSIONINFO_COMMENTS + * - PNG_USER_VERSIONINFO_COMPANYNAME + * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS + */ + +#ifdef __STDC__ +#ifdef SPECIALBUILD +# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ + are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") +#endif + +#ifdef PRIVATEBUILD +# pragma message("PRIVATEBUILD is deprecated.\ + Use PNG_USER_PRIVATEBUILD instead.") +# define PNG_USER_PRIVATEBUILD PRIVATEBUILD +#endif +#endif /* __STDC__ */ + +#ifndef PNG_VERSION_INFO_ONLY + +/* End of material added to libpng-1.2.8 */ + +/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble + Restored at libpng-1.2.21 */ +#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \ + !defined(PNG_WARN_UNINITIALIZED_ROW) +# define PNG_WARN_UNINITIALIZED_ROW 1 +#endif +/* End of material added at libpng-1.2.19/1.2.21 */ + +/* This is the size of the compression buffer, and thus the size of + * an IDAT chunk. Make this whatever size you feel is best for your + * machine. One of these will be allocated per png_struct. When this + * is full, it writes the data to the disk, and does some other + * calculations. Making this an extremely small size will slow + * the library down, but you may want to experiment to determine + * where it becomes significant, if you are concerned with memory + * usage. Note that zlib allocates at least 32Kb also. For readers, + * this describes the size of the buffer available to read the data in. + * Unless this gets smaller than the size of a row (compressed), + * it should not make much difference how big this is. + */ + +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif + +/* Enable if you want a write-only libpng */ + +#ifndef PNG_NO_READ_SUPPORTED +# define PNG_READ_SUPPORTED +#endif + +/* Enable if you want a read-only libpng */ + +#ifndef PNG_NO_WRITE_SUPPORTED +# define PNG_WRITE_SUPPORTED +#endif + +/* Enabled by default in 1.2.0. You can disable this if you don't need to + support PNGs that are embedded in MNG datastreams */ +#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) +# ifndef PNG_MNG_FEATURES_SUPPORTED +# define PNG_MNG_FEATURES_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_FLOATING_POINT_SUPPORTED +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FLOATING_POINT_SUPPORTED +# endif +#endif + +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. +#define PNG_MAX_MALLOC_64K + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +/* Special munging to support doing things the 'cygwin' way: + * 'Normal' png-on-win32 defines/defaults: + * PNG_BUILD_DLL -- building dll + * PNG_USE_DLL -- building an application, linking to dll + * (no define) -- building static library, or building an + * application and linking to the static lib + * 'Cygwin' defines/defaults: + * PNG_BUILD_DLL -- (ignored) building the dll + * (no define) -- (ignored) building an application, linking to the dll + * PNG_STATIC -- (ignored) building the static lib, or building an + * application that links to the static lib. + * ALL_STATIC -- (ignored) building various static libs, or building an + * application that links to the static libs. + * Thus, + * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and + * this bit of #ifdefs will define the 'correct' config variables based on + * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but + * unnecessary. + * + * Also, the precedence order is: + * ALL_STATIC (since we can't #undef something outside our namespace) + * PNG_BUILD_DLL + * PNG_STATIC + * (nothing) == PNG_USE_DLL + * + * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent + * of auto-import in binutils, we no longer need to worry about + * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, + * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes + * to __declspec() stuff. However, we DO need to worry about + * PNG_BUILD_DLL and PNG_STATIC because those change some defaults + * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. + */ +#if defined(__CYGWIN__) +# if defined(ALL_STATIC) +# if defined(PNG_BUILD_DLL) +# undef PNG_BUILD_DLL +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# if !defined(PNG_STATIC) +# define PNG_STATIC +# endif +# else +# if defined (PNG_BUILD_DLL) +# if defined(PNG_STATIC) +# undef PNG_STATIC +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# else +# if defined(PNG_STATIC) +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# else +# if !defined(PNG_USE_DLL) +# define PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# endif +# endif +# endif +#endif + +/* This protects us against compilers that run on a windowing system + * and thus don't have or would rather us not use the stdio types: + * stdin, stdout, and stderr. The only one currently used is stderr + * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will + * prevent these from being compiled and used. #defining PNG_NO_STDIO + * will also prevent these, plus will prevent the entire set of stdio + * macros and functions (FILE *, printf, etc.) from being compiled and used, + * unless (PNG_DEBUG > 0) has been #defined. + * + * #define PNG_NO_CONSOLE_IO + * #define PNG_NO_STDIO + */ + +#if defined(_WIN32_WCE) +# include + /* Console I/O functions are not supported on WindowsCE */ +# define PNG_NO_CONSOLE_IO + /* abort() may not be supported on some/all Windows CE platforms */ +# define PNG_ABORT() exit(-1) +# ifdef PNG_DEBUG +# undef PNG_DEBUG +# endif +#endif + +#ifdef PNG_BUILD_DLL +# ifndef PNG_CONSOLE_IO_SUPPORTED +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# endif +#endif + +# ifdef PNG_NO_STDIO +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# include +# endif +# endif +# else +# if !defined(_WIN32_WCE) +/* "stdio.h" functions are not supported on WindowsCE */ +# include +# endif +# endif + +/* This macro protects us against machines that don't have function + * prototypes (ie K&R style headers). If your compiler does not handle + * function prototypes, define this macro and use the included ansi2knr. + * I've always been able to use _NO_PROTO as the indicator, but you may + * need to drag the empty declaration out in front of here, or change the + * ifdef to suit your own needs. + */ +#ifndef PNGARG + +#ifdef OF /* zlib prototype munger */ +# define PNGARG(arglist) OF(arglist) +#else + +#ifdef _NO_PROTO +# define PNGARG(arglist) () +# ifndef PNG_TYPECAST_NULL +# define PNG_TYPECAST_NULL +# endif +#else +# define PNGARG(arglist) arglist +#endif /* _NO_PROTO */ + + +#endif /* OF */ + +#endif /* PNGARG */ + +/* Try to determine if we are compiling on a Mac. Note that testing for + * just __MWERKS__ is not good enough, because the Codewarrior is now used + * on non-Mac platforms. + */ +#ifndef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) +# define MACOS +# endif +#endif + +/* enough people need this for various reasons to include it here */ +#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) +# include +#endif + +#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) +# define PNG_SETJMP_SUPPORTED +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This is an attempt to force a single setjmp behaviour on Linux. If + * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + * + * You can bypass this test if you know that your application uses exactly + * the same setjmp.h that was included when libpng was built. Only define + * PNG_SKIP_SETJMP_CHECK while building your application, prior to the + * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK + * while building a separate libpng library for general use. + */ + +# ifndef PNG_SKIP_SETJMP_CHECK +# ifdef __linux__ +# ifdef _BSD_SOURCE +# define PNG_SAVE_BSD_SOURCE +# undef _BSD_SOURCE +# endif +# ifdef _SETJMP_H + /* If you encounter a compiler error here, see the explanation + * near the end of INSTALL. + */ + __pngconf.h__ in libpng already includes setjmp.h; + __dont__ include it again.; +# endif +# endif /* __linux__ */ +# endif /* PNG_SKIP_SETJMP_CHECK */ + + /* include setjmp.h for error handling */ +# include + +# ifdef __linux__ +# ifdef PNG_SAVE_BSD_SOURCE +# ifndef _BSD_SOURCE +# define _BSD_SOURCE +# endif +# undef PNG_SAVE_BSD_SOURCE +# endif +# endif /* __linux__ */ +#endif /* PNG_SETJMP_SUPPORTED */ + +#ifdef BSD +# include +#else +# include +#endif + +/* Other defines for things like memory and the like can go here. */ +#ifdef PNG_INTERNAL + +#include + +/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which + * aren't usually used outside the library (as far as I know), so it is + * debatable if they should be exported at all. In the future, when it is + * possible to have run-time registry of chunk-handling functions, some of + * these will be made available again. +#define PNG_EXTERN extern + */ +#define PNG_EXTERN + +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) +# if defined(MACOS) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include +# endif +# else +# include +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include +# endif +#endif + +/* Codewarrior on NT has linking problems without this. */ +#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) +# define PNG_ALWAYS_EXTERN +#endif + +/* This provides the non-ANSI (far) memory allocation routines. */ +#if defined(__TURBOC__) && defined(__MSDOS__) +# include +# include +#endif + +/* I have no idea why is this necessary... */ +#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ + defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) +# include +#endif + +/* This controls how fine the dithering gets. As this allocates + * a largish chunk of memory (32K), those who are not as concerned + * with dithering quality can decrease some or all of these. + */ +#ifndef PNG_DITHER_RED_BITS +# define PNG_DITHER_RED_BITS 5 +#endif +#ifndef PNG_DITHER_GREEN_BITS +# define PNG_DITHER_GREEN_BITS 5 +#endif +#ifndef PNG_DITHER_BLUE_BITS +# define PNG_DITHER_BLUE_BITS 5 +#endif + +/* This controls how fine the gamma correction becomes when you + * are only interested in 8 bits anyway. Increasing this value + * results in more memory being used, and more pow() functions + * being called to fill in the gamma tables. Don't set this value + * less then 8, and even that may not work (I haven't tested it). + */ + +#ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +#endif + +/* This controls how much a difference in gamma we can tolerate before + * we actually start doing gamma conversion. + */ +#ifndef PNG_GAMMA_THRESHOLD +# define PNG_GAMMA_THRESHOLD 0.05 +#endif + +#endif /* PNG_INTERNAL */ + +/* The following uses const char * instead of char * for error + * and warning message functions, so some compilers won't complain. + * If you do not want to use const, define PNG_NO_CONST here. + */ + +#ifndef PNG_NO_CONST +# define PNG_CONST const +#else +# define PNG_CONST +#endif + +/* The following defines give you the ability to remove code from the + * library that you will not be using. I wish I could figure out how to + * automate this, but I can't do that without making it seriously hard + * on the users. So if you are not using an ability, change the #define + * to and #undef, and that part of the library will not be compiled. If + * your linker can't find a function, you may want to make sure the + * ability is defined here. Some of these depend upon some others being + * defined. I haven't figured out all the interactions here, so you may + * have to experiment awhile to get everything to compile. If you are + * creating or using a shared library, you probably shouldn't touch this, + * as it will affect the size of the structures, and this will cause bad + * things to happen if the library and/or application ever change. + */ + +/* Any features you will not be using can be undef'ed here */ + +/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user + * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS + * on the compile line, then pick and choose which ones to define without + * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED + * if you only want to have a png-compliant reader/writer but don't need + * any of the extra transformations. This saves about 80 kbytes in a + * typical installation of the library. (PNG_NO_* form added in version + * 1.0.1c, for consistency) + */ + +/* The size of the png_text structure changed in libpng-1.0.6 when + * iTXt support was added. iTXt support was turned off by default through + * libpng-1.2.x, to support old apps that malloc the png_text structure + * instead of calling png_set_text() and letting libpng malloc it. It + * was turned on by default in libpng-1.3.0. + */ + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +# ifndef PNG_NO_iTXt_SUPPORTED +# define PNG_NO_iTXt_SUPPORTED +# endif +# ifndef PNG_NO_READ_iTXt +# define PNG_NO_READ_iTXt +# endif +# ifndef PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_iTXt +# endif +#endif + +#if !defined(PNG_NO_iTXt_SUPPORTED) +# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) +# define PNG_READ_iTXt +# endif +# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) +# define PNG_WRITE_iTXt +# endif +#endif + +/* The following support, added after version 1.0.0, can be turned off here en + * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility + * with old applications that require the length of png_struct and png_info + * to remain unchanged. + */ + +#ifdef PNG_LEGACY_SUPPORTED +# define PNG_NO_FREE_ME +# define PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_NO_READ_USER_CHUNKS +# define PNG_NO_READ_iCCP +# define PNG_NO_WRITE_iCCP +# define PNG_NO_READ_iTXt +# define PNG_NO_WRITE_iTXt +# define PNG_NO_READ_sCAL +# define PNG_NO_WRITE_sCAL +# define PNG_NO_READ_sPLT +# define PNG_NO_WRITE_sPLT +# define PNG_NO_INFO_IMAGE +# define PNG_NO_READ_RGB_TO_GRAY +# define PNG_NO_READ_USER_TRANSFORM +# define PNG_NO_WRITE_USER_TRANSFORM +# define PNG_NO_USER_MEM +# define PNG_NO_READ_EMPTY_PLTE +# define PNG_NO_MNG_FEATURES +# define PNG_NO_FIXED_POINT_SUPPORTED +#endif + +/* Ignore attempt to turn off both floating and fixed point support */ +#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ + !defined(PNG_NO_FIXED_POINT_SUPPORTED) +# define PNG_FIXED_POINT_SUPPORTED +#endif + +#ifndef PNG_NO_FREE_ME +# define PNG_FREE_ME_SUPPORTED +#endif + +#if defined(PNG_READ_SUPPORTED) + +#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_TRANSFORMS) +# define PNG_READ_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_READ_EXPAND +# define PNG_READ_EXPAND_SUPPORTED +# endif +# ifndef PNG_NO_READ_SHIFT +# define PNG_READ_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACK +# define PNG_READ_PACK_SUPPORTED +# endif +# ifndef PNG_NO_READ_BGR +# define PNG_READ_BGR_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP +# define PNG_READ_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACKSWAP +# define PNG_READ_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT +# define PNG_READ_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_READ_DITHER +# define PNG_READ_DITHER_SUPPORTED +# endif +# ifndef PNG_NO_READ_BACKGROUND +# define PNG_READ_BACKGROUND_SUPPORTED +# endif +# ifndef PNG_NO_READ_16_TO_8 +# define PNG_READ_16_TO_8_SUPPORTED +# endif +# ifndef PNG_NO_READ_FILLER +# define PNG_READ_FILLER_SUPPORTED +# endif +# ifndef PNG_NO_READ_GAMMA +# define PNG_READ_GAMMA_SUPPORTED +# endif +# ifndef PNG_NO_READ_GRAY_TO_RGB +# define PNG_READ_GRAY_TO_RGB_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP_ALPHA +# define PNG_READ_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT_ALPHA +# define PNG_READ_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_STRIP_ALPHA +# define PNG_READ_STRIP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_USER_TRANSFORM +# define PNG_READ_USER_TRANSFORM_SUPPORTED +# endif +# ifndef PNG_NO_READ_RGB_TO_GRAY +# define PNG_READ_RGB_TO_GRAY_SUPPORTED +# endif +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_PROGRESSIVE_READ) && \ + !defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */ +# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ +#endif /* about interlacing capability! You'll */ + /* still have interlacing unless you change the following line: */ + +#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */ + +#ifndef PNG_NO_READ_COMPOSITE_NODIV +# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ +# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ +# endif +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated, will be removed from version 2.0.0. + Use PNG_MNG_FEATURES_SUPPORTED instead. */ +#ifndef PNG_NO_READ_EMPTY_PLTE +# define PNG_READ_EMPTY_PLTE_SUPPORTED +#endif +#endif + +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_WRITE_SUPPORTED) + +# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_TRANSFORMS) +# define PNG_WRITE_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_WRITE_SHIFT +# define PNG_WRITE_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACK +# define PNG_WRITE_PACK_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_BGR +# define PNG_WRITE_BGR_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_SWAP +# define PNG_WRITE_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACKSWAP +# define PNG_WRITE_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT +# define PNG_WRITE_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_FILLER +# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ +# endif +# ifndef PNG_NO_WRITE_SWAP_ALPHA +# define PNG_WRITE_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT_ALPHA +# define PNG_WRITE_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_USER_TRANSFORM +# define PNG_WRITE_USER_TRANSFORM_SUPPORTED +# endif +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ + !defined(PNG_WRITE_INTERLACING_SUPPORTED) +#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant + encoders, but can cause trouble + if left undefined */ +#endif + +#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ + !defined(PNG_WRITE_WEIGHTED_FILTER) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#endif + +#ifndef PNG_NO_WRITE_FLUSH +# define PNG_WRITE_FLUSH_SUPPORTED +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ +#ifndef PNG_NO_WRITE_EMPTY_PLTE +# define PNG_WRITE_EMPTY_PLTE_SUPPORTED +#endif +#endif + +#endif /* PNG_WRITE_SUPPORTED */ + +#ifndef PNG_1_0_X +# ifndef PNG_NO_ERROR_NUMBERS +# define PNG_ERROR_NUMBERS_SUPPORTED +# endif +#endif /* PNG_1_0_X */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +# ifndef PNG_NO_USER_TRANSFORM_PTR +# define PNG_USER_TRANSFORM_PTR_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_STDIO +# define PNG_TIME_RFC1123_SUPPORTED +#endif + +/* This adds extra functions in pngget.c for accessing data from the + * info pointer (added in version 0.99) + * png_get_image_width() + * png_get_image_height() + * png_get_bit_depth() + * png_get_color_type() + * png_get_compression_type() + * png_get_filter_type() + * png_get_interlace_type() + * png_get_pixel_aspect_ratio() + * png_get_pixels_per_meter() + * png_get_x_offset_pixels() + * png_get_y_offset_pixels() + * png_get_x_offset_microns() + * png_get_y_offset_microns() + */ +#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) +# define PNG_EASY_ACCESS_SUPPORTED +#endif + +/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 + * and removed from version 1.2.20. The following will be removed + * from libpng-1.4.0 +*/ + +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE) +# ifndef PNG_OPTIMIZED_CODE_SUPPORTED +# define PNG_OPTIMIZED_CODE_SUPPORTED +# endif +#endif + +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) && defined(__i386__) +# ifndef PNG_ASSEMBLER_CODE_SUPPORTED +# define PNG_ASSEMBLER_CODE_SUPPORTED +# endif + +# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4) + /* work around 64-bit gcc compiler bugs in gcc-3.x */ +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_NO_MMX_CODE +# endif +# endif + +# if defined(__APPLE__) +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_NO_MMX_CODE +# endif +# endif + +# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh)) +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_NO_MMX_CODE +# endif +# endif + +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_MMX_CODE_SUPPORTED +# endif + +#endif +/* end of obsolete code to be removed from libpng-1.4.0 */ + +#if !defined(PNG_1_0_X) +#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) +# define PNG_USER_MEM_SUPPORTED +#endif +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.2.6 */ +#if !defined(PNG_1_0_X) +#ifndef PNG_SET_USER_LIMITS_SUPPORTED +#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) +# define PNG_SET_USER_LIMITS_SUPPORTED +#endif +#endif +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter + * how large, set these limits to 0x7fffffffL + */ +#ifndef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 1000000L +#endif +#ifndef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 1000000L +#endif + +/* Added at libpng-1.2.34 and 1.4.0 */ +#ifndef PNG_STRING_NEWLINE +#define PNG_STRING_NEWLINE "\n" +#endif + +/* These are currently experimental features, define them if you want */ + +/* very little testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# endif +#endif +*/ + +/* This is only for PowerPC big-endian and 680x0 systems */ +/* some testing */ +/* +#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED +# define PNG_READ_BIG_ENDIAN_SUPPORTED +#endif +*/ + +/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ +/* +#define PNG_NO_POINTER_INDEXING +*/ + +/* These functions are turned off by default, as they will be phased out. */ +/* +#define PNG_USELESS_TESTS_SUPPORTED +#define PNG_CORRECT_PALETTE_SUPPORTED +*/ + +/* Any chunks you are not interested in, you can undef here. The + * ones that allocate memory may be expecially important (hIST, + * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info + * a bit smaller. + */ + +#if defined(PNG_READ_SUPPORTED) && \ + !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_ANCILLARY_CHUNKS) +# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#if defined(PNG_WRITE_SUPPORTED) && \ + !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) +# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_READ_TEXT +# define PNG_NO_READ_iTXt +# define PNG_NO_READ_tEXt +# define PNG_NO_READ_zTXt +#endif +#ifndef PNG_NO_READ_bKGD +# define PNG_READ_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +#endif +#ifndef PNG_NO_READ_cHRM +# define PNG_READ_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +#endif +#ifndef PNG_NO_READ_gAMA +# define PNG_READ_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +#endif +#ifndef PNG_NO_READ_hIST +# define PNG_READ_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +#endif +#ifndef PNG_NO_READ_iCCP +# define PNG_READ_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +#endif +#ifndef PNG_NO_READ_iTXt +# ifndef PNG_READ_iTXt_SUPPORTED +# define PNG_READ_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_READ_oFFs +# define PNG_READ_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +#endif +#ifndef PNG_NO_READ_pCAL +# define PNG_READ_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_sCAL +# define PNG_READ_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_pHYs +# define PNG_READ_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +#endif +#ifndef PNG_NO_READ_sBIT +# define PNG_READ_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sPLT +# define PNG_READ_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sRGB +# define PNG_READ_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +#endif +#ifndef PNG_NO_READ_tEXt +# define PNG_READ_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_tIME +# define PNG_READ_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +#endif +#ifndef PNG_NO_READ_tRNS +# define PNG_READ_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +#endif +#ifndef PNG_NO_READ_zTXt +# define PNG_READ_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#if !defined(PNG_NO_READ_USER_CHUNKS) && \ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# define PNG_READ_USER_CHUNKS_SUPPORTED +# define PNG_USER_CHUNKS_SUPPORTED +# ifdef PNG_NO_READ_UNKNOWN_CHUNKS +# undef PNG_NO_READ_UNKNOWN_CHUNKS +# endif +# ifdef PNG_NO_HANDLE_AS_UNKNOWN +# undef PNG_NO_HANDLE_AS_UNKNOWN +# endif +#endif +#ifndef PNG_NO_READ_OPT_PLTE +# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ +#endif /* optional PLTE chunk in RGB and RGBA images */ +#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ + defined(PNG_READ_zTXt_SUPPORTED) +# define PNG_READ_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +#endif + +#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ + +#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_WRITE_TEXT +# define PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_tEXt +# define PNG_NO_WRITE_zTXt +#endif +#ifndef PNG_NO_WRITE_bKGD +# define PNG_WRITE_bKGD_SUPPORTED +# ifndef PNG_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_cHRM +# define PNG_WRITE_cHRM_SUPPORTED +# ifndef PNG_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_gAMA +# define PNG_WRITE_gAMA_SUPPORTED +# ifndef PNG_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_hIST +# define PNG_WRITE_hIST_SUPPORTED +# ifndef PNG_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iCCP +# define PNG_WRITE_iCCP_SUPPORTED +# ifndef PNG_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iTXt +# ifndef PNG_WRITE_iTXt_SUPPORTED +# define PNG_WRITE_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_oFFs +# define PNG_WRITE_oFFs_SUPPORTED +# ifndef PNG_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pCAL +# define PNG_WRITE_pCAL_SUPPORTED +# ifndef PNG_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sCAL +# define PNG_WRITE_sCAL_SUPPORTED +# ifndef PNG_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pHYs +# define PNG_WRITE_pHYs_SUPPORTED +# ifndef PNG_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sBIT +# define PNG_WRITE_sBIT_SUPPORTED +# ifndef PNG_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sPLT +# define PNG_WRITE_sPLT_SUPPORTED +# ifndef PNG_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sRGB +# define PNG_WRITE_sRGB_SUPPORTED +# ifndef PNG_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tEXt +# define PNG_WRITE_tEXt_SUPPORTED +# ifndef PNG_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tIME +# define PNG_WRITE_tIME_SUPPORTED +# ifndef PNG_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tRNS +# define PNG_WRITE_tRNS_SUPPORTED +# ifndef PNG_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_zTXt +# define PNG_WRITE_zTXt_SUPPORTED +# ifndef PNG_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +# endif +#endif +#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ + defined(PNG_WRITE_zTXt_SUPPORTED) +# define PNG_WRITE_TEXT_SUPPORTED +# ifndef PNG_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +# endif +#endif + +#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ + +/* Turn this off to disable png_read_png() and + * png_write_png() and leave the row_pointers member + * out of the info structure. + */ +#ifndef PNG_NO_INFO_IMAGE +# define PNG_INFO_IMAGE_SUPPORTED +#endif + +/* need the time information for reading tIME chunks */ +#if defined(PNG_tIME_SUPPORTED) +# if !defined(_WIN32_WCE) + /* "time.h" functions are not supported on WindowsCE */ +# include +# endif +#endif + +/* Some typedefs to get us started. These should be safe on most of the + * common platforms. The typedefs should be at least as large as the + * numbers suggest (a png_uint_32 must be at least 32 bits long), but they + * don't have to be exactly that size. Some compilers dislike passing + * unsigned shorts as function parameters, so you may be better off using + * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may + * want to have unsigned int for png_uint_32 instead of unsigned long. + */ + +typedef unsigned long png_uint_32; +typedef long png_int_32; +typedef unsigned short png_uint_16; +typedef short png_int_16; +typedef unsigned char png_byte; + +/* This is usually size_t. It is typedef'ed just in case you need it to + change (I'm not sure if you will or not, so I thought I'd be safe) */ +#ifdef PNG_SIZE_T + typedef PNG_SIZE_T png_size_t; +# define png_sizeof(x) png_convert_size(sizeof(x)) +#else + typedef size_t png_size_t; +# define png_sizeof(x) sizeof(x) +#endif + +/* The following is needed for medium model support. It cannot be in the + * PNG_INTERNAL section. Needs modification for other compilers besides + * MSC. Model independent support declares all arrays and pointers to be + * large using the far keyword. The zlib version used must also support + * model independent data. As of version zlib 1.0.4, the necessary changes + * have been made in zlib. The USE_FAR_KEYWORD define triggers other + * changes that are needed. (Tim Wegner) + */ + +/* Separate compiler dependencies (problem here is that zlib.h always + defines FAR. (SJT) */ +#ifdef __BORLANDC__ +# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) +# define LDATA 1 +# else +# define LDATA 0 +# endif + /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ +# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) +# define PNG_MAX_MALLOC_64K +# if (LDATA != 1) +# ifndef FAR +# define FAR __far +# endif +# define USE_FAR_KEYWORD +# endif /* LDATA != 1 */ + /* Possibly useful for moving data out of default segment. + * Uncomment it if you want. Could also define FARDATA as + * const if your compiler supports it. (SJT) +# define FARDATA FAR + */ +# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ +#endif /* __BORLANDC__ */ + + +/* Suggest testing for specific compiler first before testing for + * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, + * making reliance oncertain keywords suspect. (SJT) + */ + +/* MSC Medium model */ +#if defined(FAR) +# if defined(M_I86MM) +# define USE_FAR_KEYWORD +# define FARDATA FAR +# include +# endif +#endif + +/* SJT: default case */ +#ifndef FAR +# define FAR +#endif + +/* At this point FAR is always defined */ +#ifndef FARDATA +# define FARDATA +#endif + +/* Typedef for floating-point numbers that are converted + to fixed-point with a multiple of 100,000, e.g., int_gamma */ +typedef png_int_32 png_fixed_point; + +/* Add typedefs for pointers */ +typedef void FAR * png_voidp; +typedef png_byte FAR * png_bytep; +typedef png_uint_32 FAR * png_uint_32p; +typedef png_int_32 FAR * png_int_32p; +typedef png_uint_16 FAR * png_uint_16p; +typedef png_int_16 FAR * png_int_16p; +typedef PNG_CONST char FAR * png_const_charp; +typedef char FAR * png_charp; +typedef png_fixed_point FAR * png_fixed_point_p; + +#ifndef PNG_NO_STDIO +#if defined(_WIN32_WCE) +typedef HANDLE png_FILE_p; +#else +typedef FILE * png_FILE_p; +#endif +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * png_doublep; +#endif + +/* Pointers to pointers; i.e. arrays */ +typedef png_byte FAR * FAR * png_bytepp; +typedef png_uint_32 FAR * FAR * png_uint_32pp; +typedef png_int_32 FAR * FAR * png_int_32pp; +typedef png_uint_16 FAR * FAR * png_uint_16pp; +typedef png_int_16 FAR * FAR * png_int_16pp; +typedef PNG_CONST char FAR * FAR * png_const_charpp; +typedef char FAR * FAR * png_charpp; +typedef png_fixed_point FAR * FAR * png_fixed_point_pp; +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * FAR * png_doublepp; +#endif + +/* Pointers to pointers to pointers; i.e., pointer to array */ +typedef char FAR * FAR * FAR * png_charppp; + +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +/* SPC - Is this stuff deprecated? */ +/* It'll be removed as of libpng-1.3.0 - GR-P */ +/* libpng typedefs for types in zlib. If zlib changes + * or another compression library is used, then change these. + * Eliminates need to change all the source files. + */ +typedef charf * png_zcharp; +typedef charf * FAR * png_zcharpp; +typedef z_stream FAR * png_zstreamp; +#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ + +/* + * Define PNG_BUILD_DLL if the module being built is a Windows + * LIBPNG DLL. + * + * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. + * It is equivalent to Microsoft predefined macro _DLL that is + * automatically defined when you compile using the share + * version of the CRT (C Run-Time library) + * + * The cygwin mods make this behavior a little different: + * Define PNG_BUILD_DLL if you are building a dll for use with cygwin + * Define PNG_STATIC if you are building a static library for use with cygwin, + * -or- if you are building an application that you want to link to the + * static library. + * PNG_USE_DLL is defined by default (no user action needed) unless one of + * the other flags is defined. + */ + +#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) +# define PNG_DLL +#endif +/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. + * When building a static lib, default to no GLOBAL ARRAYS, but allow + * command-line override + */ +#if defined(__CYGWIN__) +# if !defined(PNG_STATIC) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +# else +# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# endif +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +#endif + +/* Do not use global arrays (helps with building DLL's) + * They are no longer used in libpng itself, since version 1.0.5c, + * but might be required for some pre-1.0.5c applications. + */ +#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# if defined(PNG_NO_GLOBAL_ARRAYS) || \ + (defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER) +# define PNG_USE_LOCAL_ARRAYS +# else +# define PNG_USE_GLOBAL_ARRAYS +# endif +#endif + +#if defined(__CYGWIN__) +# undef PNGAPI +# define PNGAPI __cdecl +# undef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", + * you may get warnings regarding the linkage of png_zalloc and png_zfree. + * Don't ignore those warnings; you must also reset the default calling + * convention in your compiler to match your PNGAPI, and you must build + * zlib and your applications the same way you build libpng. + */ + +#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) +# ifndef PNG_NO_MODULEDEF +# define PNG_NO_MODULEDEF +# endif +#endif + +#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) +# define PNG_IMPEXP +#endif + +#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ + (( defined(_Windows) || defined(_WINDOWS) || \ + defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) + +# ifndef PNGAPI +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGAPI __cdecl +# else +# define PNGAPI _cdecl +# endif +# endif + +# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ + 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) +# define PNG_IMPEXP +# endif + +# if !defined(PNG_IMPEXP) + +# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol +# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol + + /* Borland/Microsoft */ +# if defined(_MSC_VER) || defined(__BORLANDC__) +# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) +# define PNG_EXPORT PNG_EXPORT_TYPE1 +# else +# define PNG_EXPORT PNG_EXPORT_TYPE2 +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __export +# else +# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in + VC++ */ +# endif /* Exists in Borland C++ for + C++ classes (== huge) */ +# endif +# endif + +# if !defined(PNG_IMPEXP) +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __declspec(dllexport) +# else +# define PNG_IMPEXP __declspec(dllimport) +# endif +# endif +# endif /* PNG_IMPEXP */ +#else /* !(DLL || non-cygwin WINDOWS) */ +# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) +# ifndef PNGAPI +# define PNGAPI _System +# endif +# else +# if 0 /* ... other platforms, with other meanings */ +# endif +# endif +#endif + +#ifndef PNGAPI +# define PNGAPI +#endif +#ifndef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +#ifdef PNG_BUILDSYMS +# ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END +# endif +# ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT +# endif +# endif +#endif + +#ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type +# endif +#endif + +/* User may want to use these so they are not in PNG_INTERNAL. Any library + * functions that are passed far data must be model independent. + */ + +#ifndef PNG_ABORT +# define PNG_ABORT() abort() +#endif + +#ifdef PNG_SETJMP_SUPPORTED +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) +#endif + +#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ +/* use this to make far-to-near assignments */ +# define CHECK 1 +# define NOCHECK 0 +# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) +# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) +# define png_snprintf _fsnprintf /* Added to v 1.2.19 */ +# define png_strlen _fstrlen +# define png_memcmp _fmemcmp /* SJT: added */ +# define png_memcpy _fmemcpy +# define png_memset _fmemset +#else /* use the usual functions */ +# define CVT_PTR(ptr) (ptr) +# define CVT_PTR_NOCHECK(ptr) (ptr) +# ifndef PNG_NO_SNPRINTF +# ifdef _MSC_VER +# define png_snprintf _snprintf /* Added to v 1.2.19 */ +# define png_snprintf2 _snprintf +# define png_snprintf6 _snprintf +# else +# define png_snprintf snprintf /* Added to v 1.2.19 */ +# define png_snprintf2 snprintf +# define png_snprintf6 snprintf +# endif +# else + /* You don't have or don't want to use snprintf(). Caution: Using + * sprintf instead of snprintf exposes your application to accidental + * or malevolent buffer overflows. If you don't have snprintf() + * as a general rule you should provide one (you can get one from + * Portable OpenSSH). */ +# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1) +# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2) +# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \ + sprintf(s1,fmt,x1,x2,x3,x4,x5,x6) +# endif +# define png_strlen strlen +# define png_memcmp memcmp /* SJT: added */ +# define png_memcpy memcpy +# define png_memset memset +#endif +/* End of memory model independent support */ + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536L +#endif + +/* Added at libpng-1.2.8 */ +#endif /* PNG_VERSION_INFO_ONLY */ + +#endif /* PNGCONF_H */ diff --git a/lib/libpng/include/png.h b/lib/libpng/include/png.h new file mode 100644 index 0000000..9fc8cef --- /dev/null +++ b/lib/libpng/include/png.h @@ -0,0 +1,3687 @@ +/* png.h - header file for PNG reference library + * + * libpng version 1.2.37 - June 4, 2009 + * Copyright (c) 1998-2009 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Authors and maintainers: + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.2.37 - June 4, 2009: Glenn + * See also "Contributing Authors", below. + * + * Note about libpng version numbers: + * + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: + * + * source png.h png.h shared-lib + * version string int version + * ------- ------ ----- ---------- + * 0.89c "1.0 beta 3" 0.89 89 1.0.89 + * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] + * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] + * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] + * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] + * 0.97c 0.97 97 2.0.97 + * 0.98 0.98 98 2.0.98 + * 0.99 0.99 98 2.0.99 + * 0.99a-m 0.99 99 2.0.99 + * 1.00 1.00 100 2.1.0 [100 should be 10000] + * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] + * 1.0.1 png.h string is 10001 2.1.0 + * 1.0.1a-e identical to the 10002 from here on, the shared library + * 1.0.2 source version) 10002 is 2.V where V is the source code + * 1.0.2a-b 10003 version, except as noted. + * 1.0.3 10003 + * 1.0.3a-d 10004 + * 1.0.4 10004 + * 1.0.4a-f 10005 + * 1.0.5 (+ 2 patches) 10005 + * 1.0.5a-d 10006 + * 1.0.5e-r 10100 (not source compatible) + * 1.0.5s-v 10006 (not binary compatible) + * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) + * 1.0.6d-f 10007 (still binary incompatible) + * 1.0.6g 10007 + * 1.0.6h 10007 10.6h (testing xy.z so-numbering) + * 1.0.6i 10007 10.6i + * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) + * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) + * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) + * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) + * 1.0.7 1 10007 (still compatible) + * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 + * 1.0.8rc1 1 10008 2.1.0.8rc1 + * 1.0.8 1 10008 2.1.0.8 + * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 + * 1.0.9rc1 1 10009 2.1.0.9rc1 + * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 + * 1.0.9rc2 1 10009 2.1.0.9rc2 + * 1.0.9 1 10009 2.1.0.9 + * 1.0.10beta1 1 10010 2.1.0.10beta1 + * 1.0.10rc1 1 10010 2.1.0.10rc1 + * 1.0.10 1 10010 2.1.0.10 + * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 + * 1.0.11rc1 1 10011 2.1.0.11rc1 + * 1.0.11 1 10011 2.1.0.11 + * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 + * 1.0.12rc1 2 10012 2.1.0.12rc1 + * 1.0.12 2 10012 2.1.0.12 + * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) + * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 + * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 + * 1.2.0rc1 3 10200 3.1.2.0rc1 + * 1.2.0 3 10200 3.1.2.0 + * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 + * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 + * 1.2.1 3 10201 3.1.2.1 + * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 + * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 + * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 + * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 + * 1.0.13 10 10013 10.so.0.1.0.13 + * 1.2.2 12 10202 12.so.0.1.2.2 + * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 + * 1.2.3 12 10203 12.so.0.1.2.3 + * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 + * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 + * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 + * 1.0.14 10 10014 10.so.0.1.0.14 + * 1.2.4 13 10204 12.so.0.1.2.4 + * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 + * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 + * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 + * 1.0.15 10 10015 10.so.0.1.0.15 + * 1.2.5 13 10205 12.so.0.1.2.5 + * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 + * 1.0.16 10 10016 10.so.0.1.0.16 + * 1.2.6 13 10206 12.so.0.1.2.6 + * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 + * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 + * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 + * 1.0.17 10 10017 10.so.0.1.0.17 + * 1.2.7 13 10207 12.so.0.1.2.7 + * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 + * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 + * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 + * 1.0.18 10 10018 10.so.0.1.0.18 + * 1.2.8 13 10208 12.so.0.1.2.8 + * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 + * 1.2.9beta4-11 13 10209 12.so.0.9[.0] + * 1.2.9rc1 13 10209 12.so.0.9[.0] + * 1.2.9 13 10209 12.so.0.9[.0] + * 1.2.10beta1-8 13 10210 12.so.0.10[.0] + * 1.2.10rc1-3 13 10210 12.so.0.10[.0] + * 1.2.10 13 10210 12.so.0.10[.0] + * 1.2.11beta1-4 13 10211 12.so.0.11[.0] + * 1.0.19rc1-5 10 10019 10.so.0.19[.0] + * 1.2.11rc1-5 13 10211 12.so.0.11[.0] + * 1.0.19 10 10019 10.so.0.19[.0] + * 1.2.11 13 10211 12.so.0.11[.0] + * 1.0.20 10 10020 10.so.0.20[.0] + * 1.2.12 13 10212 12.so.0.12[.0] + * 1.2.13beta1 13 10213 12.so.0.13[.0] + * 1.0.21 10 10021 10.so.0.21[.0] + * 1.2.13 13 10213 12.so.0.13[.0] + * 1.2.14beta1-2 13 10214 12.so.0.14[.0] + * 1.0.22rc1 10 10022 10.so.0.22[.0] + * 1.2.14rc1 13 10214 12.so.0.14[.0] + * 1.0.22 10 10022 10.so.0.22[.0] + * 1.2.14 13 10214 12.so.0.14[.0] + * 1.2.15beta1-6 13 10215 12.so.0.15[.0] + * 1.0.23rc1-5 10 10023 10.so.0.23[.0] + * 1.2.15rc1-5 13 10215 12.so.0.15[.0] + * 1.0.23 10 10023 10.so.0.23[.0] + * 1.2.15 13 10215 12.so.0.15[.0] + * 1.2.16beta1-2 13 10216 12.so.0.16[.0] + * 1.2.16rc1 13 10216 12.so.0.16[.0] + * 1.0.24 10 10024 10.so.0.24[.0] + * 1.2.16 13 10216 12.so.0.16[.0] + * 1.2.17beta1-2 13 10217 12.so.0.17[.0] + * 1.0.25rc1 10 10025 10.so.0.25[.0] + * 1.2.17rc1-3 13 10217 12.so.0.17[.0] + * 1.0.25 10 10025 10.so.0.25[.0] + * 1.2.17 13 10217 12.so.0.17[.0] + * 1.0.26 10 10026 10.so.0.26[.0] + * 1.2.18 13 10218 12.so.0.18[.0] + * 1.2.19beta1-31 13 10219 12.so.0.19[.0] + * 1.0.27rc1-6 10 10027 10.so.0.27[.0] + * 1.2.19rc1-6 13 10219 12.so.0.19[.0] + * 1.0.27 10 10027 10.so.0.27[.0] + * 1.2.19 13 10219 12.so.0.19[.0] + * 1.2.20beta01-04 13 10220 12.so.0.20[.0] + * 1.0.28rc1-6 10 10028 10.so.0.28[.0] + * 1.2.20rc1-6 13 10220 12.so.0.20[.0] + * 1.0.28 10 10028 10.so.0.28[.0] + * 1.2.20 13 10220 12.so.0.20[.0] + * 1.2.21beta1-2 13 10221 12.so.0.21[.0] + * 1.2.21rc1-3 13 10221 12.so.0.21[.0] + * 1.0.29 10 10029 10.so.0.29[.0] + * 1.2.21 13 10221 12.so.0.21[.0] + * 1.2.22beta1-4 13 10222 12.so.0.22[.0] + * 1.0.30rc1 10 10030 10.so.0.30[.0] + * 1.2.22rc1 13 10222 12.so.0.22[.0] + * 1.0.30 10 10030 10.so.0.30[.0] + * 1.2.22 13 10222 12.so.0.22[.0] + * 1.2.23beta01-05 13 10223 12.so.0.23[.0] + * 1.2.23rc01 13 10223 12.so.0.23[.0] + * 1.2.23 13 10223 12.so.0.23[.0] + * 1.2.24beta01-02 13 10224 12.so.0.24[.0] + * 1.2.24rc01 13 10224 12.so.0.24[.0] + * 1.2.24 13 10224 12.so.0.24[.0] + * 1.2.25beta01-06 13 10225 12.so.0.25[.0] + * 1.2.25rc01-02 13 10225 12.so.0.25[.0] + * 1.0.31 10 10031 10.so.0.31[.0] + * 1.2.25 13 10225 12.so.0.25[.0] + * 1.2.26beta01-06 13 10226 12.so.0.26[.0] + * 1.2.26rc01 13 10226 12.so.0.26[.0] + * 1.2.26 13 10226 12.so.0.26[.0] + * 1.0.32 10 10032 10.so.0.32[.0] + * 1.2.27beta01-06 13 10227 12.so.0.27[.0] + * 1.2.27rc01 13 10227 12.so.0.27[.0] + * 1.0.33 10 10033 10.so.0.33[.0] + * 1.2.27 13 10227 12.so.0.27[.0] + * 1.0.34 10 10034 10.so.0.34[.0] + * 1.2.28 13 10228 12.so.0.28[.0] + * 1.2.29beta01-03 13 10229 12.so.0.29[.0] + * 1.2.29rc01 13 10229 12.so.0.29[.0] + * 1.0.35 10 10035 10.so.0.35[.0] + * 1.2.29 13 10229 12.so.0.29[.0] + * 1.0.37 10 10037 10.so.0.37[.0] + * 1.2.30beta01-04 13 10230 12.so.0.30[.0] + * 1.0.38rc01-08 10 10038 10.so.0.38[.0] + * 1.2.30rc01-08 13 10230 12.so.0.30[.0] + * 1.0.38 10 10038 10.so.0.38[.0] + * 1.2.30 13 10230 12.so.0.30[.0] + * 1.0.39rc01-03 10 10039 10.so.0.39[.0] + * 1.2.31rc01-03 13 10231 12.so.0.31[.0] + * 1.0.39 10 10039 10.so.0.39[.0] + * 1.2.31 13 10231 12.so.0.31[.0] + * 1.2.32beta01-02 13 10232 12.so.0.32[.0] + * 1.0.40rc01 10 10040 10.so.0.40[.0] + * 1.2.32rc01 13 10232 12.so.0.32[.0] + * 1.0.40 10 10040 10.so.0.40[.0] + * 1.2.32 13 10232 12.so.0.32[.0] + * 1.2.33beta01-02 13 10233 12.so.0.33[.0] + * 1.2.33rc01-02 13 10233 12.so.0.33[.0] + * 1.0.41rc01 10 10041 10.so.0.41[.0] + * 1.2.33 13 10233 12.so.0.33[.0] + * 1.0.41 10 10041 10.so.0.41[.0] + * 1.2.34beta01-07 13 10234 12.so.0.34[.0] + * 1.0.42rc01 10 10042 10.so.0.42[.0] + * 1.2.34rc01 13 10234 12.so.0.34[.0] + * 1.0.42 10 10042 10.so.0.42[.0] + * 1.2.34 13 10234 12.so.0.34[.0] + * 1.2.35beta01-03 13 10235 12.so.0.35[.0] + * 1.0.43rc01-02 10 10043 10.so.0.43[.0] + * 1.2.35rc01-02 13 10235 12.so.0.35[.0] + * 1.0.43 10 10043 10.so.0.43[.0] + * 1.2.35 13 10235 12.so.0.35[.0] + * 1.2.36beta01-05 13 10236 12.so.0.36[.0] + * 1.2.36rc01 13 10236 12.so.0.36[.0] + * 1.0.44 10 10044 10.so.0.44[.0] + * 1.2.36 13 10236 12.so.0.36[.0] + * 1.2.37beta01-03 13 10237 12.so.0.37[.0] + * 1.2.37rc01 13 10237 12.so.0.37[.0] + * 1.2.37 13 10237 12.so.0.37[.0] + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcNN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng.txt or libpng.3 for more information. The PNG specification + * is available as a W3C Recommendation and as an ISO Specification, + * defines should NOT be changed. + */ +#define PNG_INFO_gAMA 0x0001 +#define PNG_INFO_sBIT 0x0002 +#define PNG_INFO_cHRM 0x0004 +#define PNG_INFO_PLTE 0x0008 +#define PNG_INFO_tRNS 0x0010 +#define PNG_INFO_bKGD 0x0020 +#define PNG_INFO_hIST 0x0040 +#define PNG_INFO_pHYs 0x0080 +#define PNG_INFO_oFFs 0x0100 +#define PNG_INFO_tIME 0x0200 +#define PNG_INFO_pCAL 0x0400 +#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ + +/* This is used for the transformation routines, as some of them + * change these values for the row. It also should enable using + * the routines for other purposes. + */ +typedef struct png_row_info_struct +{ + png_uint_32 width; /* width of row */ + png_uint_32 rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_byte pixel_depth; /* bits per pixel (depth * channels) */ +} png_row_info; + +typedef png_row_info FAR * png_row_infop; +typedef png_row_info FAR * FAR * png_row_infopp; + +/* These are the function types for the I/O functions and for the functions + * that allow the user to override the default I/O functions with his or her + * own. The png_error_ptr type should match that of user-supplied warning + * and error functions, while the png_rw_ptr type should match that of the + * user read/write data functions. + */ +typedef struct png_struct_def png_struct; +typedef png_struct FAR * png_structp; + +typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); +typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); +typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); +typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, + int)); +typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, + int)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, + png_uint_32, int)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, + png_row_infop, png_bytep)); +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) +typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); +#endif +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); +#endif + +/* Transform masks for the high-level interface */ +#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ +#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ +#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ +#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ +#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ +#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ +#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ +#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ +#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ +#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ +#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ +#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only, deprecated */ +/* Added to libpng-1.2.34 */ +#define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800 /* WRITE only */ +#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* WRITE only */ + +/* Flags for MNG supported features */ +#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 +#define PNG_FLAG_MNG_FILTER_64 0x04 +#define PNG_ALL_MNG_FEATURES 0x05 + +typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); +typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); + +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application, except to store + * the jmp_buf. + */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmpbuf; /* used in png_error */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ + png_error_ptr warning_fn; /* function for printing warnings */ + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + z_stream zstream; /* pointer to decompression structure (below) */ + png_bytep zbuf; /* buffer for zlib */ + png_size_t zbuf_size; /* size of zbuf */ + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_uint_32 rowbytes; /* size of row in bytes */ + png_uint_32 irowbytes; /* size of current interlaced row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row */ + png_bytep row_buf; /* buffer to save current (unfiltered) row */ +#ifndef PNG_NO_WRITE_FILTER + png_bytep sub_row; /* buffer to save "sub" row when filtering */ + png_bytep up_row; /* buffer to save "up" row when filtering */ + png_bytep avg_row; /* buffer to save "avg" row when filtering */ + png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ +#endif + png_row_info row_info; /* used for transformation routines */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + png_uint_16 num_trans; /* number of transparency values */ + png_byte chunk_name[5]; /* null-terminated name of current chunk */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ + png_byte usr_channels; /* channels at start of write */ + png_byte sig_bytes; /* magic bytes read/written from start of file */ + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +#ifdef PNG_LEGACY_SUPPORTED + png_byte filler; /* filler byte for pixel expansion */ +#else + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif +#endif + +#if defined(PNG_bKGD_SUPPORTED) + png_byte background_gamma_type; +# ifdef PNG_FLOATING_POINT_SUPPORTED + float background_gamma; +# endif + png_color_16 background; /* background color in screen gamma space */ +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif +#endif /* PNG_bKGD_SUPPORTED */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_flush_ptr output_flush_fn;/* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float gamma; /* file gamma value */ + float screen_gamma; /* screen gamma value (display_exponent) */ +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans; /* transparency values for paletted files */ + png_color_16 trans_values; /* transparency values for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +# if defined(PNG_TEXT_SUPPORTED) + png_size_t current_text_size; /* current size of text input data */ + png_size_t current_text_left; /* how much text left to read in input */ + png_charp current_text; /* current text chunk buffer */ + png_charp current_text_ptr; /* current location in current_text */ +# endif /* PNG_TEXT_SUPPORTED */ +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* for the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + png_bytep palette_lookup; /* lookup table for dithering */ + png_bytep dither_index; /* index translation for palette files */ +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) + png_uint_16p hist; /* histogram */ +#endif + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_charp time_buffer; /* String to hold RFC 1123 time text */ +#endif + +/* New members added in libpng-1.0.6 */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) + png_voidp user_chunk_ptr; + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + int num_chunk_list; + png_bytep chunk_list; +#endif + +/* New members added in libpng-1.0.3 */ +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_byte rgb_to_gray_status; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ + defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* changed from png_byte to png_uint_32 at version 1.2.0 */ +#ifdef PNG_1_0_X + png_byte mng_features_permitted; +#else + png_uint_32 mng_features_permitted; +#endif /* PNG_1_0_X */ +#endif + +/* New member added in libpng-1.0.7 */ +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_fixed_point int_gamma; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_byte filter_type; +#endif + +#if defined(PNG_1_0_X) +/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ + png_uint_32 row_buf_size; +#endif + +/* New members added in libpng-1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +# if !defined(PNG_1_0_X) +# if defined(PNG_MMX_CODE_SUPPORTED) + png_byte mmx_bitdepth_threshold; + png_uint_32 mmx_rowbytes_threshold; +# endif + png_uint_32 asm_flags; +# endif +#endif + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +/* New member added in libpng-1.0.13 and 1.2.0 */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* The following three members were added at version 1.0.14 and 1.2.4 */ + png_bytep dither_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is */ + /* in the palette */ + png_bytep palette_to_index; /* which original index points to this */ + /* palette color */ +#endif + +/* New members added in libpng-1.0.16 and 1.2.6 */ + png_byte compression_type; + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_uint_32 user_width_max; + png_uint_32 user_height_max; +#endif + +/* New member added in libpng-1.0.25 and 1.2.17 */ +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + /* storage for unknown chunk that the library doesn't recognize. */ + png_unknown_chunk unknown_chunk; +#endif + +/* New members added in libpng-1.2.26 */ + png_uint_32 old_big_row_buf_size, old_prev_row_size; + +/* New member added in libpng-1.2.30 */ + png_charp chunkdata; /* buffer for reading chunk data */ + +}; + + +/* This triggers a compiler error in png.c, if png.c and png.h + * do not agree upon the version number. + */ +typedef png_structp version_1_2_37; + +typedef png_struct FAR * FAR * png_structpp; + +/* Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng.txt for the + * full explanation, see example.c for the summary. This just provides + * a simple one line description of the use of each function. + */ + +/* Returns the version number of the library */ +extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); + +/* Tell lib we have already handled the first magic bytes. + * Handling more than 8 bytes from the beginning of the file is an error. + */ +extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, + int num_bytes)); + +/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a + * PNG file. Returns zero if the supplied bytes match the 8-byte PNG + * signature, and non-zero otherwise. Having num_to_check == 0 or + * start > 7 will always fail (ie return non-zero). + */ +extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, + png_size_t num_to_check)); + +/* Simple signature checking function. This is the same as calling + * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). + */ +extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); + +/* Allocate and initialize png_ptr struct for reading, and any other memory. */ +extern PNG_EXPORT(png_structp,png_create_read_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +/* Allocate and initialize png_ptr struct for writing, and any other memory */ +extern PNG_EXPORT(png_structp,png_create_write_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +#ifdef PNG_WRITE_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_WRITE_SUPPORTED +extern PNG_EXPORT(void,png_set_compression_buffer_size) + PNGARG((png_structp png_ptr, png_uint_32 size)); +#endif + +/* Reset the compression stream */ +extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); + +/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_structp,png_create_read_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +extern PNG_EXPORT(png_structp,png_create_write_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +#endif + +/* Write a PNG chunk - size, type, (optional) data, CRC. */ +extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_bytep data, png_size_t length)); + +/* Write the start of a PNG chunk - length and chunk name. */ +extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_uint_32 length)); + +/* Write the data of a PNG chunk started with png_write_chunk_start(). */ +extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ +extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); + +/* Allocate and initialize the info structure */ +extern PNG_EXPORT(png_infop,png_create_info_struct) + PNGARG((png_structp png_ptr)); + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize the info structure (old interface - DEPRECATED) */ +extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); +#undef png_info_init +#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ + png_sizeof(png_info)); +#endif + +extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, + png_size_t png_info_struct_size)); + +/* Writes all the PNG information before the image. */ +extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the information before the actual image data. */ +extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) + PNGARG((png_structp png_ptr, png_timep ptime)); +#endif + +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ +#if defined(PNG_WRITE_tIME_SUPPORTED) +/* convert from a struct tm to png_time */ +extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, + struct tm FAR * ttime)); + +/* convert from time_t to png_time. Uses gmtime() */ +extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, + time_t ttime)); +#endif /* PNG_WRITE_tIME_SUPPORTED */ +#endif /* _WIN32_WCE */ + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ +extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); +#if !defined(PNG_1_0_X) +extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp + png_ptr)); +#endif +extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated */ +extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); +#endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Use blue, green, red order for pixels. */ +extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* Expand the grayscale to 24-bit RGB if necessary. */ +extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* Reduce RGB to grayscale. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, + int error_action, double red, double green )); +#endif +extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green )); +extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp + png_ptr)); +#endif + +extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, + png_colorp palette)); + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ +extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +/* The values of the PNG_FILLER_ defines should NOT be changed */ +#define PNG_FILLER_BEFORE 0 +#define PNG_FILLER_AFTER 1 +/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ +#if !defined(PNG_1_0_X) +extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +#endif +#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swap bytes in 16-bit depth files. */ +extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ +extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Swap packing order of pixels in bytes. */ +extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Converts files to legal bit depths. */ +extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, + png_color_8p true_bits)); +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Have the code handle the interlacing. Returns the number of passes. */ +extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +/* Invert monochrome files */ +extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Handle alpha and tRNS by replacing with a background color. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)); +#endif +#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +#define PNG_BACKGROUND_GAMMA_SCREEN 1 +#define PNG_BACKGROUND_GAMMA_FILE 2 +#define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip the second byte of information from a 16-bit depth file. */ +extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Turn on dithering, and reduce the palette to the number of colors available. */ +extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_uint_16p histogram, int full_dither)); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Handle gamma correction. Screen_gamma=(display_exponent) */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, + double screen_gamma, double default_file_gamma)); +#endif +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ +/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ +extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, + int empty_plte_permitted)); +#endif +#endif + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +/* Set how many lines between output flushes - 0 for no flushing */ +extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); +/* Flush the current PNG output buffer */ +extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); +#endif + +/* optional update palette with requested transformations */ +extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); + +/* optional call to update the users info structure */ +extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read one or more rows of image data. */ +extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); +#endif + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read a row of data. */ +extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, + png_bytep row, + png_bytep display_row)); +#endif + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the whole image into memory at once. */ +extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, + png_bytepp image)); +#endif + +/* write a row of image data */ +extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, + png_bytep row)); + +/* write a few rows of image data */ +extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_uint_32 num_rows)); + +/* write the image data */ +extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* writes the end of the PNG file. */ +extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED +/* read the end of the PNG file. */ +extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +/* free any memory associated with the png_info_struct */ +extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, + png_infopp info_ptr_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp + png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); + +/* free all memory used by the read (old method - NOT DLL EXPORTED) */ +/* Debian note: exporting as it is required by legacy applications */ +extern PNG_EXPORT(void,png_read_destroy) PNGARG((png_structp png_ptr, png_infop info_ptr, + png_infop end_info_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_write_struct) + PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); + +/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ +/* Debian note: exporting as it is required by legacy applications */ +extern PNG_EXPORT(void,png_write_destroy) PNGARG((png_structp png_ptr)); + +/* set the libpng method of handling chunk CRC errors */ +extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, + int crit_action, int ancil_action)); + +/* Values for png_set_crc_action() to say how to handle CRC errors in + * ancillary and critical chunks, and whether to use the data contained + * therein. Note that it is impossible to "discard" data in a critical + * chunk. For versions prior to 0.90, the action was always error/quit, + * whereas in version 0.90 and later, the action for CRC errors in ancillary + * chunks is warn/discard. These values should NOT be changed. + * + * value action:critical action:ancillary + */ +#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ +#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ +#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ +#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ +#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ +#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ + +/* These functions give the user control over the scan-line filtering in + * libpng and the compression methods used by zlib. These functions are + * mainly useful for testing, as the defaults should work with most users. + * Those users who are tight on memory or want faster performance at the + * expense of compression can modify them. See the compression library + * header file (zlib.h) for an explination of the compression functions. + */ + +/* set the filtering method(s) used by libpng. Currently, the only valid + * value for "method" is 0. + */ +extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, + int filters)); + +/* Flags for png_set_filter() to say which filters to use. The flags + * are chosen so that they don't conflict with real filter types + * below, in case they are supplied instead of the #defined constants. + * These values should NOT be changed. + */ +#define PNG_NO_FILTERS 0x00 +#define PNG_FILTER_NONE 0x08 +#define PNG_FILTER_SUB 0x10 +#define PNG_FILTER_UP 0x20 +#define PNG_FILTER_AVG 0x40 +#define PNG_FILTER_PAETH 0x80 +#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ + PNG_FILTER_AVG | PNG_FILTER_PAETH) + +/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. + * These defines should NOT be changed. + */ +#define PNG_FILTER_VALUE_NONE 0 +#define PNG_FILTER_VALUE_SUB 1 +#define PNG_FILTER_VALUE_UP 2 +#define PNG_FILTER_VALUE_AVG 3 +#define PNG_FILTER_VALUE_PAETH 4 +#define PNG_FILTER_VALUE_LAST 5 + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ +/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ + * defines, either the default (minimum-sum-of-absolute-differences), or + * the experimental method (weighted-minimum-sum-of-absolute-differences). + * + * Weights are factors >= 1.0, indicating how important it is to keep the + * filter type consistent between rows. Larger numbers mean the current + * filter is that many times as likely to be the same as the "num_weights" + * previous filters. This is cumulative for each previous row with a weight. + * There needs to be "num_weights" values in "filter_weights", or it can be + * NULL if the weights aren't being specified. Weights have no influence on + * the selection of the first row filter. Well chosen weights can (in theory) + * improve the compression for a given image. + * + * Costs are factors >= 1.0 indicating the relative decoding costs of a + * filter type. Higher costs indicate more decoding expense, and are + * therefore less likely to be selected over a filter with lower computational + * costs. There needs to be a value in "filter_costs" for each valid filter + * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't + * setting the costs. Costs try to improve the speed of decompression without + * unduly increasing the compressed image size. + * + * A negative weight or cost indicates the default value is to be used, and + * values in the range [0.0, 1.0) indicate the value is to remain unchanged. + * The default values for both weights and costs are currently 1.0, but may + * change if good general weighting/cost heuristics can be found. If both + * the weights and costs are set to 1.0, this degenerates the WEIGHTED method + * to the UNWEIGHTED method, but with added encoding time/computation. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, + int heuristic_method, int num_weights, png_doublep filter_weights, + png_doublep filter_costs)); +#endif +#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ + +/* Heuristic used for row filter selection. These defines should NOT be + * changed. + */ +#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ +#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ +#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ +#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ + +/* Set the library compression level. Currently, valid values range from + * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 + * (0 - no compression, 9 - "maximal" compression). Note that tests have + * shown that zlib compression levels 3-6 usually perform as well as level 9 + * for PNG images, and do considerably fewer caclulations. In the future, + * these values may not correspond directly to the zlib compression levels. + */ +extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, + int level)); + +extern PNG_EXPORT(void,png_set_compression_mem_level) + PNGARG((png_structp png_ptr, int mem_level)); + +extern PNG_EXPORT(void,png_set_compression_strategy) + PNGARG((png_structp png_ptr, int strategy)); + +extern PNG_EXPORT(void,png_set_compression_window_bits) + PNGARG((png_structp png_ptr, int window_bits)); + +extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, + int method)); + +/* These next functions are called for input/output, memory, and error + * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, + * and call standard C I/O routines such as fread(), fwrite(), and + * fprintf(). These functions can be made to use other I/O routines + * at run time for those applications that need to handle I/O in a + * different manner by calling png_set_???_fn(). See libpng.txt for + * more information. + */ + +#if !defined(PNG_NO_STDIO) +/* Initialize the input/output for the PNG file to the default functions. */ +extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); +#endif + +/* Replace the (error and abort), and warning functions with user + * supplied functions. If no messages are to be printed you must still + * write and use replacement functions. The replacement error_fn should + * still do a longjmp to the last setjmp location if you are using this + * method of error handling. If error_fn or warning_fn is NULL, the + * default function will be used. + */ + +extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); + +/* Return the user pointer associated with the error functions */ +extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); + +/* Replace the default data output functions with a user supplied one(s). + * If buffered output is not used, then output_flush_fn can be set to NULL. + * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time + * output_flush_fn will be ignored (and thus can be NULL). + * It is probably a mistake to use NULL for output_flush_fn if + * write_data_fn is not also NULL unless you have built libpng with + * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's + * default flush function, which uses the standard *FILE structure, will + * be used. + */ +extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); + +/* Replace the default data input function with a user supplied one. */ +extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr read_data_fn)); + +/* Return the user pointer associated with the I/O functions */ +extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, + png_read_status_ptr read_row_fn)); + +extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_USER_MEM_SUPPORTED +/* Replace the default memory allocation functions with user supplied one(s). */ +extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +/* Return the user pointer associated with the memory functions */ +extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr read_user_transform_fn)); +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr write_user_transform_fn)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp + png_ptr, png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); +/* Return the user pointer associated with the user transform functions */ +extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp + png_ptr)); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +/* Sets the function callbacks for the push reader, and a pointer to a + * user-defined structure available to the callback functions. + */ +extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, + png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn)); + +/* returns the user pointer associated with the push read functions */ +extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) + PNGARG((png_structp png_ptr)); + +/* function to be called when data becomes available */ +extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); + +/* function that combines rows. Not very much different than the + * png_combine_row() call. Is this even used????? + */ +extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, + png_bytep old_row, png_bytep new_row)); +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, + png_uint_32 size)); + +#if defined(PNG_1_0_X) +# define png_malloc_warn png_malloc +#else +/* Added at libpng version 1.2.4 */ +extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, + png_uint_32 size)); +#endif + +/* frees a pointer allocated by png_malloc() */ +extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); + +#if defined(PNG_1_0_X) +/* Function to allocate memory for zlib. */ +extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, + uInt size)); + +/* Function to free memory for zlib */ +extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); +#endif + +/* Free data that was allocated internally */ +extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 free_me, int num)); +#ifdef PNG_FREE_ME_SUPPORTED +/* Reassign responsibility for freeing existing data, whether allocated + * by libpng or by the application */ +extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, + png_infop info_ptr, int freer, png_uint_32 mask)); +#endif +/* assignments for png_data_freer */ +#define PNG_DESTROY_WILL_FREE_DATA 1 +#define PNG_SET_WILL_FREE_DATA 1 +#define PNG_USER_WILL_FREE_DATA 2 +/* Flags for png_ptr->free_me and info_ptr->free_me */ +#define PNG_FREE_HIST 0x0008 +#define PNG_FREE_ICCP 0x0010 +#define PNG_FREE_SPLT 0x0020 +#define PNG_FREE_ROWS 0x0040 +#define PNG_FREE_PCAL 0x0080 +#define PNG_FREE_SCAL 0x0100 +#define PNG_FREE_UNKN 0x0200 +#define PNG_FREE_LIST 0x0400 +#define PNG_FREE_PLTE 0x1000 +#define PNG_FREE_TRNS 0x2000 +#define PNG_FREE_TEXT 0x4000 +#define PNG_FREE_ALL 0x7fff +#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ + +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, + png_uint_32 size)); +extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, + png_voidp ptr)); +#endif + +extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, + png_voidp s1, png_voidp s2, png_uint_32 size)); + +extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, + png_voidp s1, int value, png_uint_32 size)); + +#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ +extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, + int check)); +#endif /* USE_FAR_KEYWORD */ + +#ifndef PNG_NO_ERROR_TEXT +/* Fatal error in PNG image of libpng - can't continue */ +extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); + +/* The same, but the chunk name is prepended to the error string. */ +extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); +#else +/* Fatal error in PNG image of libpng - can't continue */ +extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)); +#endif + +#ifndef PNG_NO_WARNINGS +/* Non-fatal error in libpng. Can continue, but may have a problem. */ +extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +#ifdef PNG_READ_SUPPORTED +/* Non-fatal error in libpng, chunk name is prepended to message. */ +extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); +#endif /* PNG_READ_SUPPORTED */ +#endif /* PNG_NO_WARNINGS */ + +/* The png_set_ functions are for storing values in the png_info_struct. + * Similarly, the png_get_ calls are used to read values from the + * png_info_struct, either storing the parameters in the passed variables, or + * setting pointers into the png_info_struct where the data is stored. The + * png_get_ functions return a non-zero value if the data was available + * in info_ptr, or return zero and do not change any of the parameters if the + * data was not available. + * + * These functions should be used instead of directly accessing png_info + * to avoid problems with future changes in the size and internal layout of + * png_info_struct. + */ +/* Returns "flag" if chunk data is valid in info_ptr. */ +extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 flag)); + +/* Returns number of bytes needed to hold a transformed row. */ +extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* Returns row_pointers, which is an array of pointers to scanlines that was +returned from png_read_png(). */ +extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, +png_infop info_ptr)); +/* Set row_pointers, which is an array of pointers to scanlines for use +by png_write_png(). */ +extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers)); +#endif + +/* Returns number of color channels in image. */ +extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Returns image width in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image height in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image bit_depth. */ +extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image color_type. */ +extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image filter_type. */ +extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image interlace_type. */ +extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image compression_type. */ +extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image resolution in pixels per meter, from pHYs chunk data. */ +extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns pixel aspect ratio, computed from pHYs chunk data. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +#endif + +/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ +extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +/* Returns pointer to signature string read from PNG header */ +extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p *background)); +#endif + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p background)); +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point + *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point + *int_blue_x, png_fixed_point *int_blue_y)); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double white_x, double white_y, double red_x, + double red_y, double green_x, double green_y, double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *file_gamma)); +#endif +extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_file_gamma)); +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double file_gamma)); +#endif +extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p *hist)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p hist)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); + +extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, + int *unit_type)); +#endif + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, + int *type, int *nparams, png_charp *units, png_charpp *params)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_charp units, png_charpp params)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp *palette, int *num_palette)); + +extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp palette, int num_palette)); + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p *sig_bit)); +#endif + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p sig_bit)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *intent)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen)); + /* Note to maintainer: profile should be png_bytepp */ +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tpp entries)); +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) +/* png_get_text also returns the number of text chunks in *num_text */ +extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp *text_ptr, int *num_text)); +#endif + +/* + * Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + +#if defined(PNG_TEXT_SUPPORTED) +extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep *mod_time)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep mod_time)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep *trans, int *num_trans, + png_color_16p *trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep trans, int num_trans, + png_color_16p trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +#endif + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, double *width, double *height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED */ + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* provide a list of chunks and how they are to be handled, if the built-in + handling or default unknown chunk handling is not desired. Any chunks not + listed will be handled in the default manner. The IHDR and IEND chunks + must not be listed. + keep = 0: follow default behaviour + = 1: do not keep + = 2: keep only if safe-to-copy + = 3: keep even if unsafe-to-copy +*/ +extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp + png_ptr, int keep, png_bytep chunk_list, int num_chunks)); +extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); +extern PNG_EXPORT(void, png_set_unknown_chunk_location) + PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); +extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp + png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); +#endif +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep + chunk_name)); +#endif + +/* Png_free_data() will turn off the "valid" flag for anything it frees. + If you need to turn it off for a chunk that your application has freed, + you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ +extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, + png_infop info_ptr, int mask)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* The "params" pointer is currently not used and is for future expansion. */ +extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +#endif + +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + */ +#ifdef PNG_DEBUG +#if (PNG_DEBUG > 0) +#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +#include +#if (PNG_DEBUG > 1) +#ifndef _DEBUG +# define _DEBUG +#endif +#ifndef png_debug +#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) +#endif +#ifndef png_debug1 +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) +#endif +#ifndef png_debug2 +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) +#endif +#endif +#else /* PNG_DEBUG_FILE || !_MSC_VER */ +#ifndef PNG_DEBUG_FILE +#define PNG_DEBUG_FILE stderr +#endif /* PNG_DEBUG_FILE */ + +#if (PNG_DEBUG > 1) +/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on + * non-ISO compilers */ +# ifdef __STDC__ +# ifndef png_debug +# define png_debug(l,m) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ + } +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ + } +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ + } +# endif +# else /* __STDC __ */ +# ifndef png_debug +# define png_debug(l,m) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format); \ + } +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1); \ + } +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1,p2); \ + } +# endif +# endif /* __STDC __ */ +#endif /* (PNG_DEBUG > 1) */ + +#endif /* _MSC_VER */ +#endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +#define png_debug(l, m) +#endif +#ifndef png_debug1 +#define png_debug1(l, m, p1) +#endif +#ifndef png_debug2 +#define png_debug2(l, m, p1, p2) +#endif + +extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); + +#ifdef PNG_MNG_FEATURES_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp + png_ptr, png_uint_32 mng_features_permitted)); +#endif + +/* For use in png_set_keep_unknown, added to version 1.2.6 */ +#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 +#define PNG_HANDLE_CHUNK_NEVER 1 +#define PNG_HANDLE_CHUNK_IF_SAFE 2 +#define PNG_HANDLE_CHUNK_ALWAYS 3 + +/* Added to version 1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if defined(PNG_MMX_CODE_SUPPORTED) +#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 +#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 +#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 +#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 +#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 +#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 +#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ + +#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) +#define PNG_MMX_WRITE_FLAGS ( 0 ) + +#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ + | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ + | PNG_MMX_READ_FLAGS \ + | PNG_MMX_WRITE_FLAGS ) + +#define PNG_SELECT_READ 1 +#define PNG_SELECT_WRITE 2 +#endif /* PNG_MMX_CODE_SUPPORTED */ + +#if !defined(PNG_1_0_X) +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) + PNGARG((int flag_select, int *compilerID)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) + PNGARG((int flag_select)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flags) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) + PNGARG((png_structp png_ptr)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_asm_flags) + PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_mmx_thresholds) + PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold)); + +#endif /* PNG_1_0_X */ + +#if !defined(PNG_1_0_X) +/* png.c, pnggccrd.c, or pngvcrd.c */ +extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); +#endif /* PNG_1_0_X */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + +/* Strip the prepended error numbers ("#nnn ") from error and warning + * messages before passing them to the error or warning handler. */ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp + png_ptr, png_uint_32 strip_mode)); +#endif + +/* Added at libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp + png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); +extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp + png_ptr)); +extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp + png_ptr)); +#endif + + +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ + +#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +/* With these routines we avoid an integer divide, which will be slower on + * most machines. However, it does take more operations than the corresponding + * divide method, so it may be slower on a few RISC systems. There are two + * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. + * + * Note that the rounding factors are NOT supposed to be the same! 128 and + * 32768 are correct for the NODIV code; 127 and 32767 are correct for the + * standard method. + * + * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] + */ + + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 - \ + (png_uint_16)(alpha)) + (png_uint_16)128); \ + (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } + +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(png_uint_32)(65535L - \ + (png_uint_32)(alpha)) + (png_uint_32)32768L); \ + (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } + +#else /* standard method using integer division */ + +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + (png_uint_16)127) / 255) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ + (png_uint_32)32767) / (png_uint_32)65535L) + +#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ + +/* Inline macros to do direct reads of bytes from the input buffer. These + * require that you are using an architecture that uses PNG byte ordering + * (MSB first) and supports unaligned data storage. I think that PowerPC + * in big-endian mode and 680x0 are the only ones that will support this. + * The x86 line of processors definitely do not. The png_get_int_32() + * routine also assumes we are using two's complement format for negative + * values, which is almost certainly true. + */ +#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) +# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) +# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) +# define png_get_int_32(buf) ( *((png_int_32p) (buf))) +#else +extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); +extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); +extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); +#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ +extern PNG_EXPORT(png_uint_32,png_get_uint_31) + PNGARG((png_structp png_ptr, png_bytep buf)); +/* No png_get_int_16 -- may be added if there's a real need for it. */ + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). + */ +extern PNG_EXPORT(void,png_save_uint_32) + PNGARG((png_bytep buf, png_uint_32 i)); +extern PNG_EXPORT(void,png_save_int_32) + PNGARG((png_bytep buf, png_int_32 i)); + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +extern PNG_EXPORT(void,png_save_uint_16) + PNGARG((png_bytep buf, unsigned int i)); +/* No png_save_int_16 -- may be added if there's a real need for it. */ + +/* ************************************************************************* */ + +/* These next functions are used internally in the code. They generally + * shouldn't be used unless you are writing code to add or replace some + * functionality in libpng. More information about most functions can + * be found in the files where the functions are located. + */ + + +/* Various modes of operation, that are visible to applications because + * they are used for unknown chunk location. + */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_HAVE_IDAT 0x04 +#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ +#define PNG_HAVE_IEND 0x10 + +#if defined(PNG_INTERNAL) + +/* More modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. + */ +#define PNG_HAVE_gAMA 0x20 +#define PNG_HAVE_cHRM 0x40 +#define PNG_HAVE_sRGB 0x80 +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ + +/* flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_DITHER 0x0040 +#define PNG_BACKGROUND 0x0080 +#define PNG_BACKGROUND_EXPAND 0x0100 + /* 0x0200 unused */ +#define PNG_16_TO_8 0x0400 +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000L +#define PNG_PACKSWAP 0x10000L +#define PNG_SWAP_ALPHA 0x20000L +#define PNG_STRIP_ALPHA 0x40000L +#define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L +#define PNG_RGB_TO_GRAY_ERR 0x200000L +#define PNG_RGB_TO_GRAY_WARN 0x400000L +#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ + /* 0x800000L Unused */ +#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ +#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ + /* 0x4000000L unused */ + /* 0x8000000L unused */ + /* 0x10000000L unused */ + /* 0x20000000L unused */ + /* 0x40000000L unused */ + +/* flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_SHIFT 8 +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_SHIFT 3 +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 +#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 +#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 +#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 +#define PNG_FLAG_ZLIB_FINISHED 0x0020 +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_FREE_PLTE 0x1000 +#define PNG_FLAG_FREE_TRNS 0x2000 +#define PNG_FLAG_FREE_HIST 0x4000 +#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L +#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L +#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L +#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ +#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ + /* 0x800000L unused */ + /* 0x1000000L unused */ + /* 0x2000000L unused */ + /* 0x4000000L unused */ + /* 0x8000000L unused */ + /* 0x10000000L unused */ + /* 0x20000000L unused */ + /* 0x40000000L unused */ + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* save typing and make code easier to understand */ + +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* Added to libpng-1.2.6 JB */ +#define PNG_ROWBYTES(pixel_bits, width) \ + ((pixel_bits) >= 8 ? \ + ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ + (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) + +/* PNG_OUT_OF_RANGE returns true if value is outside the range + ideal-delta..ideal+delta. Each argument is evaluated twice. + "ideal" and "delta" should be constants, normally simple + integers, "value" a variable. Added to libpng-1.2.6 JB */ +#define PNG_OUT_OF_RANGE(value, ideal, delta) \ + ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* place to hold the signature string for a PNG file. */ +#ifdef PNG_USE_GLOBAL_ARRAYS + PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8]; +#else +#endif +#endif /* PNG_NO_EXTERN */ + +/* Constant strings for known chunk types. If you need to add a chunk, + * define the name here, and add an invocation of the macro in png.c and + * wherever it's needed. + */ +#define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} +#define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} +#define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} +#define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} +#define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} +#define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} +#define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} +#define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} +#define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} +#define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} +#define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} +#define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} +#define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} +#define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} +#define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} +#define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} +#define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} +#define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} +#define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} +#define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} + +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5]; +PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5]; +#endif /* PNG_USE_GLOBAL_ARRAYS */ + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize png_ptr struct for reading, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_read_struct instead). + */ +extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); +#undef png_read_init +#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); +#endif + +extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Initialize png_ptr struct for writing, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_write_struct instead). + */ +extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); +#undef png_write_init +#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); +#endif + +extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Allocate memory for an internal libpng struct */ +PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); + +/* Free memory from internal libpng struct */ +PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); + +PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr + malloc_fn, png_voidp mem_ptr)); +PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, + png_free_ptr free_fn, png_voidp mem_ptr)); + +/* Free any memory that info_ptr points to and reset struct. */ +PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_1_0_X +/* Function to allocate memory for zlib. */ +PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); + +/* Function to free memory for zlib */ +PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); + +#ifdef PNG_SIZE_T +/* Function to convert a sizeof an item to png_sizeof item */ + PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); +#endif + +/* Next four functions are used internally as callbacks. PNGAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ + +PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif + +PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if !defined(PNG_NO_STDIO) +PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); +#endif +#endif +#else /* PNG_1_0_X */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif +#endif /* PNG_1_0_X */ + +/* Reset the CRC variable */ +PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); + +/* Write the "data" buffer to whatever output you are using. */ +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, + png_size_t length)); + +/* Decompress data in a chunk that uses compression */ +#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_size_t chunklength, + png_size_t prefix_length, png_size_t *data_length)); +#endif + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, + png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +#endif + +/* simple function to write the signature */ +PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); + +/* write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, + png_uint_32 height, + int bit_depth, int color_type, int compression_method, int filter_method, + int interlace_method)); + +PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, + png_uint_32 num_pal)); + +PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point + file_gamma)); +#endif +#endif + +#if defined(PNG_WRITE_sBIT_SUPPORTED) +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, + int color_type)); +#endif + +#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, + double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_WRITE_sRGB_SUPPORTED) +PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, + int intent)); +#endif + +#if defined(PNG_WRITE_iCCP_SUPPORTED) +PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, + png_charp name, int compression_type, + png_charp profile, int proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, + png_sPLT_tp palette)); +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, + png_color_16p values, int number, int color_type)); +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, + png_color_16p values, int color_type)); +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, + int num_hist)); +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, + png_charp key, png_charpp new_key)); +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len)); +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len, int compression)); +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, + int compression, png_charp key, png_charp lang, png_charp lang_key, + png_charp text)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ +PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type)); +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, + png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params)); +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type)); +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, + png_timep mod_time)); +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, + int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, + int unit, png_charp width, png_charp height)); +#endif +#endif +#endif + +/* Called when finished processing a row of data */ +PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); + +/* Internal use only. Called before first row of data */ +PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#endif + +/* combine a row of data, dealing with alpha, etc. if requested */ +PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, + int mask)); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +/* expand an interlaced row */ +/* OLD pre-1.0.9 interface: +PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations)); + */ +PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* grab pixels out of a row for an interlaced pass */ +PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass)); +#endif + +/* unfilter a row */ +PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); + +/* Choose the best filter to use and filter the row data */ +PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, + png_row_infop row_info)); + +/* Write out the filtered row. */ +PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, + png_bytep filtered_row)); +/* finish a row while reading, dealing with interlacing passes, etc. */ +PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); + +/* initialize the row buffers, etc. */ +PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); +/* optional call to update the users info structure */ +PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* these are the functions that do the transformations */ +#if defined(PNG_READ_FILLER_SUPPORTED) +PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop + row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p sig_bits)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, + png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); + +# if defined(PNG_CORRECT_PALETTE_SUPPORTED) +PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette)); +# endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) +PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth)); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p bit_depth)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background, + png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift)); +#else +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background)); +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift)); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, + png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); +PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, + png_bytep row, png_color_16p trans_value)); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* decode the IHDR chunk */ +PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); + +#if defined(PNG_READ_bKGD_SUPPORTED) +PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_gAMA_SUPPORTED) +PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_iCCP_SUPPORTED) +extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sPLT_SUPPORTED) +extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_sRGB_SUPPORTED) +PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tRNS_SUPPORTED) +PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); + +PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, + png_bytep chunk_name)); + +/* handle the transformations for reading and writing */ +PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); + +PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, + png_uint_32 length)); +PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); +PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#if defined(PNG_MMX_CODE_SUPPORTED) +/* png.c */ /* PRIVATE */ +PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); +#endif +#endif + +#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_pHYs_SUPPORTED) +PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ + +/* Read the chunk header (length + type name) */ +PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); + +/* Added at libpng version 1.2.34 */ +#if defined(PNG_cHRM_SUPPORTED) +PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif + +/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#endif /* PNG_INTERNAL */ + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +/* do not put anything past this line */ +#endif /* PNG_H */ diff --git a/lib/libpng/include/pngconf.h b/lib/libpng/include/pngconf.h new file mode 100644 index 0000000..025368d --- /dev/null +++ b/lib/libpng/include/pngconf.h @@ -0,0 +1,1496 @@ + +/* pngconf.h - machine configurable file for libpng + * + * libpng version 1.2.37 - June 4, 2009 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2009 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* Any machine specific code is near the front of this file, so if you + * are configuring libpng for a machine, you may want to read the section + * starting here down to where it starts to typedef png_color, png_text, + * and png_info. + */ + +#ifndef PNGCONF_H +#define PNGCONF_H + +#define PNG_1_2_X + +/* + * PNG_USER_CONFIG has to be defined on the compiler command line. This + * includes the resource compiler for Windows DLL configurations. + */ +#ifdef PNG_USER_CONFIG +# ifndef PNG_USER_PRIVATEBUILD +# define PNG_USER_PRIVATEBUILD +# endif +#include "pngusr.h" +#endif + +/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ +#ifdef PNG_CONFIGURE_LIBPNG +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#endif + +/* + * Added at libpng-1.2.8 + * + * If you create a private DLL you need to define in "pngusr.h" the followings: + * #define PNG_USER_PRIVATEBUILD + * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." + * #define PNG_USER_DLLFNAME_POSTFIX + * e.g. // private DLL "libpng13gx.dll" + * #define PNG_USER_DLLFNAME_POSTFIX "gx" + * + * The following macros are also at your disposal if you want to complete the + * DLL VERSIONINFO structure. + * - PNG_USER_VERSIONINFO_COMMENTS + * - PNG_USER_VERSIONINFO_COMPANYNAME + * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS + */ + +#ifdef __STDC__ +#ifdef SPECIALBUILD +# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ + are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") +#endif + +#ifdef PRIVATEBUILD +# pragma message("PRIVATEBUILD is deprecated.\ + Use PNG_USER_PRIVATEBUILD instead.") +# define PNG_USER_PRIVATEBUILD PRIVATEBUILD +#endif +#endif /* __STDC__ */ + +#ifndef PNG_VERSION_INFO_ONLY + +/* End of material added to libpng-1.2.8 */ + +/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble + Restored at libpng-1.2.21 */ +#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \ + !defined(PNG_WARN_UNINITIALIZED_ROW) +# define PNG_WARN_UNINITIALIZED_ROW 1 +#endif +/* End of material added at libpng-1.2.19/1.2.21 */ + +/* This is the size of the compression buffer, and thus the size of + * an IDAT chunk. Make this whatever size you feel is best for your + * machine. One of these will be allocated per png_struct. When this + * is full, it writes the data to the disk, and does some other + * calculations. Making this an extremely small size will slow + * the library down, but you may want to experiment to determine + * where it becomes significant, if you are concerned with memory + * usage. Note that zlib allocates at least 32Kb also. For readers, + * this describes the size of the buffer available to read the data in. + * Unless this gets smaller than the size of a row (compressed), + * it should not make much difference how big this is. + */ + +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif + +/* Enable if you want a write-only libpng */ + +#ifndef PNG_NO_READ_SUPPORTED +# define PNG_READ_SUPPORTED +#endif + +/* Enable if you want a read-only libpng */ + +#ifndef PNG_NO_WRITE_SUPPORTED +# define PNG_WRITE_SUPPORTED +#endif + +/* Enabled by default in 1.2.0. You can disable this if you don't need to + support PNGs that are embedded in MNG datastreams */ +#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) +# ifndef PNG_MNG_FEATURES_SUPPORTED +# define PNG_MNG_FEATURES_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_FLOATING_POINT_SUPPORTED +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FLOATING_POINT_SUPPORTED +# endif +#endif + +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. +#define PNG_MAX_MALLOC_64K + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +/* Special munging to support doing things the 'cygwin' way: + * 'Normal' png-on-win32 defines/defaults: + * PNG_BUILD_DLL -- building dll + * PNG_USE_DLL -- building an application, linking to dll + * (no define) -- building static library, or building an + * application and linking to the static lib + * 'Cygwin' defines/defaults: + * PNG_BUILD_DLL -- (ignored) building the dll + * (no define) -- (ignored) building an application, linking to the dll + * PNG_STATIC -- (ignored) building the static lib, or building an + * application that links to the static lib. + * ALL_STATIC -- (ignored) building various static libs, or building an + * application that links to the static libs. + * Thus, + * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and + * this bit of #ifdefs will define the 'correct' config variables based on + * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but + * unnecessary. + * + * Also, the precedence order is: + * ALL_STATIC (since we can't #undef something outside our namespace) + * PNG_BUILD_DLL + * PNG_STATIC + * (nothing) == PNG_USE_DLL + * + * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent + * of auto-import in binutils, we no longer need to worry about + * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, + * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes + * to __declspec() stuff. However, we DO need to worry about + * PNG_BUILD_DLL and PNG_STATIC because those change some defaults + * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. + */ +#if defined(__CYGWIN__) +# if defined(ALL_STATIC) +# if defined(PNG_BUILD_DLL) +# undef PNG_BUILD_DLL +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# if !defined(PNG_STATIC) +# define PNG_STATIC +# endif +# else +# if defined (PNG_BUILD_DLL) +# if defined(PNG_STATIC) +# undef PNG_STATIC +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# else +# if defined(PNG_STATIC) +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# else +# if !defined(PNG_USE_DLL) +# define PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# endif +# endif +# endif +#endif + +/* This protects us against compilers that run on a windowing system + * and thus don't have or would rather us not use the stdio types: + * stdin, stdout, and stderr. The only one currently used is stderr + * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will + * prevent these from being compiled and used. #defining PNG_NO_STDIO + * will also prevent these, plus will prevent the entire set of stdio + * macros and functions (FILE *, printf, etc.) from being compiled and used, + * unless (PNG_DEBUG > 0) has been #defined. + * + * #define PNG_NO_CONSOLE_IO + * #define PNG_NO_STDIO + */ + +#if defined(_WIN32_WCE) +# include + /* Console I/O functions are not supported on WindowsCE */ +# define PNG_NO_CONSOLE_IO + /* abort() may not be supported on some/all Windows CE platforms */ +# define PNG_ABORT() exit(-1) +# ifdef PNG_DEBUG +# undef PNG_DEBUG +# endif +#endif + +#ifdef PNG_BUILD_DLL +# ifndef PNG_CONSOLE_IO_SUPPORTED +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# endif +#endif + +# ifdef PNG_NO_STDIO +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# include +# endif +# endif +# else +# if !defined(_WIN32_WCE) +/* "stdio.h" functions are not supported on WindowsCE */ +# include +# endif +# endif + +/* This macro protects us against machines that don't have function + * prototypes (ie K&R style headers). If your compiler does not handle + * function prototypes, define this macro and use the included ansi2knr. + * I've always been able to use _NO_PROTO as the indicator, but you may + * need to drag the empty declaration out in front of here, or change the + * ifdef to suit your own needs. + */ +#ifndef PNGARG + +#ifdef OF /* zlib prototype munger */ +# define PNGARG(arglist) OF(arglist) +#else + +#ifdef _NO_PROTO +# define PNGARG(arglist) () +# ifndef PNG_TYPECAST_NULL +# define PNG_TYPECAST_NULL +# endif +#else +# define PNGARG(arglist) arglist +#endif /* _NO_PROTO */ + + +#endif /* OF */ + +#endif /* PNGARG */ + +/* Try to determine if we are compiling on a Mac. Note that testing for + * just __MWERKS__ is not good enough, because the Codewarrior is now used + * on non-Mac platforms. + */ +#ifndef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) +# define MACOS +# endif +#endif + +/* enough people need this for various reasons to include it here */ +#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) +# include +#endif + +#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) +# define PNG_SETJMP_SUPPORTED +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This is an attempt to force a single setjmp behaviour on Linux. If + * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + * + * You can bypass this test if you know that your application uses exactly + * the same setjmp.h that was included when libpng was built. Only define + * PNG_SKIP_SETJMP_CHECK while building your application, prior to the + * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK + * while building a separate libpng library for general use. + */ + +# ifndef PNG_SKIP_SETJMP_CHECK +# ifdef __linux__ +# ifdef _BSD_SOURCE +# define PNG_SAVE_BSD_SOURCE +# undef _BSD_SOURCE +# endif +# ifdef _SETJMP_H + /* If you encounter a compiler error here, see the explanation + * near the end of INSTALL. + */ + __pngconf.h__ in libpng already includes setjmp.h; + __dont__ include it again.; +# endif +# endif /* __linux__ */ +# endif /* PNG_SKIP_SETJMP_CHECK */ + + /* include setjmp.h for error handling */ +# include + +# ifdef __linux__ +# ifdef PNG_SAVE_BSD_SOURCE +# ifndef _BSD_SOURCE +# define _BSD_SOURCE +# endif +# undef PNG_SAVE_BSD_SOURCE +# endif +# endif /* __linux__ */ +#endif /* PNG_SETJMP_SUPPORTED */ + +#ifdef BSD +# include +#else +# include +#endif + +/* Other defines for things like memory and the like can go here. */ +#ifdef PNG_INTERNAL + +#include + +/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which + * aren't usually used outside the library (as far as I know), so it is + * debatable if they should be exported at all. In the future, when it is + * possible to have run-time registry of chunk-handling functions, some of + * these will be made available again. +#define PNG_EXTERN extern + */ +#define PNG_EXTERN + +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) +# if defined(MACOS) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include +# endif +# else +# include +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include +# endif +#endif + +/* Codewarrior on NT has linking problems without this. */ +#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) +# define PNG_ALWAYS_EXTERN +#endif + +/* This provides the non-ANSI (far) memory allocation routines. */ +#if defined(__TURBOC__) && defined(__MSDOS__) +# include +# include +#endif + +/* I have no idea why is this necessary... */ +#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ + defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) +# include +#endif + +/* This controls how fine the dithering gets. As this allocates + * a largish chunk of memory (32K), those who are not as concerned + * with dithering quality can decrease some or all of these. + */ +#ifndef PNG_DITHER_RED_BITS +# define PNG_DITHER_RED_BITS 5 +#endif +#ifndef PNG_DITHER_GREEN_BITS +# define PNG_DITHER_GREEN_BITS 5 +#endif +#ifndef PNG_DITHER_BLUE_BITS +# define PNG_DITHER_BLUE_BITS 5 +#endif + +/* This controls how fine the gamma correction becomes when you + * are only interested in 8 bits anyway. Increasing this value + * results in more memory being used, and more pow() functions + * being called to fill in the gamma tables. Don't set this value + * less then 8, and even that may not work (I haven't tested it). + */ + +#ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +#endif + +/* This controls how much a difference in gamma we can tolerate before + * we actually start doing gamma conversion. + */ +#ifndef PNG_GAMMA_THRESHOLD +# define PNG_GAMMA_THRESHOLD 0.05 +#endif + +#endif /* PNG_INTERNAL */ + +/* The following uses const char * instead of char * for error + * and warning message functions, so some compilers won't complain. + * If you do not want to use const, define PNG_NO_CONST here. + */ + +#ifndef PNG_NO_CONST +# define PNG_CONST const +#else +# define PNG_CONST +#endif + +/* The following defines give you the ability to remove code from the + * library that you will not be using. I wish I could figure out how to + * automate this, but I can't do that without making it seriously hard + * on the users. So if you are not using an ability, change the #define + * to and #undef, and that part of the library will not be compiled. If + * your linker can't find a function, you may want to make sure the + * ability is defined here. Some of these depend upon some others being + * defined. I haven't figured out all the interactions here, so you may + * have to experiment awhile to get everything to compile. If you are + * creating or using a shared library, you probably shouldn't touch this, + * as it will affect the size of the structures, and this will cause bad + * things to happen if the library and/or application ever change. + */ + +/* Any features you will not be using can be undef'ed here */ + +/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user + * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS + * on the compile line, then pick and choose which ones to define without + * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED + * if you only want to have a png-compliant reader/writer but don't need + * any of the extra transformations. This saves about 80 kbytes in a + * typical installation of the library. (PNG_NO_* form added in version + * 1.0.1c, for consistency) + */ + +/* The size of the png_text structure changed in libpng-1.0.6 when + * iTXt support was added. iTXt support was turned off by default through + * libpng-1.2.x, to support old apps that malloc the png_text structure + * instead of calling png_set_text() and letting libpng malloc it. It + * was turned on by default in libpng-1.3.0. + */ + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +# ifndef PNG_NO_iTXt_SUPPORTED +# define PNG_NO_iTXt_SUPPORTED +# endif +# ifndef PNG_NO_READ_iTXt +# define PNG_NO_READ_iTXt +# endif +# ifndef PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_iTXt +# endif +#endif + +#if !defined(PNG_NO_iTXt_SUPPORTED) +# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) +# define PNG_READ_iTXt +# endif +# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) +# define PNG_WRITE_iTXt +# endif +#endif + +/* The following support, added after version 1.0.0, can be turned off here en + * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility + * with old applications that require the length of png_struct and png_info + * to remain unchanged. + */ + +#ifdef PNG_LEGACY_SUPPORTED +# define PNG_NO_FREE_ME +# define PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_NO_READ_USER_CHUNKS +# define PNG_NO_READ_iCCP +# define PNG_NO_WRITE_iCCP +# define PNG_NO_READ_iTXt +# define PNG_NO_WRITE_iTXt +# define PNG_NO_READ_sCAL +# define PNG_NO_WRITE_sCAL +# define PNG_NO_READ_sPLT +# define PNG_NO_WRITE_sPLT +# define PNG_NO_INFO_IMAGE +# define PNG_NO_READ_RGB_TO_GRAY +# define PNG_NO_READ_USER_TRANSFORM +# define PNG_NO_WRITE_USER_TRANSFORM +# define PNG_NO_USER_MEM +# define PNG_NO_READ_EMPTY_PLTE +# define PNG_NO_MNG_FEATURES +# define PNG_NO_FIXED_POINT_SUPPORTED +#endif + +/* Ignore attempt to turn off both floating and fixed point support */ +#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ + !defined(PNG_NO_FIXED_POINT_SUPPORTED) +# define PNG_FIXED_POINT_SUPPORTED +#endif + +#ifndef PNG_NO_FREE_ME +# define PNG_FREE_ME_SUPPORTED +#endif + +#if defined(PNG_READ_SUPPORTED) + +#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_TRANSFORMS) +# define PNG_READ_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_READ_EXPAND +# define PNG_READ_EXPAND_SUPPORTED +# endif +# ifndef PNG_NO_READ_SHIFT +# define PNG_READ_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACK +# define PNG_READ_PACK_SUPPORTED +# endif +# ifndef PNG_NO_READ_BGR +# define PNG_READ_BGR_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP +# define PNG_READ_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACKSWAP +# define PNG_READ_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT +# define PNG_READ_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_READ_DITHER +# define PNG_READ_DITHER_SUPPORTED +# endif +# ifndef PNG_NO_READ_BACKGROUND +# define PNG_READ_BACKGROUND_SUPPORTED +# endif +# ifndef PNG_NO_READ_16_TO_8 +# define PNG_READ_16_TO_8_SUPPORTED +# endif +# ifndef PNG_NO_READ_FILLER +# define PNG_READ_FILLER_SUPPORTED +# endif +# ifndef PNG_NO_READ_GAMMA +# define PNG_READ_GAMMA_SUPPORTED +# endif +# ifndef PNG_NO_READ_GRAY_TO_RGB +# define PNG_READ_GRAY_TO_RGB_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP_ALPHA +# define PNG_READ_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT_ALPHA +# define PNG_READ_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_STRIP_ALPHA +# define PNG_READ_STRIP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_USER_TRANSFORM +# define PNG_READ_USER_TRANSFORM_SUPPORTED +# endif +# ifndef PNG_NO_READ_RGB_TO_GRAY +# define PNG_READ_RGB_TO_GRAY_SUPPORTED +# endif +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_PROGRESSIVE_READ) && \ + !defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */ +# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ +#endif /* about interlacing capability! You'll */ + /* still have interlacing unless you change the following line: */ + +#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */ + +#ifndef PNG_NO_READ_COMPOSITE_NODIV +# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ +# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ +# endif +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated, will be removed from version 2.0.0. + Use PNG_MNG_FEATURES_SUPPORTED instead. */ +#ifndef PNG_NO_READ_EMPTY_PLTE +# define PNG_READ_EMPTY_PLTE_SUPPORTED +#endif +#endif + +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_WRITE_SUPPORTED) + +# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_TRANSFORMS) +# define PNG_WRITE_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_WRITE_SHIFT +# define PNG_WRITE_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACK +# define PNG_WRITE_PACK_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_BGR +# define PNG_WRITE_BGR_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_SWAP +# define PNG_WRITE_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACKSWAP +# define PNG_WRITE_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT +# define PNG_WRITE_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_FILLER +# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ +# endif +# ifndef PNG_NO_WRITE_SWAP_ALPHA +# define PNG_WRITE_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT_ALPHA +# define PNG_WRITE_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_USER_TRANSFORM +# define PNG_WRITE_USER_TRANSFORM_SUPPORTED +# endif +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ + !defined(PNG_WRITE_INTERLACING_SUPPORTED) +#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant + encoders, but can cause trouble + if left undefined */ +#endif + +#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ + !defined(PNG_WRITE_WEIGHTED_FILTER) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#endif + +#ifndef PNG_NO_WRITE_FLUSH +# define PNG_WRITE_FLUSH_SUPPORTED +#endif + +#if defined(PNG_1_0_X) || defined (PNG_1_2_X) +/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ +#ifndef PNG_NO_WRITE_EMPTY_PLTE +# define PNG_WRITE_EMPTY_PLTE_SUPPORTED +#endif +#endif + +#endif /* PNG_WRITE_SUPPORTED */ + +#ifndef PNG_1_0_X +# ifndef PNG_NO_ERROR_NUMBERS +# define PNG_ERROR_NUMBERS_SUPPORTED +# endif +#endif /* PNG_1_0_X */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +# ifndef PNG_NO_USER_TRANSFORM_PTR +# define PNG_USER_TRANSFORM_PTR_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_STDIO +# define PNG_TIME_RFC1123_SUPPORTED +#endif + +/* This adds extra functions in pngget.c for accessing data from the + * info pointer (added in version 0.99) + * png_get_image_width() + * png_get_image_height() + * png_get_bit_depth() + * png_get_color_type() + * png_get_compression_type() + * png_get_filter_type() + * png_get_interlace_type() + * png_get_pixel_aspect_ratio() + * png_get_pixels_per_meter() + * png_get_x_offset_pixels() + * png_get_y_offset_pixels() + * png_get_x_offset_microns() + * png_get_y_offset_microns() + */ +#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) +# define PNG_EASY_ACCESS_SUPPORTED +#endif + +/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 + * and removed from version 1.2.20. The following will be removed + * from libpng-1.4.0 +*/ + +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE) +# ifndef PNG_OPTIMIZED_CODE_SUPPORTED +# define PNG_OPTIMIZED_CODE_SUPPORTED +# endif +#endif + +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) && defined(__i386__) +# ifndef PNG_ASSEMBLER_CODE_SUPPORTED +# define PNG_ASSEMBLER_CODE_SUPPORTED +# endif + +# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4) + /* work around 64-bit gcc compiler bugs in gcc-3.x */ +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_NO_MMX_CODE +# endif +# endif + +# if defined(__APPLE__) +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_NO_MMX_CODE +# endif +# endif + +# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh)) +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_NO_MMX_CODE +# endif +# endif + +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_MMX_CODE_SUPPORTED +# endif + +#endif +/* end of obsolete code to be removed from libpng-1.4.0 */ + +#if !defined(PNG_1_0_X) +#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) +# define PNG_USER_MEM_SUPPORTED +#endif +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.2.6 */ +#if !defined(PNG_1_0_X) +#ifndef PNG_SET_USER_LIMITS_SUPPORTED +#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) +# define PNG_SET_USER_LIMITS_SUPPORTED +#endif +#endif +#endif /* PNG_1_0_X */ + +/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter + * how large, set these limits to 0x7fffffffL + */ +#ifndef PNG_USER_WIDTH_MAX +# define PNG_USER_WIDTH_MAX 1000000L +#endif +#ifndef PNG_USER_HEIGHT_MAX +# define PNG_USER_HEIGHT_MAX 1000000L +#endif + +/* Added at libpng-1.2.34 and 1.4.0 */ +#ifndef PNG_STRING_NEWLINE +#define PNG_STRING_NEWLINE "\n" +#endif + +/* These are currently experimental features, define them if you want */ + +/* very little testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# endif +#endif +*/ + +/* This is only for PowerPC big-endian and 680x0 systems */ +/* some testing */ +/* +#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED +# define PNG_READ_BIG_ENDIAN_SUPPORTED +#endif +*/ + +/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ +/* +#define PNG_NO_POINTER_INDEXING +*/ + +/* These functions are turned off by default, as they will be phased out. */ +/* +#define PNG_USELESS_TESTS_SUPPORTED +#define PNG_CORRECT_PALETTE_SUPPORTED +*/ + +/* Any chunks you are not interested in, you can undef here. The + * ones that allocate memory may be expecially important (hIST, + * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info + * a bit smaller. + */ + +#if defined(PNG_READ_SUPPORTED) && \ + !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_ANCILLARY_CHUNKS) +# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#if defined(PNG_WRITE_SUPPORTED) && \ + !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) +# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_READ_TEXT +# define PNG_NO_READ_iTXt +# define PNG_NO_READ_tEXt +# define PNG_NO_READ_zTXt +#endif +#ifndef PNG_NO_READ_bKGD +# define PNG_READ_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +#endif +#ifndef PNG_NO_READ_cHRM +# define PNG_READ_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +#endif +#ifndef PNG_NO_READ_gAMA +# define PNG_READ_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +#endif +#ifndef PNG_NO_READ_hIST +# define PNG_READ_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +#endif +#ifndef PNG_NO_READ_iCCP +# define PNG_READ_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +#endif +#ifndef PNG_NO_READ_iTXt +# ifndef PNG_READ_iTXt_SUPPORTED +# define PNG_READ_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_READ_oFFs +# define PNG_READ_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +#endif +#ifndef PNG_NO_READ_pCAL +# define PNG_READ_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_sCAL +# define PNG_READ_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_pHYs +# define PNG_READ_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +#endif +#ifndef PNG_NO_READ_sBIT +# define PNG_READ_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sPLT +# define PNG_READ_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sRGB +# define PNG_READ_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +#endif +#ifndef PNG_NO_READ_tEXt +# define PNG_READ_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_tIME +# define PNG_READ_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +#endif +#ifndef PNG_NO_READ_tRNS +# define PNG_READ_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +#endif +#ifndef PNG_NO_READ_zTXt +# define PNG_READ_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#if !defined(PNG_NO_READ_USER_CHUNKS) && \ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# define PNG_READ_USER_CHUNKS_SUPPORTED +# define PNG_USER_CHUNKS_SUPPORTED +# ifdef PNG_NO_READ_UNKNOWN_CHUNKS +# undef PNG_NO_READ_UNKNOWN_CHUNKS +# endif +# ifdef PNG_NO_HANDLE_AS_UNKNOWN +# undef PNG_NO_HANDLE_AS_UNKNOWN +# endif +#endif +#ifndef PNG_NO_READ_OPT_PLTE +# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ +#endif /* optional PLTE chunk in RGB and RGBA images */ +#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ + defined(PNG_READ_zTXt_SUPPORTED) +# define PNG_READ_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +#endif + +#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ + +#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_WRITE_TEXT +# define PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_tEXt +# define PNG_NO_WRITE_zTXt +#endif +#ifndef PNG_NO_WRITE_bKGD +# define PNG_WRITE_bKGD_SUPPORTED +# ifndef PNG_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_cHRM +# define PNG_WRITE_cHRM_SUPPORTED +# ifndef PNG_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_gAMA +# define PNG_WRITE_gAMA_SUPPORTED +# ifndef PNG_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_hIST +# define PNG_WRITE_hIST_SUPPORTED +# ifndef PNG_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iCCP +# define PNG_WRITE_iCCP_SUPPORTED +# ifndef PNG_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iTXt +# ifndef PNG_WRITE_iTXt_SUPPORTED +# define PNG_WRITE_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_oFFs +# define PNG_WRITE_oFFs_SUPPORTED +# ifndef PNG_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pCAL +# define PNG_WRITE_pCAL_SUPPORTED +# ifndef PNG_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sCAL +# define PNG_WRITE_sCAL_SUPPORTED +# ifndef PNG_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pHYs +# define PNG_WRITE_pHYs_SUPPORTED +# ifndef PNG_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sBIT +# define PNG_WRITE_sBIT_SUPPORTED +# ifndef PNG_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sPLT +# define PNG_WRITE_sPLT_SUPPORTED +# ifndef PNG_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sRGB +# define PNG_WRITE_sRGB_SUPPORTED +# ifndef PNG_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tEXt +# define PNG_WRITE_tEXt_SUPPORTED +# ifndef PNG_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tIME +# define PNG_WRITE_tIME_SUPPORTED +# ifndef PNG_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tRNS +# define PNG_WRITE_tRNS_SUPPORTED +# ifndef PNG_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_zTXt +# define PNG_WRITE_zTXt_SUPPORTED +# ifndef PNG_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +# endif +#endif +#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ + defined(PNG_WRITE_zTXt_SUPPORTED) +# define PNG_WRITE_TEXT_SUPPORTED +# ifndef PNG_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +# endif +#endif + +#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ + +/* Turn this off to disable png_read_png() and + * png_write_png() and leave the row_pointers member + * out of the info structure. + */ +#ifndef PNG_NO_INFO_IMAGE +# define PNG_INFO_IMAGE_SUPPORTED +#endif + +/* need the time information for reading tIME chunks */ +#if defined(PNG_tIME_SUPPORTED) +# if !defined(_WIN32_WCE) + /* "time.h" functions are not supported on WindowsCE */ +# include +# endif +#endif + +/* Some typedefs to get us started. These should be safe on most of the + * common platforms. The typedefs should be at least as large as the + * numbers suggest (a png_uint_32 must be at least 32 bits long), but they + * don't have to be exactly that size. Some compilers dislike passing + * unsigned shorts as function parameters, so you may be better off using + * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may + * want to have unsigned int for png_uint_32 instead of unsigned long. + */ + +typedef unsigned long png_uint_32; +typedef long png_int_32; +typedef unsigned short png_uint_16; +typedef short png_int_16; +typedef unsigned char png_byte; + +/* This is usually size_t. It is typedef'ed just in case you need it to + change (I'm not sure if you will or not, so I thought I'd be safe) */ +#ifdef PNG_SIZE_T + typedef PNG_SIZE_T png_size_t; +# define png_sizeof(x) png_convert_size(sizeof(x)) +#else + typedef size_t png_size_t; +# define png_sizeof(x) sizeof(x) +#endif + +/* The following is needed for medium model support. It cannot be in the + * PNG_INTERNAL section. Needs modification for other compilers besides + * MSC. Model independent support declares all arrays and pointers to be + * large using the far keyword. The zlib version used must also support + * model independent data. As of version zlib 1.0.4, the necessary changes + * have been made in zlib. The USE_FAR_KEYWORD define triggers other + * changes that are needed. (Tim Wegner) + */ + +/* Separate compiler dependencies (problem here is that zlib.h always + defines FAR. (SJT) */ +#ifdef __BORLANDC__ +# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) +# define LDATA 1 +# else +# define LDATA 0 +# endif + /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ +# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) +# define PNG_MAX_MALLOC_64K +# if (LDATA != 1) +# ifndef FAR +# define FAR __far +# endif +# define USE_FAR_KEYWORD +# endif /* LDATA != 1 */ + /* Possibly useful for moving data out of default segment. + * Uncomment it if you want. Could also define FARDATA as + * const if your compiler supports it. (SJT) +# define FARDATA FAR + */ +# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ +#endif /* __BORLANDC__ */ + + +/* Suggest testing for specific compiler first before testing for + * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, + * making reliance oncertain keywords suspect. (SJT) + */ + +/* MSC Medium model */ +#if defined(FAR) +# if defined(M_I86MM) +# define USE_FAR_KEYWORD +# define FARDATA FAR +# include +# endif +#endif + +/* SJT: default case */ +#ifndef FAR +# define FAR +#endif + +/* At this point FAR is always defined */ +#ifndef FARDATA +# define FARDATA +#endif + +/* Typedef for floating-point numbers that are converted + to fixed-point with a multiple of 100,000, e.g., int_gamma */ +typedef png_int_32 png_fixed_point; + +/* Add typedefs for pointers */ +typedef void FAR * png_voidp; +typedef png_byte FAR * png_bytep; +typedef png_uint_32 FAR * png_uint_32p; +typedef png_int_32 FAR * png_int_32p; +typedef png_uint_16 FAR * png_uint_16p; +typedef png_int_16 FAR * png_int_16p; +typedef PNG_CONST char FAR * png_const_charp; +typedef char FAR * png_charp; +typedef png_fixed_point FAR * png_fixed_point_p; + +#ifndef PNG_NO_STDIO +#if defined(_WIN32_WCE) +typedef HANDLE png_FILE_p; +#else +typedef FILE * png_FILE_p; +#endif +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * png_doublep; +#endif + +/* Pointers to pointers; i.e. arrays */ +typedef png_byte FAR * FAR * png_bytepp; +typedef png_uint_32 FAR * FAR * png_uint_32pp; +typedef png_int_32 FAR * FAR * png_int_32pp; +typedef png_uint_16 FAR * FAR * png_uint_16pp; +typedef png_int_16 FAR * FAR * png_int_16pp; +typedef PNG_CONST char FAR * FAR * png_const_charpp; +typedef char FAR * FAR * png_charpp; +typedef png_fixed_point FAR * FAR * png_fixed_point_pp; +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * FAR * png_doublepp; +#endif + +/* Pointers to pointers to pointers; i.e., pointer to array */ +typedef char FAR * FAR * FAR * png_charppp; + +#if defined(PNG_1_0_X) || defined(PNG_1_2_X) +/* SPC - Is this stuff deprecated? */ +/* It'll be removed as of libpng-1.3.0 - GR-P */ +/* libpng typedefs for types in zlib. If zlib changes + * or another compression library is used, then change these. + * Eliminates need to change all the source files. + */ +typedef charf * png_zcharp; +typedef charf * FAR * png_zcharpp; +typedef z_stream FAR * png_zstreamp; +#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ + +/* + * Define PNG_BUILD_DLL if the module being built is a Windows + * LIBPNG DLL. + * + * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. + * It is equivalent to Microsoft predefined macro _DLL that is + * automatically defined when you compile using the share + * version of the CRT (C Run-Time library) + * + * The cygwin mods make this behavior a little different: + * Define PNG_BUILD_DLL if you are building a dll for use with cygwin + * Define PNG_STATIC if you are building a static library for use with cygwin, + * -or- if you are building an application that you want to link to the + * static library. + * PNG_USE_DLL is defined by default (no user action needed) unless one of + * the other flags is defined. + */ + +#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) +# define PNG_DLL +#endif +/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. + * When building a static lib, default to no GLOBAL ARRAYS, but allow + * command-line override + */ +#if defined(__CYGWIN__) +# if !defined(PNG_STATIC) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +# else +# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# endif +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +#endif + +/* Do not use global arrays (helps with building DLL's) + * They are no longer used in libpng itself, since version 1.0.5c, + * but might be required for some pre-1.0.5c applications. + */ +#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# if defined(PNG_NO_GLOBAL_ARRAYS) || \ + (defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER) +# define PNG_USE_LOCAL_ARRAYS +# else +# define PNG_USE_GLOBAL_ARRAYS +# endif +#endif + +#if defined(__CYGWIN__) +# undef PNGAPI +# define PNGAPI __cdecl +# undef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", + * you may get warnings regarding the linkage of png_zalloc and png_zfree. + * Don't ignore those warnings; you must also reset the default calling + * convention in your compiler to match your PNGAPI, and you must build + * zlib and your applications the same way you build libpng. + */ + +#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) +# ifndef PNG_NO_MODULEDEF +# define PNG_NO_MODULEDEF +# endif +#endif + +#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) +# define PNG_IMPEXP +#endif + +#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ + (( defined(_Windows) || defined(_WINDOWS) || \ + defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) + +# ifndef PNGAPI +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGAPI __cdecl +# else +# define PNGAPI _cdecl +# endif +# endif + +# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ + 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) +# define PNG_IMPEXP +# endif + +# if !defined(PNG_IMPEXP) + +# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol +# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol + + /* Borland/Microsoft */ +# if defined(_MSC_VER) || defined(__BORLANDC__) +# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) +# define PNG_EXPORT PNG_EXPORT_TYPE1 +# else +# define PNG_EXPORT PNG_EXPORT_TYPE2 +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __export +# else +# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in + VC++ */ +# endif /* Exists in Borland C++ for + C++ classes (== huge) */ +# endif +# endif + +# if !defined(PNG_IMPEXP) +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __declspec(dllexport) +# else +# define PNG_IMPEXP __declspec(dllimport) +# endif +# endif +# endif /* PNG_IMPEXP */ +#else /* !(DLL || non-cygwin WINDOWS) */ +# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) +# ifndef PNGAPI +# define PNGAPI _System +# endif +# else +# if 0 /* ... other platforms, with other meanings */ +# endif +# endif +#endif + +#ifndef PNGAPI +# define PNGAPI +#endif +#ifndef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +#ifdef PNG_BUILDSYMS +# ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END +# endif +# ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT +# endif +# endif +#endif + +#ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type +# endif +#endif + +/* User may want to use these so they are not in PNG_INTERNAL. Any library + * functions that are passed far data must be model independent. + */ + +#ifndef PNG_ABORT +# define PNG_ABORT() abort() +#endif + +#ifdef PNG_SETJMP_SUPPORTED +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) +#endif + +#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ +/* use this to make far-to-near assignments */ +# define CHECK 1 +# define NOCHECK 0 +# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) +# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) +# define png_snprintf _fsnprintf /* Added to v 1.2.19 */ +# define png_strlen _fstrlen +# define png_memcmp _fmemcmp /* SJT: added */ +# define png_memcpy _fmemcpy +# define png_memset _fmemset +#else /* use the usual functions */ +# define CVT_PTR(ptr) (ptr) +# define CVT_PTR_NOCHECK(ptr) (ptr) +# ifndef PNG_NO_SNPRINTF +# ifdef _MSC_VER +# define png_snprintf _snprintf /* Added to v 1.2.19 */ +# define png_snprintf2 _snprintf +# define png_snprintf6 _snprintf +# else +# define png_snprintf snprintf /* Added to v 1.2.19 */ +# define png_snprintf2 snprintf +# define png_snprintf6 snprintf +# endif +# else + /* You don't have or don't want to use snprintf(). Caution: Using + * sprintf instead of snprintf exposes your application to accidental + * or malevolent buffer overflows. If you don't have snprintf() + * as a general rule you should provide one (you can get one from + * Portable OpenSSH). */ +# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1) +# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2) +# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \ + sprintf(s1,fmt,x1,x2,x3,x4,x5,x6) +# endif +# define png_strlen strlen +# define png_memcmp memcmp /* SJT: added */ +# define png_memcpy memcpy +# define png_memset memset +#endif +/* End of memory model independent support */ + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536L +#endif + +/* Added at libpng-1.2.8 */ +#endif /* PNG_VERSION_INFO_ONLY */ + +#endif /* PNGCONF_H */ diff --git a/lib/libpng/include/zconf.h b/lib/libpng/include/zconf.h new file mode 100644 index 0000000..c89b6bd --- /dev/null +++ b/lib/libpng/include/zconf.h @@ -0,0 +1,332 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError + +# define alloc_func z_alloc_func +# define free_func z_free_func +# define in_func z_in_func +# define out_func z_out_func +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */ +# include /* for off_t */ +//# include /* for SEEK_* and off_t */ JONAS +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +# ifdef FAR +# undef FAR +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(deflateBound,"DEBND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(compressBound,"CMBND") +# pragma map(inflate_table,"INTABL") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/lib/libpng/include/zlib.h b/lib/libpng/include/zlib.h new file mode 100644 index 0000000..0228179 --- /dev/null +++ b/lib/libpng/include/zlib.h @@ -0,0 +1,1357 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.3, July 18th, 2005 + + Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/lib/libpng/lib/libpng-bcc.lib b/lib/libpng/lib/libpng-bcc.lib new file mode 100644 index 0000000..ebcbf6b Binary files /dev/null and b/lib/libpng/lib/libpng-bcc.lib differ diff --git a/lib/libpng/lib/libpng.lib b/lib/libpng/lib/libpng.lib new file mode 100644 index 0000000..b693724 Binary files /dev/null and b/lib/libpng/lib/libpng.lib differ diff --git a/lib/libpng/libpng-config.htm b/lib/libpng/libpng-config.htm new file mode 100644 index 0000000..e150f9d --- /dev/null +++ b/lib/libpng/libpng-config.htm @@ -0,0 +1,2062 @@ + + + + + + + + + + + + + + + + + + + libpng-config - + stonesense - + + + A retro isometric visualizer for Dwarf Fortress - Google Project Hosting + + + + + + + + + + + + + + + +

+ +
+ + + + + My favorites + | Sign in + + + +
+ +
+
+ + +
+ + + + + + + + + + + +
+ + + + + + + + +
+ + + +
+ +
+ +
+ + +
+ Project Home + + + + + Downloads + + + + + + Wiki + + + + + + + + Source + + + + + + + +
+
+ + + + + + + + + + + + + + + +
+
+
+ + + + + Checkout   + Browse   + Changes   + +   + + +
+ +   + + + + + + +
+ +
+
+ +
+ + + +
+ + + + + + + +
+
+ + + + + + + + + + + +
+ + + + + + + +
+
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
+
+
+
+
#! /bin/sh

# libpng-config
# provides configuration info for libpng.

# Copyright (C) 2002, 2004, 2006, 2007 Glenn Randers-Pehrson
# For conditions of distribution and use, see copyright notice in png.h

# Modeled after libxml-config.

version="1.2.37"
prefix="c:/progra~1/libpng"
exec_prefix="${prefix}"
libdir="${exec_prefix}/lib"
includedir="${prefix}/include/libpng12"
libs="-lpng12"
all_libs="-lpng12 -lz
I_opts="-I${includedir}"
L_opts="-L${libdir}"
R_opts=""
cppflags=""
ccopts=""
ldopts=""

usage()
{
cat <<EOF
Usage: $0 [OPTION] ...

Known values for OPTION are:

--prefix print libpng prefix
--libdir print path to directory containing library
--libs print library linking information
--ccopts print compiler options
--cppflags print pre-processor flags
--cflags print preprocessor flags, I_opts, and compiler options
--I_opts print "-I" include options
--L_opts print linker "-L" flags for dynamic linking
--R_opts print dynamic linker "-R" or "-rpath" flags
--ldopts print linker options
--ldflags print linker flags (ldopts, L_opts, R_opts, and libs)
--static revise subsequent outputs for static linking
--help print this help and exit
--version print version information
EOF

exit $1
}

if test $# -eq 0; then
usage 1
fi

while test $# -gt 0; do
case "$1" in

--prefix)
echo ${prefix}
;;

--version)
echo ${version}
exit 0
;;

--help)
usage 0
;;

--ccopts)
echo ${ccopts}
;;

--cppflags)
echo ${cppflags}
;;

--cflags)
echo ${I_opts} ${cppflags} ${ccopts}
;;

--libdir)
echo ${libdir}
;;

--libs)
echo ${libs}
;;

--I_opts)
echo ${I_opts}
;;

--L_opts)
echo ${L_opts}
;;

--R_opts)
echo ${R_opts}
;;

--ldopts)
echo ${ldopts}
;;

--ldflags)
echo ${ldopts} ${L_opts} ${R_opts} ${libs}
;;

--static)
R_opts=""
libs=${all_libs}
;;

*)
usage
exit 1
;;
esac
shift
done

exit 0
+
+
+ + + + + + +
+ +
+ + +
+
+
+
+
+
+

Change log

+
+ r64 + by jonask84 + on Oct 26, 2009 +   Diff +
+
Moved all sprites to PNG format.
+Added loadpng library, and with it libpng
+and zlib.
+Screenshots are now saved as png.
+No transparency is yet supported.
+
+ + + + + + + + + + +
+
Go to:  + +
+ + + + + + +
+ Project members, + sign in to write a code review
+ + + +
+ + +
+
+
+
+
+
+
+
+
+
+
+

Older revisions

+ + All revisions of this file +
+
+
+
+
+
+ +
+
+
+
+
+
+

File info

+ +
Size: 2245 bytes, + 124 lines
+ + +
+ +
+
+
+
+
+
+
+ + +
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+ + +
+ Powered by Google Project Hosting +
+ + + + + + + + + diff --git a/lib/libpng/libpng12-config.htm b/lib/libpng/libpng12-config.htm new file mode 100644 index 0000000..42271cd --- /dev/null +++ b/lib/libpng/libpng12-config.htm @@ -0,0 +1,2062 @@ + + + + + + + + + + + + + + + + + + + libpng12-config - + stonesense - + + + A retro isometric visualizer for Dwarf Fortress - Google Project Hosting + + + + + + + + + + + + + + + +
+ +
+ + + + + My favorites + | Sign in + + + +
+ +
+
+ + +
+ + + + + + + + + + + +
+ + + + + + + + +
+ + + +
+ +
+ +
+ + +
+ Project Home + + + + + Downloads + + + + + + Wiki + + + + + + + + Source + + + + + + + +
+
+ + + + + + + + + + + + + + + +
+
+
+ + + + + Checkout   + Browse   + Changes   + +   + + +
+ +   + + + + + + +
+ +
+
+ +
+ + + +
+ + + + + + + +
+
+ + + + + + + + + + + +
+ + + + + + + +
+
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
+
+
+
+
#! /bin/sh

# libpng-config
# provides configuration info for libpng.

# Copyright (C) 2002, 2004, 2006, 2007 Glenn Randers-Pehrson
# For conditions of distribution and use, see copyright notice in png.h

# Modeled after libxml-config.

version="1.2.37"
prefix="c:/progra~1/libpng"
exec_prefix="${prefix}"
libdir="${exec_prefix}/lib"
includedir="${prefix}/include/libpng12"
libs="-lpng12"
all_libs="-lpng12 -lz
I_opts="-I${includedir}"
L_opts="-L${libdir}"
R_opts=""
cppflags=""
ccopts=""
ldopts=""

usage()
{
cat <<EOF
Usage: $0 [OPTION] ...

Known values for OPTION are:

--prefix print libpng prefix
--libdir print path to directory containing library
--libs print library linking information
--ccopts print compiler options
--cppflags print pre-processor flags
--cflags print preprocessor flags, I_opts, and compiler options
--I_opts print "-I" include options
--L_opts print linker "-L" flags for dynamic linking
--R_opts print dynamic linker "-R" or "-rpath" flags
--ldopts print linker options
--ldflags print linker flags (ldopts, L_opts, R_opts, and libs)
--static revise subsequent outputs for static linking
--help print this help and exit
--version print version information
EOF

exit $1
}

if test $# -eq 0; then
usage 1
fi

while test $# -gt 0; do
case "$1" in

--prefix)
echo ${prefix}
;;

--version)
echo ${version}
exit 0
;;

--help)
usage 0
;;

--ccopts)
echo ${ccopts}
;;

--cppflags)
echo ${cppflags}
;;

--cflags)
echo ${I_opts} ${cppflags} ${ccopts}
;;

--libdir)
echo ${libdir}
;;

--libs)
echo ${libs}
;;

--I_opts)
echo ${I_opts}
;;

--L_opts)
echo ${L_opts}
;;

--R_opts)
echo ${R_opts}
;;

--ldopts)
echo ${ldopts}
;;

--ldflags)
echo ${ldopts} ${L_opts} ${R_opts} ${libs}
;;

--static)
R_opts=""
libs=${all_libs}
;;

*)
usage
exit 1
;;
esac
shift
done

exit 0
+
+
+ + + + + + +
+ +
+ + +
+
+
+
+
+
+

Change log

+
+ r64 + by jonask84 + on Oct 26, 2009 +   Diff +
+
Moved all sprites to PNG format.
+Added loadpng library, and with it libpng
+and zlib.
+Screenshots are now saved as png.
+No transparency is yet supported.
+
+ + + + + + + + + + +
+
Go to:  + +
+ + + + + + +
+ Project members, + sign in to write a code review
+ + + +
+ + +
+
+
+
+
+
+
+
+
+
+
+

Older revisions

+ + All revisions of this file +
+
+
+
+
+
+ +
+
+
+
+
+
+

File info

+ +
Size: 2245 bytes, + 124 lines
+ + +
+ +
+
+
+
+
+
+
+ + +
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+ + +
+ Powered by Google Project Hosting +
+ + + + + + + + + diff --git a/lib/libpng/libpng12.dll b/lib/libpng/libpng12.dll new file mode 100644 index 0000000..25c0a7c Binary files /dev/null and b/lib/libpng/libpng12.dll differ diff --git a/lib/libpng/libpng3.dll b/lib/libpng/libpng3.dll new file mode 100644 index 0000000..649ec64 Binary files /dev/null and b/lib/libpng/libpng3.dll differ diff --git a/lib/loadpng/loadpng.c b/lib/loadpng/loadpng.c new file mode 100644 index 0000000..7e2cfe5 --- /dev/null +++ b/lib/loadpng/loadpng.c @@ -0,0 +1,403 @@ +/* loadpng, Allegro wrapper routines for libpng + * by Peter Wang (tjaden@users.sf.net). + * + * This file is hereby placed in the public domain. + */ + + +//#include +#include +#include +#include "loadpng.h" +#include "png.h" +#include "zlib.h" + +/* We need internals _color_load_depth and _fixup_loaded_bitmap. The + * first can be replaced by the new get_color_depth() function which + * is in Allegro 4.1 branch. But it's not worth it to break 4.0 + * compatibility. + */ + + + +double _png_screen_gamma = -1.0; +int _png_compression_level = Z_BEST_COMPRESSION; + + + +/* get_gamma: + * Get screen gamma value one of three ways. + */ +static double get_gamma(void) +{ + if (_png_screen_gamma == -1.0) { + /* Use the environment variable if available. + * 2.2 is a good guess for PC monitors. + * 1.1 is good for my laptop. + */ + + AL_CONST char *gamma_str = NULL; //getenv("SCREEN_GAMMA"); + return (gamma_str) ? atof(gamma_str) : 2.2; + } + + return _png_screen_gamma; +} + + + +/* read_data: + * Custom read function to use Allegro packfile routines, + * rather than C streams (so we can read from datafiles!) + */ +static void read_data(png_structp png_ptr, png_bytep data, png_uint_32 length) +{ + PACKFILE *f = (PACKFILE *)png_get_io_ptr(png_ptr); + if ((png_uint_32)pack_fread(data, length, f) != length) + png_error(png_ptr, "read error (loadpng calling pack_fread)"); +} + + + +/* check_if_png: + * Check if input file is really PNG format. + */ +#define PNG_BYTES_TO_CHECK 4 + +static int check_if_png(PACKFILE *fp) +{ + unsigned char buf[PNG_BYTES_TO_CHECK]; + + ASSERT(fp); + + if (pack_fread(buf, PNG_BYTES_TO_CHECK, fp) != PNG_BYTES_TO_CHECK) + return 0; + + return (png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK) == 0); +} + + + +/* really_load_png: + * Worker routine, used by load_png and load_memory_png. + */ +static BITMAP *really_load_png(png_structp png_ptr, png_infop info_ptr, RGB *pal) +{ + BITMAP *bmp; + PALETTE tmppal; + png_uint_32 width, height, rowbytes; + int bit_depth, color_type, interlace_type; + double image_gamma, screen_gamma; + int intent; + int bpp, dest_bpp; + int tRNS_to_alpha = FALSE; + int number_passes, pass; + + ASSERT(png_ptr && info_ptr && rgb); + + /* The call to png_read_info() gives us all of the information from the + * PNG file before the first IDAT (image data chunk). + */ + png_read_info(png_ptr, info_ptr); + + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, + &interlace_type, NULL, NULL); + + /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single + * byte into separate bytes (useful for paletted and grayscale images). + */ + png_set_packing(png_ptr); + + /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ + if ((color_type == PNG_COLOR_TYPE_GRAY) && (bit_depth < 8)) + png_set_expand(png_ptr); + + /* Adds a full alpha channel if there is transparency information + * in a tRNS chunk. */ + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { + png_set_tRNS_to_alpha(png_ptr); + tRNS_to_alpha = TRUE; + } + + /* Convert 16-bits per colour component to 8-bits per colour component. */ + if (bit_depth == 16) + png_set_strip_16(png_ptr); + + /* Convert grayscale to RGB triplets */ + if ((color_type == PNG_COLOR_TYPE_GRAY) || + (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) + png_set_gray_to_rgb(png_ptr); + + /* Optionally, tell libpng to handle the gamma correction for us. */ + if (_png_screen_gamma != 0.0) { + screen_gamma = get_gamma(); + + if (png_get_sRGB(png_ptr, info_ptr, &intent)) + png_set_gamma(png_ptr, screen_gamma, 0.45455); + else { + if (png_get_gAMA(png_ptr, info_ptr, &image_gamma)) + png_set_gamma(png_ptr, screen_gamma, image_gamma); + else + png_set_gamma(png_ptr, screen_gamma, 0.45455); + } + } + + /* Turn on interlace handling. */ + number_passes = png_set_interlace_handling(png_ptr); + + /* Call to gamma correct and add the background to the palette + * and update info structure. + */ + png_read_update_info(png_ptr, info_ptr); + + /* Even if the user doesn't supply space for a palette, we want + * one for the load process. + */ + if (!pal) + pal = tmppal; + + /* Palettes. */ + if (color_type & PNG_COLOR_MASK_PALETTE) { + int num_palette, i; + png_colorp palette; + + if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) { + /* We don't actually dither, we just copy the palette. */ + for (i = 0; ((i < num_palette) && (i < 256)); i++) { + pal[i].r = palette[i].red >> 2; /* 256 -> 64 */ + pal[i].g = palette[i].green >> 2; + pal[i].b = palette[i].blue >> 2; + } + + for (; i < 256; i++) + pal[i].r = pal[i].g = pal[i].b = 0; + } + } + else { + generate_332_palette(pal); + } + + rowbytes = png_get_rowbytes(png_ptr, info_ptr); + + /* Allocate the memory to hold the image using the fields of info_ptr. */ + bpp = rowbytes * 8 / width; + + /* Allegro cannot handle less than 8 bpp. */ + if (bpp < 8) + bpp = 8; + + dest_bpp = _color_load_depth(bpp, (bpp == 32)); + bmp = create_bitmap_ex(bpp, width, height); + + /* Maybe flip RGB to BGR. */ + if ((bpp == 24) || (bpp == 32)) { + int c = makecol_depth(bpp, 0, 0, 255); + unsigned char *pc = (unsigned char *)&c; + if (pc[0] == 255) + png_set_bgr(png_ptr); +#ifdef ALLEGRO_BIG_ENDIAN + png_set_swap_alpha(png_ptr); +#endif + } + + /* Read the image, one line at a line (easier to debug!) */ + for (pass = 0; pass < number_passes; pass++) { + png_uint_32 y; + for (y = 0; y < height; y++) + png_read_row(png_ptr, bmp->line[y], NULL); + } + + /* Let Allegro convert the image into the desired colour depth. */ + if (dest_bpp != bpp) + bmp = _fixup_loaded_bitmap(bmp, pal, dest_bpp); + + /* Read rest of file, and get additional chunks in info_ptr. */ + png_read_end(png_ptr, info_ptr); + + return bmp; +} + + + +/* load_png: + * Load a PNG file from disk, doing colour coversion if required. + */ +BITMAP *load_png(AL_CONST char *filename, RGB *pal) +{ + PACKFILE *fp; + BITMAP *bmp; + + ASSERT(filename); + + fp = pack_fopen(filename, "r"); + if (!fp) + return NULL; + + bmp = load_png_pf(fp, pal); + + pack_fclose(fp); + + return bmp; +} + + + +/* load_png_pf: + * Load a PNG file from disk, doing colour coversion if required. + */ +BITMAP *load_png_pf(PACKFILE *fp, RGB *pal) +{ + BITMAP *bmp; + png_structp png_ptr; + png_infop info_ptr; + + ASSERT(fp); + + if (!check_if_png(fp)) { + return NULL; + } + + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also supply the + * the compiler header file version, so that we know if the application + * was compiled with a compatible version of the library. + */ + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + (void *)NULL, NULL, NULL); + if (!png_ptr) { + return NULL; + } + + /* Allocate/initialize the memory for image information. */ + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); + return NULL; + } + + /* Set error handling if you are using the setjmp/longjmp method (this is + * the normal method of doing things with libpng). REQUIRED unless you + * set up your own error handlers in the png_create_read_struct() earlier. + */ + if (setjmp(png_ptr->jmpbuf)) { + /* Free all of the memory associated with the png_ptr and info_ptr */ + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); + /* If we get here, we had a problem reading the file */ + return NULL; + } + + /* Use Allegro packfile routines. */ + png_set_read_fn(png_ptr, fp, (png_rw_ptr)read_data); + + /* We have already read some of the signature. */ + png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); + + /* Really load the image now. */ + bmp = really_load_png(png_ptr, info_ptr, pal); + + /* Clean up after the read, and free any memory allocated. */ + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); + + return bmp; +} + + + +/* read_data_memory: + * Custom reader function to read a PNG file from a memory buffer. + */ + +typedef struct { + AL_CONST unsigned char *buffer; + png_uint_32 bufsize; + png_uint_32 current_pos; +} MEMORY_READER_STATE; + +static void read_data_memory(png_structp png_ptr, png_bytep data, png_uint_32 length) +{ + MEMORY_READER_STATE *f = (MEMORY_READER_STATE *)png_get_io_ptr(png_ptr); + + if (length > (f->bufsize - f->current_pos)) + png_error(png_ptr, "read error in read_data_memory (loadpng)"); + + memcpy(data, f->buffer + f->current_pos, length); + f->current_pos += length; +} + + + +/* check_if_png_memory: + * Check if input buffer is really PNG format. + */ +static int check_if_png_memory(AL_CONST void *buffer) +{ + unsigned char *buf = (unsigned char *)buffer; + return (png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK) == 0); +} + + + +/* load_memory_png: + * Load a PNG file from memory, doing colour coversion if required. + */ +BITMAP *load_memory_png(AL_CONST void *buffer, int bufsize, RGB *pal) +{ + MEMORY_READER_STATE memory_reader_state; + BITMAP *bmp; + png_structp png_ptr; + png_infop info_ptr; + + if (!buffer || (bufsize <= 0)) + return NULL; + + if (!check_if_png_memory(buffer)) + return NULL; + + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also supply the + * the compiler header file version, so that we know if the application + * was compiled with a compatible version of the library. + */ + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + (void *)NULL, NULL, NULL); + if (!png_ptr) + return NULL; + + /* Allocate/initialize the memory for image information. */ + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); + return NULL; + } + + /* Set error handling if you are using the setjmp/longjmp method (this is + * the normal method of doing things with libpng). REQUIRED unless you + * set up your own error handlers in the png_create_read_struct() earlier. + */ + if (setjmp(png_ptr->jmpbuf)) { + /* Free all of the memory associated with the png_ptr and info_ptr */ + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); + /* If we get here, we had a problem reading the file */ + return NULL; + } + + /* Set up the reader state. */ + memory_reader_state.buffer = (unsigned char *)buffer; + memory_reader_state.bufsize = bufsize; + memory_reader_state.current_pos = PNG_BYTES_TO_CHECK; + + /* Tell libpng to use our custom reader. */ + png_set_read_fn(png_ptr, &memory_reader_state, (png_rw_ptr)read_data_memory); + + /* We have already read some of the signature. */ + png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); + + /* Really load the image now. */ + bmp = really_load_png(png_ptr, info_ptr, pal); + + /* Clean up after the read, and free any memory allocated. */ + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); + + return bmp; +} \ No newline at end of file diff --git a/lib/loadpng/loadpng.h b/lib/loadpng/loadpng.h new file mode 100644 index 0000000..993da07 --- /dev/null +++ b/lib/loadpng/loadpng.h @@ -0,0 +1,75 @@ +/* loadpng.h */ +/* This file is hereby placed in the public domain. */ +#ifndef _included_loadpng_h_ +#define _included_loadpng_h_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +/* Overkill :-) */ +#define LOADPNG_VERSION 1 +#define LOADPNG_SUBVERSION 5 +#define LOADPNG_VERSIONSTR "1.5" + + +/* _png_screen_gamma is slightly overloaded (sorry): + * + * A value of 0.0 means: Don't do any gamma correction in load_png() + * and load_memory_png(). This meaning was introduced in v1.4. + * + * A value of -1.0 means: Use the value from the environment variable + * SCREEN_GAMMA (if available), otherwise fallback to a value of 2.2 + * (a good guess for PC monitors, and the value for sRGB colourspace). + * This is the default. + * + * Otherwise, the value of _png_screen_gamma is taken as-is. + */ +extern double _png_screen_gamma; + + +/* Choose zlib compression level for saving file. + * Default is Z_BEST_COMPRESSION. + */ +extern int _png_compression_level; + + +/* Load a PNG from disk. */ +extern BITMAP *load_png(AL_CONST char *filename, RGB *pal); + +/* Load a PNG from some place. */ +extern BITMAP *load_png_pf(PACKFILE *fp, RGB *pal); + +/* Load a PNG from memory. */ +extern BITMAP *load_memory_png(AL_CONST void *buffer, int buffer_size, RGB *pal); + +/* Save a bitmap to disk in PNG format. */ +extern int save_png(AL_CONST char *filename, BITMAP *bmp, AL_CONST RGB *pal); + +/* Adds `PNG' to Allegro's internal file type table. + * You can then just use load_bitmap and save_bitmap as usual. + */ +extern void register_png_file_type(void); + +/* Register an datafile type ID with Allegro, so that when an object + * with that type ID is encountered while loading a datafile, that + * object will be loaded as a PNG file. + */ +extern void register_png_datafile_object(int id); + +/* This is supposed to resemble jpgalleg_init in JPGalleg 2.0, just in + * case you are lazier than lazy. It contains these 3 lines of code: + * register_png_datafile_object(DAT_ID('P','N','G',' ')); + * register_png_file_type(); + * return 0; + */ +extern int loadpng_init(void); + + +#ifdef __cplusplus +} +#endif + +#endif /* _included_loadpng_h */ diff --git a/lib/loadpng/regpng.c b/lib/loadpng/regpng.c new file mode 100644 index 0000000..323422b --- /dev/null +++ b/lib/loadpng/regpng.c @@ -0,0 +1,68 @@ +/* loadpng, Allegro wrapper routines for libpng + * by Peter Wang (tjaden@users.sf.net). + * + * This file is hereby placed in the public domain. + */ + + +#include +#include "loadpng.h" + + + +/* register_png_file_type: + */ +void register_png_file_type(void) +{ + register_bitmap_file_type("png", load_png, save_png); +} + + + +/* register_png_datafile_object: + */ + +static void *load_datafile_png(PACKFILE *f, long size) +{ + BITMAP *bmp; + void *buffer; + + buffer = malloc(size); + if (!buffer) + return NULL; + + if (pack_fread(buffer, size, f) != size) { + free(buffer); + return NULL; + } + + bmp = load_memory_png(buffer, size, NULL); + + free(buffer); + + return bmp; +} + +static void destroy_datafile_png(void *data) +{ + if (data) { + destroy_bitmap((BITMAP *)data); + } +} + +void register_png_datafile_object(int id) +{ + register_datafile_object(id, load_datafile_png, destroy_datafile_png); +} + + + +/* loadpng_init: + * This is supposed to resemble jpgalleg_init in JPGalleg 2.0. + */ +int loadpng_init(void) +{ + register_png_datafile_object(DAT_ID('P','N','G',' ')); + register_png_file_type(); + return 0; +} diff --git a/lib/loadpng/savepng.c b/lib/loadpng/savepng.c new file mode 100644 index 0000000..fbac626 --- /dev/null +++ b/lib/loadpng/savepng.c @@ -0,0 +1,306 @@ +/* loadpng, Allegro wrapper routines for libpng + * by Peter Wang (tjaden@users.sf.net). + * + * This file is hereby placed in the public domain. + */ + + +#include +#include +#include "loadpng.h" + + + +/* write_data: + * Custom write function to use Allegro packfile routines, + * rather than C streams. + */ +static void write_data(png_structp png_ptr, png_bytep data, png_uint_32 length) +{ + PACKFILE *f = (PACKFILE *)png_get_io_ptr(png_ptr); + if ((png_uint_32)pack_fwrite(data, length, f) != length) + png_error(png_ptr, "write error (loadpng calling pack_fwrite)"); +} + +/* Don't think Allegro has any problem with buffering + * (rather, Allegro provides no way to flush packfiles). + */ +static void flush_data(png_structp png_ptr) { (void)png_ptr; } + + + +/* save_indexed: + * Core save routine for 8 bpp images. + * */ +static int save_indexed(png_structp png_ptr, BITMAP *bmp) +{ + ASSERT(bitmap_color_depth(bmp) == 8); + + if (is_memory_bitmap(bmp)) { /* fast path */ + int y; + + for (y=0; yh; y++) { + png_write_row(png_ptr, bmp->line[y]); + } + + return 1; + } + else { /* generic case */ + unsigned char *rowdata; + int x, y; + + rowdata = (unsigned char *)malloc(bmp->w * 3); + if (!rowdata) + return 0; + + for (y=0; yh; y++) { + unsigned char *p = rowdata; + + for (x=0; xw; x++) { + *p++ = getpixel(bmp, x, y); + } + + png_write_row(png_ptr, rowdata); + } + + free(rowdata); + + return 1; + } +} + + + +/* save_rgb: + * Core save routine for 15/16/24 bpp images (original by Martijn Versteegh). + */ +static int save_rgb(png_structp png_ptr, BITMAP *bmp) +{ + AL_CONST int depth = bitmap_color_depth(bmp); + unsigned char *rowdata; + int y, x; + + ASSERT(depth == 15 || depth == 16 || depth == 24); + + rowdata = (unsigned char *)malloc(bmp->w * 3); + if (!rowdata) + return 0; + + for (y=0; yh; y++) { + unsigned char *p = rowdata; + + if (depth == 15) { + for (x = 0; x < bmp->w; x++) { + int c = getpixel(bmp, x, y); + *p++ = getr15(c); + *p++ = getg15(c); + *p++ = getb15(c); + } + } + else if (depth == 16) { + for (x = 0; x < bmp->w; x++) { + int c = getpixel(bmp, x, y); + *p++ = getr16(c); + *p++ = getg16(c); + *p++ = getb16(c); + } + } + else { /* depth == 24 */ + for (x = 0; x < bmp->w; x++) { + int c = getpixel(bmp, x, y); + *p++ = getr24(c); + *p++ = getg24(c); + *p++ = getb24(c); + } + } + + png_write_row(png_ptr, rowdata); + } + + free(rowdata); + + return 1; +} + + + +/* save_rgba: + * Core save routine for 32 bpp images. + */ +static int save_rgba(png_structp png_ptr, BITMAP *bmp) +{ + unsigned char *rowdata; + int x, y; + + ASSERT(bitmap_color_depth(bmp) == 32); + + rowdata = (unsigned char *)malloc(bmp->w * 4); + if (!rowdata) + return 0; + + for (y=0; yh; y++) { + unsigned char *p = rowdata; + + for (x=0; xw; x++) { + int c = getpixel(bmp, x, y); + *p++ = getr32(c); + *p++ = getg32(c); + *p++ = getb32(c); + *p++ = geta32(c); + } + + png_write_row(png_ptr, rowdata); + } + + free(rowdata); + + return 1; +} + + + +/* save_png: + * Writes a non-interlaced, no-frills PNG, taking the usual save_xyz + * parameters. Returns non-zero on error. + */ +static int really_save_png(PACKFILE *fp, BITMAP *bmp, AL_CONST RGB *pal) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + int depth; + int colour_type; + + depth = bitmap_color_depth(bmp); + if (depth == 8 && !pal) + return -1; + + /* Create and initialize the png_struct with the + * desired error handler functions. + */ + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, + (void *)NULL, NULL, NULL); + if (!png_ptr) + goto Error; + + /* Allocate/initialize the image information data. */ + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + goto Error; + + /* Set error handling. */ + if (setjmp(png_ptr->jmpbuf)) { + /* If we get here, we had a problem reading the file. */ + goto Error; + } + + /* Use packfile routines. */ + png_set_write_fn(png_ptr, fp, (png_rw_ptr)write_data, flush_data); + + /* Set the image information here. Width and height are up to 2^31, + * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on + * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, + * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, + * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or + * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST + * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. + */ + if (depth == 8) + colour_type = PNG_COLOR_TYPE_PALETTE; + else if (depth == 32) + colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + else + colour_type = PNG_COLOR_TYPE_RGB; + + /* Set compression level. */ + png_set_compression_level(png_ptr, _png_compression_level); + + png_set_IHDR(png_ptr, info_ptr, bmp->w, bmp->h, 8, colour_type, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, + PNG_FILTER_TYPE_BASE); + + /* Set the palette if there is one. Required for indexed-color images. */ + if (colour_type == PNG_COLOR_TYPE_PALETTE) { + png_color palette[256]; + int i; + + for (i = 0; i < 256; i++) { + palette[i].red = _rgb_scale_6[pal[i].r]; /* 64 -> 256 */ + palette[i].green = _rgb_scale_6[pal[i].g]; + palette[i].blue = _rgb_scale_6[pal[i].b]; + } + + /* Set palette colors. */ + png_set_PLTE(png_ptr, info_ptr, palette, 256); + } + + /* Optionally write comments into the image ... Nah. */ + + /* Write the file header information. */ + png_write_info(png_ptr, info_ptr); + + /* Once we write out the header, the compression type on the text + * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or + * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again + * at the end. + */ + + /* Save the data. */ + switch (depth) { + case 8: + if (!save_indexed(png_ptr, bmp)) + goto Error; + break; + case 15: + case 16: + case 24: + if (!save_rgb(png_ptr, bmp)) + goto Error; + break; + case 32: + if (!save_rgba(png_ptr, bmp)) + goto Error; + break; + default: + ASSERT(FALSE); + goto Error; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + return 0; + + Error: + + if (png_ptr) { + if (info_ptr) + png_destroy_write_struct(&png_ptr, &info_ptr); + else + png_destroy_write_struct(&png_ptr, NULL); + } + + return -1; +} + + +int save_png(AL_CONST char *filename, BITMAP *bmp, AL_CONST RGB *pal) +{ + PACKFILE *fp; + int result; + + ASSERT(filename); + ASSERT(bmp); + + fp = pack_fopen(filename, "w"); + if (!fp) + return -1; + + acquire_bitmap(bmp); + result = really_save_png(fp, bmp, pal); + release_bitmap(bmp); + + pack_fclose(fp); + + return result; +} diff --git a/src/DMX_Remake/DMX_Remake.sln b/src/DMX_Remake/DMX_Remake.sln new file mode 100644 index 0000000..0b47b4f --- /dev/null +++ b/src/DMX_Remake/DMX_Remake.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DMX_Remake", "DMX_Remake\DMX_Remake.vcxproj", "{A8D1503A-D533-4888-ADAE-1F6F0AC667B6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8D1503A-D533-4888-ADAE-1F6F0AC667B6}.Debug|Win32.ActiveCfg = Debug|Win32 + {A8D1503A-D533-4888-ADAE-1F6F0AC667B6}.Debug|Win32.Build.0 = Debug|Win32 + {A8D1503A-D533-4888-ADAE-1F6F0AC667B6}.Release|Win32.ActiveCfg = Release|Win32 + {A8D1503A-D533-4888-ADAE-1F6F0AC667B6}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/DMX_Remake/DMX_Remake/DMX_Remake.vcxproj b/src/DMX_Remake/DMX_Remake/DMX_Remake.vcxproj new file mode 100644 index 0000000..732b81b --- /dev/null +++ b/src/DMX_Remake/DMX_Remake/DMX_Remake.vcxproj @@ -0,0 +1,114 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {A8D1503A-D533-4888-ADAE-1F6F0AC667B6} + DMX_Remake + + + + Application + true + MultiByte + + + Application + false + true + MultiByte + + + + + + + + + + + + + DMX_Debug + D:\svn\dmx\trunk\lib\allegro\include;D:\svn\dmx\trunk\lib\fmodapi375win\api\inc;D:\svn\dmx\trunk\lib\libpng\include\libpng12;D:\svn\dmx\trunk\lib\libpng\include;D:\svn\dmx\trunk\lib\loadpng;D:\svn\dmx\trunk\src\headers;$(IncludePath) + D:\svn\dmx\trunk\lib\allegro\lib;D:\svn\dmx\trunk\lib\fmodapi375win\api\lib;D:\svn\dmx\trunk\lib\libpng\lib;$(LibraryPath) + + + DMX + D:\svn\dmx\trunk\lib\allegro\include;D:\svn\dmx\trunk\lib\fmodapi375win\api\inc;D:\svn\dmx\trunk\lib\libpng\include\libpng12;D:\svn\dmx\trunk\lib\libpng\include;D:\svn\dmx\trunk\lib\loadpng;D:\svn\dmx\trunk\src\headers;$(IncludePath) + D:\svn\dmx\trunk\lib\allegro\lib;D:\svn\dmx\trunk\lib\fmodapi375win\api\lib;D:\svn\dmx\trunk\lib\libpng\lib;$(LibraryPath) + + + + Level3 + Disabled + _MBCS;DMXDEBUG;%(PreprocessorDefinitions) + + + true + alleg.lib;fmodvc.lib;winmm.lib;libpng.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + + + true + true + true + alleg.lib;fmodvc.lib;winmm.lib;libpng.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/DMX_Remake/DMX_Remake/DMX_Remake.vcxproj.filters b/src/DMX_Remake/DMX_Remake/DMX_Remake.vcxproj.filters new file mode 100644 index 0000000..ec066f7 --- /dev/null +++ b/src/DMX_Remake/DMX_Remake/DMX_Remake.vcxproj.filters @@ -0,0 +1,123 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {6978387f-133c-4bf3-91c3-3781a1da51d2} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + External Source Files + + + External Source Files + + + External Source Files + + + \ No newline at end of file diff --git a/src/headers/bookManager.h b/src/headers/bookManager.h new file mode 100644 index 0000000..78e5ede --- /dev/null +++ b/src/headers/bookManager.h @@ -0,0 +1,86 @@ +// bookManager.h implements bookkeeping for Dance Maniax +// source file created by Allen Seitz 3/6/2012 + +#ifndef _BOOKMANAGER_H_ +#define _BOOKMANAGER_H_ + +#include "common.h" + +struct DAILY_BOOKKEEP +{ + long int uptime; // total power-on time counted no matter what (in ms) + long int playtime; // counted while in certain game modes (in ms) + + long int coins; // coin switch hits which resulted in a credit + long int services; // service button hits which resulted in a credit + + long int logins; // player logins that day (including first time players) + long int nonLogins; // games played where the player opted out of login + + long int spGames; // singles play + long int dpGames; // doubles play + long int vpGames; // versus play + long int mpGames; // mission play + + DAILY_BOOKKEEP::DAILY_BOOKKEEP() + { + reset(); + } + + void DAILY_BOOKKEEP::reset() + { + uptime = playtime = 0; + coins = services = 0; + logins = nonLogins = 0; + spGames = dpGames = vpGames = mpGames = 0; + } +}; + +class BookManager +{ +public: + BookManager(); + + void resetData(); + // postcondition: sets all bookkeeping values to zero and all times to 1/1/70 + +private: + void loadData(); // called once by the constructor and never again + // postcondition: if bkeep.dat exists on disk, loads the previous values from it + + void saveData(); // called periodically by the logTime() function + // postcondition: writes current values to bkeep.dat (including newly initialized values) + +public: + void logCoin(bool wasService); + void logTime(int ms, int mode); + void logLogin(bool wasAnonymous); + void logMode(int mode); + // postcondition: logs whatever, however + + void forceBookkeepingSave() { saveData(); } + // precondition: only to be called from firstOperatorLoop(), for debugging purposes + + void nukeBookkeeping() { resetData(); saveData(); loadData(); saveData(); } + // precondition: to be called from exactly one place in the operator menu + + DAILY_BOOKKEEP getAllTime(int day) { return allTime[day]; } + DAILY_BOOKKEEP getThisWeek(int day) { return thisWeek[day]; } + +private: + DAILY_BOOKKEEP allTime[7]; + DAILY_BOOKKEEP thisWeek[7]; + + int lastPowerOnMonth; + int lastPowerOnDay; + int lastPowerOnYear; + int currentDay; // 0-6, used as an index into thisWeek[] + + int timeSinceLastSave; // incremented during logTime(), calls saveData() during next mode transition + + long countDaysIn(int year, int month, int day); + // precondition: year is >= 1900, month and day are also legal dates + // postcondition: returns the number of days since 1/1/1900 +}; + +#endif \ No newline at end of file diff --git a/src/headers/common.h b/src/headers/common.h new file mode 100644 index 0000000..3eb37ee --- /dev/null +++ b/src/headers/common.h @@ -0,0 +1,468 @@ +// common.h declares some common stuff that I need in most source files +// file created by Allen Seitz 7/18/2009 + +#ifndef _COMMONDMXH_H_ +#define _COMMONDMXH_H_ + +#include +#include +#include +#include + +#pragma warning(disable : 4312) +#include "allegro.h" // allegro library +//#include "apeg.h" // an add on for mpeg and ogg support +#pragma warning(default : 4312) + +#define UTIME unsigned long int + +#define UNUSED(var) (void)(var) + +// use this while developing the game to disable most types of audio +#ifdef DMXDEBUG +#define DONT_WANNA_HEAR_IT 0 +#else // and use this to ensure that release mode is never accidentally built without audio +#define DONT_WANNA_HEAR_IT 0 +#endif + +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 + +#define CURRENT_VERSION_NUMBER 1 + +// for the operator menu +#define WHITE makeacol(255,255,255, 255) +#define RED makeacol(255,32,32, 255) +#define GREEN makeacol(100,255,100, 255) +#define BLUE makeacol(100,100,255, 255) +#define PURPLE makeacol(255,64,255, 255) +#define GET_ON_OFF(b) (b ? "ON" : "OFF") +#define GET_ON_COLOR(b) (b ? RED : WHITE) +#define GET_LAMP_STRING(n) (n == 1 ? "RED" : n == 2 ? "BLUE" : n == 3 ? "PURPLE" : "OFF") +#define GET_LAMP_COLOR(n) (n == 1 ? RED : n == 2 ? BLUE : n == 3 ? PURPLE : WHITE) + +#define DEFAULT_SONGS_PER_SET 3 +#define DEFAULT_COINS_PER_CREDIT 2 + +// generally useful functions +#define SUBTRACT_TO_ZERO(x,y) (x = y > x ? 0 : x - y) +#define WEIGHTED_AVERAGE(a,b,weight,denominator) ( ((a*weight) + (b*(denominator-weight))) / denominator ) +#define BPM_TO_MSEC(bpm) (60000.0/bpm) +#define MSEC_TO_BPM(msec) (60000.0/msec) + +int pickRandomInt(int argc, ...); +int getValueFromRange(int min, int max, int percent); + +void addLeadingZeros(char* buffer, int desiredLength); +// precondition: buffer is a null-terminated string and is at least desiredLength in size +// postcondition: moves the string down and adds '0' chars. For example "1234" -> "0001234" + +// used by the lightning effect, other places +struct AL_POINT +{ + int x; + int y; + + AL_POINT() { x = y = 0; } +}; + +// game modes +#define SPLASH 0 +#define WARNING 1 +#define SONGWHEEL 2 +#define GAMEPLAY 3 +#define RECORDING 4 +#define MAINMENU 5 +#define RESULTS 6 +#define TESTMODE 7 +#define ATTRACT 8 +#define LOGIN 9 +#define GAMEOVER 10 +#define ERRORMODE 11 +#define VIDEOTEST 12 +#define CAUTIONMODE 13 +#define NONSTOP 14 +#define FAILURE 15 +#define PLAYERSELECT 16 +#ifdef DMXDEBUG + #define FIRST_GAME_MODE SONGWHEEL + //#define FIRST_GAME_MODE PLAYERSELECT + //#define FIRST_GAME_MODE ATTRACT +#else + #define FIRST_GAME_MODE ATTRACT +#endif + +// play modes, for logging with bookkeeping +#define SINGLES_PLAY 1 +#define DOUBLES_PLAY 2 +#define VERSUS_PLAY 3 +#define MISSION_PLAY 4 + +// global error codes used by error mode +#define UNSET_MACHINE_SETTINGS 3001 +#define BOOKKEEPING_NOT_FOUND 3002 +#define CLEARED_MACHINE_SETTINGS 3003 +#define SONG_DATA_INCOMPLETE 4001 +#define ERROR_DECODING_VIDEO 4002 +#define INVALID_SONG_ID 4003 +#define PLAYER_PREFS_LOST 5001 +#define PLAYER_SCORES_LOST 5002 + +void globalError(long errorCode, char* errorInfo); +void songIndexError(int id); + +// implement safe asset loading +BITMAP* loadImage(const char* filename); + +// implement a weak file backup system +FILE* safeLoadFile(char* filename); +void safeCloseFile(FILE* fp, char* filename); +char calculateChecksum(char* filename); // calculates the checksum for any file and should return 0 on any legit file +bool fileExists(char* filename); +void makeBackupFile(char* filename); + +int checkFileVersion(FILE* fp, char* expected); + +// implement some debug rendering +void renderWhiteLetter(char letter, int x, int y); +void renderWhiteString(const char* string, int x, int y); +void renderWhiteNumber(int number, int x, int y); + +// implement real text rendering; colors 0-3 = white, green, pink, blue +void renderTextString(const char* string, int x, int y, int width, int height); +void renderBoldString(const unsigned char* string, int x, int y, int maxWidth, bool fixedWidth, int color = 0); +void renderBoldString(const char* string, int x, int y, int maxWidth, bool fixedWidth, int color = 0); +void renderArtistString(const unsigned char* string, int x, int y, int width, int height); +void renderArtistString(const char* string, int x, int y, int width, int height); +void renderScoreString(const char* string, int x, int y, int width, int height); +void renderScoreNumber(int number, int x, int y, int requiredDigits); +void renderNameString(const char* string, int x, int y, int color); +void renderNameLetter(char letter, int x, int y, int color); + +// implement double buffering +class RenderingManager +{ +public: + void Initialize(); + + BITMAP* m_backbuf; + BITMAP* m_backbuf1; + BITMAP* m_backbuf2; + + BITMAP* m_whiteFont; + BITMAP* m_textFont; + BITMAP* m_boldFont[4]; + BITMAP* m_artistFont; + BITMAP* m_scoreFont; + BITMAP* m_nameFont[3]; + + BITMAP* m_temp64; // used for rendering effects on arrows + + int currentPage; + + void flip(); + void screenshot(); + void renderWipeAnim(int frame); // frame must be 0-14 + void dimScreen(int percent); // must be 0-100 +}; + +void replaceColor(BITMAP* bmp, long col1, long col2); +// precondition: bmp is 32 bit +// postcondition: any instances of col1 are replaced by col2 + + +// implement a global sfx system +#define TOTAL_NUM_SFX 160 +class EffectsManager +{ +public: + void initialize(); + + void playSample(int which); + void announcerQuip(int which); + bool announcerQuipChance(int which, int percent); + + SAMPLE* basic_sfx[TOTAL_NUM_SFX]; + SAMPLE* currentAnnouncer; + + EffectsManager::EffectsManager() + { + currentAnnouncer = 0; + } + + void announceCombo(int combo) + { + static int comboGroups[10][4] = + { + { 134, 134, 134, 134 }, // 100 "CHARISMA!" + { 142, 142, 145, 145 }, + { 137, 137, 141, 141 }, + { 124, 124, 124, 124 }, // 400 "wow lots of combos" + { 147, 147, 149, 149 }, + { 125, 125, 125, 125 }, // 600 "the way of the combo is still continuing" + { 147, 147, 124, 124 }, + { 149, 149, 125, 125 }, + { 148, 148, 148, 148 }, // 900 "everybody is getting hot" + { 147, 134, 124, 125 }, // combo fever + }; + int hundred = MIN(9, (combo/100)-1); + announcerQuip( pickRandomInt(4, comboGroups[hundred][0], comboGroups[hundred][1], comboGroups[hundred][2], comboGroups[hundred][3]) ); + } +}; + +#define SFX_CREDIT_BEGIN 2 +#define SFX_START_BUTTON 3 +#define SFX_MENU_MOVE 4 +#define SFX_MENU_STUCK 5 +#define SFX_MENU_PICK 6 +#define SFX_NONE 7 +#define SFX_EAMUSE_DIAL 8 +#define SFX_CROWD_HAPPY 9 +#define SFX_CROWD_SCARED 10 +#define SFX_MENU_PICK2 11 +#define SFX_DIFF 12 // a bit of a 'ting' +#define SFX_MOD_MOVE 14 +#define SFX_FORCEFUL_SELECTION 15 +#define SFX_TIMER_LOW 16 +#define SFX_SOUND_CHECK1 17 +#define SFX_SOUND_CHECK2 18 +#define SFX_SONGWHEEL_MOVE 19 +#define SFX_SONGWHEEL_PICK 20 +#define SFX_SONGWHEEL_APPEAR 21 +#define SFX_RESULTS_APPEAR 22 +#define SFX_NAME_CURSOR_MOVE 23 +#define SFX_NAME_CURSOR_WAGGLE 24 +#define SFX_FAILURE_WHOOSH 25 +#define SFX_GAME_OVER_EXPLOSION 27 +#define SFX_FAILURE_ANIMATION 29 +#define SFX_DMX2ND_APPEND 30 +#define SFX_MENU_SORT 31 +#define SFX_COURSE_APPEAR 32 +#define SFX_COURSE_PREVIEW_LOAD 33 +#define SFX_PIN_DIGIT 34 +#define SFX_NAME_ENTRY_BACKSPACE 35 +#define SFX_COURSE_ENTRY_CONFIRM 36 +#define SFX_LOUD_BELL 37 +#define SFX_CROWD_CHEERING 39 +#define SFX_CROWD_BOOING 40 +#define SFX_FULL_COMBO_SPLASH 157 +#define SFX_BATTERY_ZAP 158 +#define SFX_BATTERY_RECOVER 159 +#define SFX_DIFFICULTY_MOVE SFX_MENU_MOVE +#define SFX_CREDIT SFX_SONGWHEEL_PICK +// be sure to update TOTAL_NUM_SFX above + +#define BGM_TITLE 0 +#define BGM_DEMO 1 +#define BGM_MODE 2 +#define BGM_RESULT 3 +#define BGM_GAMEOVER 4 + +#define GUY_GAME_BEGIN pickRandomInt(2, 45, 114) +#define GUY_NONSTOP_BEGIN pickRandomInt(2, 47, 113) +#define GUY_EVERYBODY_WAITING 84 +#define GUY_LOGIN pickRandomInt(4, 42, 46, 49, 84) +#define GUY_SONGWHEEL pickRandomInt(2, 80, 87) + +#define GUY_RESULT_S pickRandomInt(2, 100, 101) +#define GUY_RESULT_B pickRandomInt(2, 97, 104) +#define GUY_RESULT_C pickRandomInt(2, 103, 108) +#define GUY_RESULT_D pickRandomInt(2, 91, 95) + +#define GUY_EARN_EXTRA pickRandomInt(2, 115, 85) // one more time, made just for you, +#define GUY_EARN_SPECIAL_EXTRA pickRandomInt(2, 82, 81) // wow youre a real dancer, can you do this, +#define GUY_STAGE_FAILED pickRandomInt(2, 66, 67) +#define GUY_SPECIAL_GAMEOVER pickRandomInt(2, 110, 138) + +////////////////////////////////////////////////////////////////////////////// +// implement the chart structure +////////////////////////////////////////////////////////////////////////////// +enum NOTE_TYPE +{ + TAP = 1, + JUMP = 2, + //HOLD_START = 3, // columns == which columns to hold + //HOLD_END = 4, // columns == which columns to release + SHOCK = 5, + NEW_SECTION = 6, // new banner/gimmick time + END_SONG = 7, // new song segment time + BPM_CHANGE = 8, // color = new BPM instead + SCROLL_STOP = 9, // color = stop length instead +}; + +// used while recording new charts +//#define CHART_RECORDING + +// the charts being played are made out of these two structs +struct ARROW +{ + UTIME timing; + int type; // one of the enumerated note types + int color; // 0-3, a color offset for the animation + char columns[4]; // which columns this note appears in + char judgement; // the judgement earned for this arrow + + ARROW() + { + timing = type = color = judgement = 0; + columns[0] = columns[1] = columns[2] = columns[3] = -1; + } +}; + +struct FREEZE +{ + UTIME startTime; + UTIME endTime1; + UTIME endTime2; + char columns[2]; + UTIME meltTime1; // counts milliseconds while this isn't held + UTIME meltTime2; // counts milliseconds while this isn't held + char isHeld; // set to 1 while this freeze is being held + char judgement; // the judgement earned for this arrow + + FREEZE() + { + startTime = 0; + endTime1 = endTime2 = 0; + columns[0] = columns[1] = -1; + meltTime1 = meltTime2 = isHeld = 0; + judgement = 0; + } +}; + +#define HOLD_PASSED_BY -1 +#define HOLD_RENDERED 0 +#define HOLD_TOO_EARLY 1 + +#define HOLD_UNTOUCHED 0 +#define HOLD_BRIGHT 1 +#define HOLD_MELT 2 + +#define HOLD_DMX_RED 0 +#define HOLD_DMX_BLUE 1 +#define HOLD_DMX_GOLD 2 +#define HOLD_DMX_BRIGHT 3 +#define HOLD_DMX_MELT 4 + +int calculateArrowColor(unsigned long timing, int timePerBeat); +// precondition: timePerBeat is not 0 +// returns: 0 = 1/4 beat, 1 = 1/8th beat, 2 = 1/16th beat, else 3 + + +////////////////////////////////////////////////////////////////////////////// +// song list +////////////////////////////////////////////////////////////////////////////// +struct SongEntry +{ + long songID; + int minBPM; + int maxBPM; + char mildSingle; + char wildSingle; + char mildDouble; + char wildDouble; + char version; // for sorting + int numPlays; // the only non-static data in this structure + char unlockFlag; + bool isNew; + + SongEntry::SongEntry() + { + songID = 0; + isNew = false; + } + + void SongEntry::initialize(long id, int min, int max, char ms, char ws, char md, char wd, char v) + { + songID = id; + minBPM = min; + maxBPM = max; + mildSingle = ms; + wildSingle = ws; + mildDouble = md; + wildDouble = wd; + version = v; + numPlays = 0; + unlockFlag = 0; + } +}; + +#define SINGLE_MILD 0 +#define SINGLE_WILD 1 +#define SINGLE_ANOTHER 2 // wanted to have "LAZY" and "CRAZY", but there's no need +#define DOUBLE_MILD 10 +#define DOUBLE_WILD 11 +#define DOUBLE_ANOTHER 12 + +#define UNLOCK_METHOD_NONE 0 +#define UNLOCK_METHOD_EXTRA_STAGE 1 +#define UNLOCK_METHOD_CLEAR 2 +#define UNLOCK_METHOD_SPECIAL 3 +#define UNLOCK_METHOD_ROULETTE 4 + +int songID_to_listID(int songID); +int listID_to_songID(int index); +// precondition: the index or songID is valid +// postcondition: returns the matching value. For example: 101 <-> 0 and 102 <-> 1 + +int getChartIndexFromType(int type); +// precondition: type is one of the above enumerations +// postcondition: returns an index 0-6 that is used a few places + + +////////////////////////////////////////////////////////////////////////////// +// sound effects +////////////////////////////////////////////////////////////////////////////// +void playSFXOnce(SAMPLE* sample); +// precondition: sample is not NULL +// postcondition: calls an Allegro function to mix the audio automatically + +int getSampleLength(SAMPLE* sample); +// precondition: sample is not NULL +// postcondition: returns the length of the sample in seconds + + +////////////////////////////////////////////////////////////////////////////// +// gameplay elements +////////////////////////////////////////////////////////////////////////////// + +// normal judgements +#define MARVELLOUS 1 +#define PERFECT 2 +#define GREAT 3 +#define GOOD 4 +//#define BAD 5 +#define MISS 6 +#define OK 7 +#define NG 8 +#define IGNORED 9 +#define UNSET 0 + +// different combo colors +#define COMBO_SHADOW 0 +#define COMBO_GREAT 1 +#define COMBO_PERFECT 2 +#define COMBO_MARVELOUS 3 +#define COMBO_MISS 4 + + +////////////////////////////////////////////////////////////////////////////// +// score related +////////////////////////////////////////////////////////////////////////////// +#define GRADE_NONE 0 +#define GRADE_F 1 +#define GRADE_E 2 +#define GRADE_D 3 +#define GRADE_C 4 +#define GRADE_B 5 +#define GRADE_A 6 +#define GRADE_AA 7 +#define GRADE_AAA 8 + +#define STATUS_NONE 0 +#define STATUS_FAILED 1 +#define STATUS_CLEARED 2 +#define STATUS_FULLCOMBO 3 +#define STATUS_PERFECT 4 + +#endif // end include guard \ No newline at end of file diff --git a/src/headers/dwi_read.h b/src/headers/dwi_read.h new file mode 100644 index 0000000..4f1fcdd --- /dev/null +++ b/src/headers/dwi_read.h @@ -0,0 +1,26 @@ +// dwi_read.h reads a .DWI file, for older DMX simfiles +// source file created 1/18/12 by Catastrophe + +#ifndef _DWI_READ_H_ +#define _DWI_READ_H_ + +#include + +#include "common.h" + +int readDWI(std::vector *chart, std::vector *holds, int songID, int chartType); +// precondition: it is safe to overwrite chart and holds, and songID and chartType exist +// postcondition: will write new values for chart and holds, or leave them untouched if there is an error +// returns: the maximum score in dance points for this chart + +int readDWI2P(std::vector *chart, std::vector *holds, int songID, int chartType); +// precondition: it is safe to overwrite chart and holds, and songID and chartType exist +// postcondition: calls readDWI, then moves columns 0-3 to 4-7 +// returns: the maximum score in dance points for this chart + +int readDWICenter(std::vector *chart, std::vector *holds, int songID, int chartType); +// precondition: it is safe to overwrite chart and holds, and songID and chartType exist +// postcondition: calls readDWI, then moves columns 0-3 to 4-7 +// returns: the maximum score in dance points for this chart + +#endif \ No newline at end of file diff --git a/src/headers/gameStateManager.h b/src/headers/gameStateManager.h new file mode 100644 index 0000000..b4444ef --- /dev/null +++ b/src/headers/gameStateManager.h @@ -0,0 +1,410 @@ +// gameStateManager.h declares a "class" that manages the gameplay state for the gameplayMode, gameplayRendering, and gameplayDirector objects +// source file created by Allen Seitz 12/20/09 + +#ifndef _GAMESTATEVARS_H_ +#define _GAMESTATEVARS_H_ + +#include "common.h" +#include + +#include "fmod.h" // an audio library used for playing keysounds + +/* +#ifdef __cplusplus +extern "C" { +#endif +//#include "logg.h" // an addon for ogg support +#ifdef __cplusplus +} +#endif +//*/ + +#define MSETTING_FILENAME "conf/msetting.dat" + +#define MODE_NONSTOP 0 +#define MODE_FREE 1 +#define MODE_MISSION 2 + +class GameStateManager +{ +public: + + // program flow data + int g_currentGameMode; + int g_gameModeTransition; + int g_errorCode; + char g_errorInfo[256]; + + // the current BGM + FSOUND_SAMPLE* currentSongSample; + int currentSong; + int currentSongLength; + int currentSongChannel; // used by FMOD hardware functions + int bgmGap; // how many ms early or late to start the bgm + + // non-player game state data + bool isSolo; // should not be used in this program + bool isDoubles; + bool isVersus; + int currentStage; + int numCoins; + int currentGameType; // 0 = nonstop, 1 = free, 2 = mission + + // operator data + bool isInitialized; + int numSongsPerSet; + int numCoinsPerCredit; + bool isFreeplay; + bool isVersusPremium; + bool isDoublePremium; + bool isEventMode; + + class PLAYER + { + public: + // chart data + std::vector currentChart; + std::vector freezeArrows; + int currentNote; // the index of the closest note that hasn't passed + int lastLateNote; // the index of the last note that hasn't been scored + int currentFreeze; // the index of the next freeze arrow to render + UTIME timeElapsed; // the current time position into the currentChart + + // scroll rate + int scrollRate; // the current BPM + int newScrollRate; // what the BPM is changing to + UTIME stopTime; // the timeElapsed that the tempo stop happened at + UTIME stopLength; // the milliseconds that the current tempo stop lasts for + UTIME bpmUpdateTimer; // allows the BPM to change smoothly from scrollRate to newScrollRate + int speedMod; // the current speed mod times 10 (for 1.5, 2.5, etc) + + // animation timers and states (mostly timers) + UTIME stepZoneBeatTimer; + UTIME stepZoneBlinkTimer; + UTIME stepZoneTimePerBeat; + bool everyOtherBeat; // DMX needs to blink only every other beat + UTIME stepZoneResizeTimers[10]; + int colorCycle; // [0..3], rotates the arrows between the four colors + int judgementTime; // time since the last judgement was registered + int lastJudgement; // what the most recent Judgement was + int columnJudgeTime[10]; + int columnJudgement[10]; + int laneFlareColors[10]; + UTIME laneFlareTimers[10]; + UTIME shockAnimTimer; // greater than 0 while the shock anim is playing + UTIME drummaniaCombo[4]; // each digit of the combo bounces independently + + // player's score + int displayCombo; + int comboColor; + int currentSongCombo; + int currentSongMaxCombo; + + // lifebar related + int lifebarPercent; // a number from 0 (empty) to 1000 (full) + int lifebarLives; // when using the battery, lives lift + bool useBattery; // switches the lifebar mode + + // special trick rendering modes + bool drummaniaMode; // pretty much switches the combo and enables "column judgements" + bool danceManiaxMode; // added for Dance Maniax (Yes, this is technically a modifier. Without it the game renders DDR!) + + // modifiers + bool darkModifier; // hides the step zone + unsigned char reverseModifier; // 8 bits for which columns are on reverse + unsigned char suddenModifier; // 8 bits for which columns are on sudden + unsigned char hiddenModifier; // 8 bits for which columns are on hidden + bool stealthModifier; // special rendering mode + char arrangeModifier; // 1 = mirror, 2 = upside-down + + // segment choosing logic + int stagesPlayed[7]; // stages picked by the player + int stagesLevels[7]; + + PLAYER::PLAYER() + { + resetAll(); + resetStages(); + } + + void nextStage() + { + currentNote = lastLateNote = currentFreeze = 0; + timeElapsed = 0; + + stopTime = 0; + stopLength = 0; + bpmUpdateTimer = 0; + + for ( int i = 0; i < 10; i++ ) + { + stepZoneResizeTimers[i] = 0; + columnJudgeTime[i] = 0; + columnJudgement[i] = 0; + laneFlareColors[i] = 0; + laneFlareTimers[i] = 0; + } + + // animation timers and states (mostly timers) + stepZoneBeatTimer = 0; + stepZoneBlinkTimer = 0; + stepZoneTimePerBeat = 400; + colorCycle = 0; + judgementTime = 0; + lastJudgement = 0; + shockAnimTimer = 0; + drummaniaCombo[0] = drummaniaCombo[1] = drummaniaCombo[2] = drummaniaCombo[3] = 0; + + //comboColor = 1; + currentSongCombo = 0; + currentSongMaxCombo = 0; + + // lifebar related + lifebarPercent = 0; + } + + void resetAll() + { + nextStage(); + + // scroll rate + scrollRate = 150; + newScrollRate = 150; + speedMod = 10; + + // player's score + displayCombo = 0; + comboColor = 1; + + // lifebar related + lifebarLives = 4; + useBattery = false; + + // tricky Variables + drummaniaMode = false; + danceManiaxMode = true; + darkModifier = false; + reverseModifier = 0; + suddenModifier = 0; + hiddenModifier = 0; + stealthModifier = false; + arrangeModifier = 0; + } + + void resetStages() + { + for ( int i = 0; i < 7; i++ ) + { + stagesPlayed[i] = -1; + stagesLevels[i] = 0; + } + } + + bool isColumnReversed(char col) + { + if ( col == -1 ) + { + return false; + } + return (reverseModifier & (1 << col)) > 0; + } + }; + + // per-player data + PLAYER player[2]; + + GameStateManager::GameStateManager() + { + player[0].resetAll(); + player[0].resetStages(); + player[1].resetAll(); + player[1].resetStages(); + + // program flow data + g_currentGameMode = FIRST_GAME_MODE; + g_gameModeTransition = 1; + g_errorCode = 0; + +#ifdef CHART_RECORDING + g_currentGameMode = RECORDING; +#endif + + // directly audio related + currentSong = 0; + currentSongSample = NULL; + currentSongLength = -1; + currentSongChannel = -1; + + // global game state + isSolo = false; + isDoubles = false; + isVersus = false; + currentStage = 0; + numCoins = 0; + currentGameType = 1; + if ( g_currentGameMode == SONGWHEEL ) + { + //isVersus = true; // for debugging - otherwise this cannot happen + } + + // operator settings + isInitialized = false; + numSongsPerSet = DEFAULT_SONGS_PER_SET; + numCoinsPerCredit = DEFAULT_COINS_PER_CREDIT; + isFreeplay = false; + isVersusPremium = false; + isDoublePremium = false; + isEventMode = false; + } + + void loadSong(int songID) + { + char filename[] = "DATA/audio/112.mp3"; + filename[11] = (songID/100 % 10) + '0'; + filename[12] = (songID/10 % 10) + '0'; + filename[13] = (songID % 10) + '0'; + + killSong(); + currentSongSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, filename, FSOUND_NORMAL | FSOUND_MPEGACCURATE, 0, 0); + if ( currentSongSample == NULL ) + { + allegro_message("Unable to load song %s!", filename); + } + currentSong = songID; + currentSongLength = 0; // TODO: figure out how to calculate the length of a stream? or just look it up + } + + void killSong() + { + if ( currentSongSample != NULL ) + + { + FSOUND_Sample_Free(currentSongSample); + currentSongChannel = -1; + currentSong = -1; + } + currentSongSample = NULL; + } + + void playSong() + { + currentSongChannel = FSOUND_PlaySound(FSOUND_FREE, currentSongSample); + FSOUND_SetVolume(currentSongChannel, DONT_WANNA_HEAR_IT ? 0 : 128); // '64' leaves room to grow/shrink (turn up other volume controls) + FSOUND_SetLoopMode(currentSongChannel, currentSong < 100 ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF); // menu music should loop + } + + void pauseSong() + { + FSOUND_StopSound(currentSongChannel); + } + + void setSongPosition(int offset) + { + unsigned int numSamples = FSOUND_GetCurrentPosition(currentSongChannel); + if ( numSamples == 0 ) + { + return; + } + + unsigned int samplesPerSec = numSamples/player[0].timeElapsed; + + player[0].timeElapsed += offset; + player[1].timeElapsed += offset; + FSOUND_SetCurrentPosition(currentSongChannel, samplesPerSec*player[0].timeElapsed); + } + + void setSongVolume(unsigned char vol) + { + FSOUND_SetVolume(currentSongChannel, (int)vol); // volume is 0-255, the int is misleading + } + + bool isSongPlaying() + { + if ( currentSongChannel == -1 ) + { + return false; + } + return FSOUND_IsPlaying(currentSongChannel) != 0; + } + + void loadOperatorSettings() + { + FILE* fp = NULL; + int n = 0; + + // does bookkeeping exist? + if ( (fp = safeLoadFile(MSETTING_FILENAME)) == NULL ) + { + return; // failure to load operator settings requires them to be reset manually for safety + } + + // read a short version number + int vnum = checkFileVersion(fp, "DMXM"); + if ( vnum != CURRENT_VERSION_NUMBER ) + { + TRACE("Wrong msettings version number."); + return; // later when multiple versions exist, ideas for converting them + } + + // okay, read everything + fread(&numSongsPerSet, sizeof(long), 1, fp); + fread(&numCoinsPerCredit, sizeof(long), 1, fp); + fread(&n, sizeof(long), 1, fp); + isFreeplay = n != 0; + fread(&n, sizeof(long), 1, fp); + isVersusPremium = n != 0; + fread(&n, sizeof(long), 1, fp); + isDoublePremium = n != 0; + + isInitialized = true; + fclose(fp); + } + + void saveOperatorSettings() + { + FILE* fp = NULL; + int n = 0; + + if ( fopen_s(&fp, MSETTING_FILENAME, "wb") != 0 ) + { + TRACE("UNABLE TO SAVE BOOKKEEPING"); + return; // this is bad + } + + // write the version + fprintf(fp, "DMXM"); + int vnum = CURRENT_VERSION_NUMBER; + fwrite(&vnum, sizeof(long), 1, fp); + fwrite(&numSongsPerSet, sizeof(long), 1, fp); + fwrite(&numCoinsPerCredit, sizeof(long), 1, fp); + n = isFreeplay ? 1 : 0; + fwrite(&n, sizeof(long), 1, fp); + n = isVersusPremium ? 1 : 0; + fwrite(&n, sizeof(long), 1, fp); + n = isDoublePremium ? 1 : 0; + fwrite(&n, sizeof(long), 1, fp); + + safeCloseFile(fp, MSETTING_FILENAME); + } + + const char* getErrorString() + { + switch (g_errorCode) + { + case 3000: return "UNSPECIFIC NVRAM ERROR"; + case UNSET_MACHINE_SETTINGS: return "MACHINE SETTINGS NEED TO BE SET BEFORE FIRST USE."; + case BOOKKEEPING_NOT_FOUND: return "BOOKKEEPING DATA NOT FOUND."; + case CLEARED_MACHINE_SETTINGS: return "THE MACHINE SETTINGS HAVE BEEN CLEARED."; + case 4000: return "UNSPECIFIC SONG DATA ERROR"; + case SONG_DATA_INCOMPLETE: return "SONG DATA INCOMPLETE"; + case ERROR_DECODING_VIDEO: return "VIDEO DECODE ERROR"; + case INVALID_SONG_ID: return "INVALID SONG ID"; + case 5000: return "UNSPECIFIC PLAYER DATA ERROR"; + case PLAYER_PREFS_LOST: return "PLAYER RECORD LOST"; + case PLAYER_SCORES_LOST: return "PLAYER SCORE DATA LOST"; + } + return "(no error description)"; + } +}; + +#endif // end include guard diff --git a/src/headers/gameplayRendering.h b/src/headers/gameplayRendering.h new file mode 100644 index 0000000..0bd479d --- /dev/null +++ b/src/headers/gameplayRendering.h @@ -0,0 +1,218 @@ +// gameplayRendering.h contains declarations used in rendering the game loop +// source file created by Allen Seitz 12-20-09 + +#ifndef _GAMEPLAYRENDERING_H_ +#define _GAMEPLAYRENDERING_H_ + +#include "common.h" + +////////////////////////////////////////////////////////////////////////////// +// Constants +////////////////////////////////////////////////////////////////////////////// +#define JUDGEMENT_DISPLAY_TIME 600 +#define HIT_FLASH_DISPLAY_TIME 300 +#define SHOCK_ANIM_TIME 750 + +#define DRUMMANIA_COMBO_BOUNCE_TIME 250 + +// these are specifically for DMX +#define JUDGEMENT_Y 222 +#define REVERSE_JUDGEMENT_Y 331 + +// these are for the step zone animation when a panel is pressed +#define RESIZE_TIME 100 +#define GET_RESIZE(time) (100-(25*time/RESIZE_TIME)) + +static int columnX[5][10] = +{ + { 0, 8, 1, 2, 9, 3, 4, 5, 6, 7 }, // doubles (and singles 1P) + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, // solo + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, // solo + doubles + { 4, 5, 6, 7, 8, 9, 0, 1, 2, 3 }, // singles (2P) + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 }, // "column" modifer +}; + +////////////////////////////////////////////////////////////////////////////// +// Constants - specifically for proceedurally generated graphics +////////////////////////////////////////////////////////////////////////////// +#define END_SECTION_COLOR1 makeacol(255, 32, 32, 255) +#define END_SECTION_COLOR2 makeacol(196, 32, 32, 255) +#define BPM_CHANGE_COLOR1 makeacol(32, 255, 32, 255) +#define BPM_CHANGE_COLOR2 makeacol(32, 196, 32, 255) +#define SCROLL_STOP_COLOR1 makeacol(32, 32, 255, 255) +#define SCROLL_STOP_COLOR2 makeacol(32, 32, 196, 255) +#define COLOR_WHITE makeacol(255, 255, 255, 255) +#define SHOCK_OUTLINE_COLOR 0x88EEFF + +static int arrowColors[9][3] = +{ + { 255, 128, 128 }, // red(ish) + { 128, 128, 255 }, // blue + { 164, 255, 255 }, // green + { 255, 255, 164 }, // yellow + { 255, 128, 128 }, // repeat of the first color (for blending) + { 196, 255, 96 }, // the freeze arrow color + { 196, 255, 96 }, // the freeze arrow color (for blending) + { 100, 100, 255 }, // the shock arrow color + { 100, 100, 255 }, // the shock arrow color (for blending) +}; + +static int drummaniaColors[7][3] = +{ + { 114, 121, 255 }, // hi hat + { 255, 229, 38 }, // snare + { 255, 0, 80 }, // bass + { 0, 255, 33 }, // low tom + { 255, 0, 0 }, // hi tom + { 127, 201, 255 }, // cymbal + { 255, 255, 255 }, // the shock arrow color +}; + +static int beatmaniaColors[3][3] = +{ + { 240, 240, 240 }, // white + { 130, 130, 255 }, // blue + { 255, 255, 255 }, // the shock arrow color +}; + +static int flareColors[3][3] = +{ + { 255, 255, 255 }, // white + { 255, 239, 128 }, // yellow + { 128, 255, 140 }, // green +}; + +static int dmxHoldColors[5][4][3] = +{ + { + { 255, 216, 0 }, // red notes + { 20, 20, 60 }, + { 255, 38, 0 }, + { 255, 176, 173 }, + }, + { + { 255, 216, 0 }, // blue notes + { 60, 20, 20 }, + { 0, 38, 255 }, + { 76, 255, 231 }, + }, + { + { 255, 216, 0 }, // gold notes (not used) + { 60, 60, 20 }, + { 255, 255, 38 }, + { 255, 231, 76 }, + }, + { + { 255, 255, 196 }, // being held + { 60, 60, 60 }, + { 255, 255, 80 }, + { 180, 255, 100 }, + }, + { + { 128, 128, 128 }, // melted + { 60, 20, 20 }, + { 0, 38, 0 }, + { 128, 128, 128 }, + }, +}; + +// a constant in the blending function for the arrow colors +#define ARROW_BRIGHTNESS 164 + + +////////////////////////////////////////////////////////////////////////////// +// General Functions +////////////////////////////////////////////////////////////////////////////// +int getNumColumns(); +int getColumnOffsetX_DDR(int column); +int getColumnOffsetX_DM(int column); +int getColumnOffsetX_BM(int column); +int getColumnOffsetX_DMX(int column); + +int getLeftmostColumnX_DMX(int player); + +void loadGameplayGraphics(); +// precondition: called only once when the program starts +// postcondition: allocates a bunch of memory that isn't freed until the program quits + + +////////////////////////////////////////////////////////////////////////////// +// Primary Functions - these call the mode-specific functions +////////////////////////////////////////////////////////////////////////////// +void renderGameplay(); +// precondition: called only once per frame after the logic is complete +// postcondition: rm.m_backbuf contains a fresh image of the current game state + +void renderStageDisplay(); +// precondition: gs.currentStage is 0-6 or the game is in the demo loop +// postcondition: renders a bitmap, top center, telling the player the stage number + +void renderGrade(int player); +// precondition: gs.player[player] is crrently tracking the grade +// postcondition: grade is rendered to the screen + +void renderSpeedMod(int scrollRate, int speedMod, int x, int y); +// +// + +void renderLifebar(int player); +// +// + +void renderFullComboAnim(int x, int time, int step); +// +// + +void renderEndSongMarker(int x1, int x2, int y); +void renderBPMMarker(int x1, int x2, int y, int bpm); +void renderTempoStopMarker(int x1, int x2, int y, int len); +// +// + + +////////////////////////////////////////////////////////////////////////////// +// Mode-Specific Functions +////////////////////////////////////////////////////////////////////////////// +int getStepZonePos_DDR(char player); +void renderStepZone_DDR(int player); +void renderFlaresAndFlashes_DDR(int player); +void renderStepZonePiece_DDR(BITMAP* src, int x, int y, int scale); + +// a generic "renderNote" function for debugging +void renderDebugNote(struct ARROW n, int x, int y); + +// helper functions for renderChart() +void renderDDRChart(int player); +void renderDDRNote(int player, struct ARROW n, int x, int y); +void renderDDRArrow(int player, int column, int color, int judgement, int x, int y); // called only by renderDDRNote() +char renderDDRHoldNote(int player, struct FREEZE f, UTIME time, long pausedTime); // returns HOLD_PASSED_BY, HOLD_RENDERED, or HOLD_TOO_EARLY +void renderDDRHoldNoteBody(int column, int x, int topy, int bot, int color ); // called only by renderDDRHoldNote() + +void renderDDRJudgement(int judgement, int time, int x, int y); +void renderDDRCombo(int combo, int time, int centerX, int color); +void renderDDRComboNum(int num, int size, int color, int x, int y); // called only by renderDDRCombo() + +void renderDMChart(int player); +void renderDMNote(int player, struct ARROW n, int x, int y); +void renderDMChip(int player, int column, int color, int judgement, int x, int y); +char renderDMHoldNote(struct FREEZE f, UTIME time, long pausedTime); +void renderColumnJudgements(int player); +void renderDMCombo(int combo, int player); +void renderDMComboNum(int num, int x, int y); // called only by renderDMCombo() + +void renderDMXChart(int player); +void renderDMXNote(int player, struct ARROW n, int y); +void renderDMXArrow(int player, int column, int color, int judgement, int x, int y); // called only by renderDMXNote() +char renderDMXHoldNote(int player, struct FREEZE f, UTIME time, long pausedTime); // returns HOLD_PASSED_BY, HOLD_RENDERED, or HOLD_TOO_EARLY +void renderDMXHoldNoteBody(int column, int x, int topy, int bot, int color, int player); +void renderDMXCombo(int combo, int time, int centerX, int color); +void renderDMXJudgement(int judgement, int time, int x, int y); + +void renderOverFrameDMX(); +void renderUnderFrameDMX(); +void renderStepZoneDMX(int player); +void renderStepLaneDMX(int x, int bgColor, int outlineColor); +void renderDMXFlaresAndFlashes(int player); +void renderBatteryLivesDMX(int player); + +#endif // end include guard \ No newline at end of file diff --git a/src/headers/inputManager.h b/src/headers/inputManager.h new file mode 100644 index 0000000..ebfc9af --- /dev/null +++ b/src/headers/inputManager.h @@ -0,0 +1,106 @@ +// inputManger.h declares a class that handles all types of user input +// file created by Allen Seitz 10/12/2009 + +#ifndef _INPUTMANAGER_H_ +#define _INPUTMANAGER_H_ + +#include "common.h" + +// key states for the panelStates array +#define HELD_UP 0 +#define JUST_UP -1 +#define HELD_DOWN 2 +#define JUST_DOWN 1 + +// column IDs +#define LL_1P 0 +#define UL_1P 1 +#define UR_1P 2 +#define LR_1P 3 +#define MENU_LEFT_1P 10 +#define MENU_RIGHT_1P 11 +#define MENU_START_1P 14 + +#define LL_2P 4 +#define UL_2P 5 +#define UR_2P 6 +#define LR_2P 7 +#define MENU_LEFT_2P 12 +#define MENU_RIGHT_2P 13 +#define MENU_START_2P 15 + +#ifdef DMXDEBUG + #define MENU_TEST 16 + #define MENU_SERVICE 17 +#else // the j-pac is annoying + #define MENU_TEST 17 + #define MENU_SERVICE 16 +#endif +#define MENU_COIN 18 + +#define BLUE_SENSOR_1PL0 19 +#define BLUE_SENSOR_1PL1 20 +#define BLUE_SENSOR_1PR0 21 +#define BLUE_SENSOR_1PR1 22 +#define BLUE_SENSOR_2PL0 23 +#define BLUE_SENSOR_2PL1 24 +#define BLUE_SENSOR_2PR0 25 +#define BLUE_SENSOR_2PR1 26 + +#define NUM_INPUTS 27 + +class InputManager +{ +public: + InputManager(); + + void updateKeyStates(UTIME dt); + // precondition: this is called every logic frame, regardless of game mode + // postcondition: panelsDown and panelHoldLength are updated + + char getKeyState(int column); + // precondition: column is [0..10], 0-9 = panels, 10 = start + // postcondition: returns a panelState + + bool isKeyDown(int column); + // precondition: updateKeyStates() has been called at least once + // postcondition: returns true if the state is DOWN or JUST_DOWN + + bool isKeyInUse(int column); + // precondition: isSolo and isDoubles are set + // postcondition: returns true this column is used in the current mode + + int getHoldLength(int column); + int getReleaseLength(int column); + // precondition: updateKeyStates() has been called at least once + // postcondition: returns a number of milliseconds, 0-30000 (capped) + + void setCooldownTime(int milliseconds) { m_cooldownThreshold = milliseconds; } + // precondition: milliseconds should be [0..150] or bad things will happen + // postcondition: if milliseconds > 0 then "ghosting" will be less of a problem + +protected: + char m_panelStates[NUM_INPUTS]; + int m_panelHoldLength[NUM_INPUTS]; + int m_panelReleaseLength[NUM_INPUTS]; + + int m_cooldownThreshold; // needed to prevent input flickering (as infrareds are likely to do) + + // {qw,az,sx} = 1P, arrow keys for 2P, enter for 'start', see source file + int m_keyMapping[NUM_INPUTS]; + + void processDanceManiaxBlueSensors(); + // precondition: called only from updateKeyStates() + // postcondition: reads the inputs from BLUE_SENSOR_* and alters the state of inputs L?_#P + // NOTE: when installed on a machine, inputs L?_#P are not supposed to be wired. Use the blue sensors. + + void processDanceManiaxBlueSensorHelper(int a, int b, int blue); + // postcondition: 'a' and 'b' inputs each control 'blue' + // example parameters: BLUE_SENSOR_1PL0, BLUE_SENSOR_1PL1, LL_1P + + int getShortestReleaseLength(int column); + // precondition: updateKeyStates() has been called at least once + // postcondition: for blue columns, returns the lower of the two hold lengths +}; + +#endif // end include guard \ No newline at end of file diff --git a/src/headers/scoreManager.h b/src/headers/scoreManager.h new file mode 100644 index 0000000..c7c9de0 --- /dev/null +++ b/src/headers/scoreManager.h @@ -0,0 +1,215 @@ +// scoreManager.h implements a class to record scores for Dance Maniax +// source file created by Allen Seitz 2/12/2012 + +#ifndef _SCOREMANAGER_H_ +#define _SCOREMANAGER_H_ + +#include "common.h" + +extern int NUM_SONGS; + +struct SONG_RECORD +{ + int songID; // + int chartID; // for example, SINGLE_WILD + int perfects; // + int greats; // + int goods; // + int misses; // + int maxCombo; // this is saved as each song is played + int points; // dance points + int maxPoints; // this is the maximum dance points (max score is 1 mil) + char status; // for example, STATUS_NONE, STATUS_CLEAR + char grade; // for example, GRADE_A + long time; // when this score was set (seconds since Jan 1, 1970) + char unlockStatus; // normally 0, but could be nonzero for an unlock + + SONG_RECORD::SONG_RECORD() + { + resetData(); + } + + void SONG_RECORD::resetData() + { + songID = chartID = 0; + perfects = greats = goods = misses = 0; + maxCombo = points = maxPoints = status = 0; + grade = 0; + time = 0; + unlockStatus = 0; + } + + int SONG_RECORD::getDancePoints() + { + return perfects*2 + greats; + } + + int SONG_RECORD::getScore() + { + if ( maxPoints == 0 ) + { + if ( getDancePoints() != 0 ) + { + return 5; // this indicates a serious error in the data permanence, and player data may be lost! + } + return 0; + } + return (getDancePoints() * 100000 / maxPoints) * 10; + } + + int SONG_RECORD::calculateStatus() + { + if ( maxPoints == 0 ) + { + status = STATUS_NONE; // can happen, for example 2P during a single player game + } + else if ( misses == 0 ) + { + status = STATUS_FULLCOMBO; + if ( greats == 0 ) + { + status = STATUS_PERFECT; + } + } + else if ( getScore() >= 700000 ) + { + status = STATUS_CLEARED; + } + else + { + status = STATUS_FAILED; + } + + return status; + } + + int SONG_RECORD::calculateGrade() + { + if ( maxPoints == 0 ) + { + status = GRADE_NONE; // can happen, for example 2P during a single player game + } + if ( getScore() >= 990000 ) + { + grade = GRADE_AAA; + } + else if ( getScore() >= 950000 ) + { + grade = GRADE_AA; + } + else if ( getScore() >= 900000 ) + { + grade = GRADE_A; + } + else if ( getScore() >= 800000 ) + { + grade = GRADE_B; + } + else if ( getScore() >= 700000 ) + { + grade = GRADE_C; + } + else if ( getScore() >= 600000 ) + { + grade = GRADE_D; + } + else + { + grade = GRADE_E; + } + + return grade; + } + + int calculatePoints() + { + return points = perfects*2 + greats; + } +}; + +struct PLAYER_DATA +{ + bool isLoggedIn; + char displayName[8]; + char pinDigits[4]; + SONG_RECORD currentSet[7]; // these are the songs which have been played during just this credit + SONG_RECORD** allTime; // these are the records, all-time, for this player (or blank) + long numPlaysSP; + long numPlaysDP; + + PLAYER_DATA::PLAYER_DATA() + { + allTime = NULL; + } + + void PLAYER_DATA::allocateMemory() + { + if ( allTime == NULL ) + { + allTime = (SONG_RECORD **)malloc(NUM_SONGS * sizeof(SONG_RECORD)); + + for ( int i = 0; i < NUM_SONGS; i++ ) + { + allTime[i] = (SONG_RECORD *)malloc(NUM_SONGS * 6); + } + } + } + + void PLAYER_DATA::resetData() + { + static char chartTypes[6] = { SINGLE_MILD, SINGLE_WILD, SINGLE_ANOTHER, DOUBLE_MILD, DOUBLE_WILD, DOUBLE_ANOTHER }; + isLoggedIn = false; + displayName[0] = 0; + + for ( int i = 0; i < 7; i++ ) + { + currentSet[i].resetData(); + } + + for ( int i = 0; i < NUM_SONGS; i++ ) + for ( int chart = 0; chart < 6; chart++ ) + { + allTime[i][chart].resetData(); + allTime[i][chart].songID = listID_to_songID(i); + allTime[i][chart].chartID = chartTypes[chart]; + } + + numPlaysSP = numPlaysDP = 0; + } +}; + +class ScoreManager +{ +public: + ScoreManager::ScoreManager(); + + void resetData(); + // postcondition: zeros out both players + + bool loadPlayerFromDisk(char* name, char side); + // precondition: name is 1-8 letters [0-9,A-Z], side is 0-1 + // postcondition: loads the player if it exists and sets isLoggedIn to true on success + + void savePlayersToDisk(); + // postcondition: for each player, if isLoggedIn is true, creates a new file on disk + + bool doesPlayerNameExist(char* name); + // precondition: name is 8 or less in length and contains only symbols allowed in filenames + // postcondition: returns true if PLAYERS/name.prefs exists + + bool isPinCorrect(int pin, int side); + // precondition: pin is [0..9999] + // postcondition: returns true only if a player is loaded and this is their pin + +private: + void mergeCurrentScores(PLAYER_DATA &p, int side); + // postcondition: reconciles player[side].currentSet with player[side].allTime (basically) + + void savePlayerToDisk(PLAYER_DATA &p); + // postcondition: writes or rewrites players/NAME.score on disk + +public: + PLAYER_DATA player[2]; +}; + +#endif \ No newline at end of file diff --git a/src/headers/songwheelMode.h b/src/headers/songwheelMode.h new file mode 100644 index 0000000..8648f1a --- /dev/null +++ b/src/headers/songwheelMode.h @@ -0,0 +1,71 @@ +// songwheelMode.h declares functions for the songwheel +// source file created by Allen Seitz 9-17-2011 + +#ifndef _SONGWHEELMODE_H_ +#define _SONGWHEELMODE_H_ + +#include "common.h" + +////////////////////////////////////////////////////////////////////////////// +// Constants +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// Primary Functions - these call the mode-specific functions +////////////////////////////////////////////////////////////////////////////// +void firstSongwheelLoop(); +// +// + +void mainSongwheelLoop(UTIME dt); +// +// + +void renderSongwheelLoop(); +// precondition: called only once per frame after the logic is complete +// postcondition: rm.m_backbuf contains an image of the current game state + +void renderIntroAnim(int percent); +// precondition: called only once per frame when the mode is first initialized +// postcondition: rm.m_backbuf contains a fresh image + +////////////////////////////////////////////////////////////////////////////// +// Mode-Specific Functions +////////////////////////////////////////////////////////////////////////////// +void prepareForSongwheelRotation(); +// +// + +void postSongwheelRotation(); +// +// + +void updateSongwheelRotation(UTIME dt); +// +// + +void renderBanner(int textureID, int coordsIndex, bool isNew); +// +// + +void renderPickedSongs(int percent); +// precondition: relies on the GameStateManager stagesPlayed[] array +// postcondition: song banners have been rendered to the top right corner + +void renderTitleArea(int percent); +// +// + +void renderDifficultyStars(int x, int y, char type, char level); +// precondition: type = mild (0) or wild (1), level = 1-10 +// postcondition: renders stars to the backbuf + +void renderTimeRemaining(int xcoord = 5, int ycoord = 42); +// +// + +void renderLoginStats(int x, int side); +// +// + +#endif // end include guard \ No newline at end of file diff --git a/src/headers/specialEffects.h b/src/headers/specialEffects.h new file mode 100644 index 0000000..81780ab --- /dev/null +++ b/src/headers/specialEffects.h @@ -0,0 +1,35 @@ +// specialEffects.h implements functions to do some special rendering tasks +// file created by Allen Seitz 12-02-09 + +#ifndef _SPECIALEFFECTS_H_ +#define _SPECIALEFFECTS_H_ + +#pragma warning(disable : 4312) +#include // allegro library +//#include "apeg.h" // an add on for mpeg and ogg support +#pragma warning(default : 4312) + +void renderLightningBeamHorizontal(int x, int width, int y1, int y2, int seed, int endStyle); +void renderLightningBeamVertical(int y, int height, int x1, int x2, int seed, int endStyle); +// precondition: seed is [0..1023], x1 < x2, and y1 < y2, endstyle is an enum +// postcondition: a lightning bolt that will fill the area is rendered to the backbuf + +#define LIGHTNING_END_START 0 +#define LIGHTNING_END_ANY 1 +#define LIGHTNING END_FORK 2 + +void drawLightningLine(int x1, int y1, int x2, int y2, int brightness); +// precondition: called only as a helper function by another 'lightning' function +// postcondition: does the work of rendering pixels to the backbuf + +void drawLightningPixel(BITMAP *bmp, int x, int y, int color); +void drawLightningPixelThick(BITMAP *bmp, int x, int y, int color); +void drawLightningPixelOld(BITMAP *bmp, int x, int y, int brightness); +// precondition: called only as a helper function by drawLightningLine +// postcondition: actually does the work of rendering pixels to the backbuf + +void renderBannerAnim(); +// precondition: the next banner is already determined +// postcondition: renders the next step of the banner animation + +#endif // end include guard \ No newline at end of file diff --git a/src/headers/videoManager.h b/src/headers/videoManager.h new file mode 100644 index 0000000..af53315 --- /dev/null +++ b/src/headers/videoManager.h @@ -0,0 +1,106 @@ +// videoManager.h declares a class which implements the background videos +// source file created by Allen Seitz 6/27/2012 + +#ifndef _VIDEOMANAGER_H_ +#define _VIDEOMANAGER_H_ + +#include "common.h" + +// this structure is borrowed from DMX2ja directly and has not been fully reverse engineered +struct MOVIE_SEQ_STEP +{ +public: + short int alpha; // unsure, always 0 + short int beta; // flags: always 0, 1, 4, or 7 + char gamma; // unsure, always 0 + char delta; // flags: always 0 or 1 + short int epsilon; // + short int zeta; // unsure, always 0 + short int eta; // unsure, always 0 + short int theta; // unsure, always 0 + short int omega; // how to play the video: 1-5 + short int timing; // timing is in ticks, 300 ticks per second + char filename[14]; // which file to load + + MOVIE_SEQ_STEP::MOVIE_SEQ_STEP() + { + clear(); + } + + void MOVIE_SEQ_STEP::clear() + { + alpha = beta = gamma = delta = epsilon = zeta = omega = 0; + timing = -1; + memset(filename, 0, 14); + } +}; + +class VideoManager +{ +public: + VideoManager::VideoManager(); + + void update(UTIME dt, bool skipLoad); + // precondition: dt is in milliseconds, the video script should already be loaded + // postcondition: advances the movie script + // NOTE: skipLoad will prevent loading the next frame from disk, if applicable + + void reset() + { + currentTime = currentStep = currentFrame = 0; + frameData = NULL; + msPerFrame = msSinceFrame = playDirection = numFrames = 0; + isStopped = true; + } + + void play() + { + isStopped = false; + } + + void stop() + { + isStopped = true; + } + + // used by the attract loop for extra long movies with hardcoded lengths + void alternateSetNumFrames(int frames) + { + numFrames = frames; + } + + void renderToSurface(BITMAP* surface, int x, int y); + void renderToSurfaceStretched(BITMAP* surface, int x, int y, int width, int height); + // precondition: surface is 320x192 for the unstreteched version + // postcondition: surface has been modified + + void loadScript(const char* filename); + // precondition: file exists on disk, or else movie playback will stop + // postcondition: this movie will replace any currently playing movie, also calls reset() + +private: + struct MOVIE_SEQ_STEP script[100]; // nothing will ever be larger, probably + int currentTime; // counts milliseconds as they pass + int currentStep; // which script step we're on + int currentFrame; // for the current movie, which frame we're on + BITMAP* frameData; // the pixel contents of the current frame + int msPerFrame; // basically the framerate for the current movie + int msSinceFrame; // time since the last frame change + int playDirection; // which direction to step for the current movie + int numFrames; // the number of frames in the currently loaded video + bool isStopped; // pause movie playback + + bool haxLowerFramerate; // option for less stressful video loading + bool haxNoVideos; // option for computers which just cannot handle it + BITMAP* m_noVideo; // used with haxNoVideos + + void loadFrame(); + // precondition: should only be called from within update() + // postcondition: frameData has been updated from disk or set to NULL + + int calculateNumFrames(); + // precondition: the current movie exists + // postcondition: returns 75 or 80 +}; + +#endif // end include guard \ No newline at end of file diff --git a/src/source/ScoreManager.cpp b/src/source/ScoreManager.cpp new file mode 100644 index 0000000..0f1cdce --- /dev/null +++ b/src/source/ScoreManager.cpp @@ -0,0 +1,283 @@ +// scoreManager.cpp implements a class to record scores for Dance Maniax +// source file created by Allen Seitz 2/12/2012 + +#include +#include + +#include "scoreManager.h" + +#include "GameStateManager.h" +extern GameStateManager gs; + +ScoreManager::ScoreManager() +{ +} + +void ScoreManager::resetData() +{ + player[0].allocateMemory(); + player[1].allocateMemory(); + player[0].resetData(); + player[1].resetData(); +} + +bool ScoreManager::loadPlayerFromDisk(char* name, char side) +{ + FILE* fp = NULL; + struct PLAYER_DATA& p = side == 0 ? player[0] : player[1]; + + char baseFilename[64] = "PLAYERS/"; + char prefsFilename[64] = ""; + char scoreFilename[64] = ""; + + // calculate the filenames + for ( int i = 0; i < 8; i++ ) + { + baseFilename[8+i] = name[i]; //can't strcat because it isn't null terminated + } + strcat_s(prefsFilename, 64, baseFilename); + strcat_s(prefsFilename, 64, ".prefs"); + strcat_s(scoreFilename, 64, baseFilename); + strcat_s(scoreFilename, 64, ".score"); + + // load the preferences + if ( (fp = safeLoadFile(prefsFilename)) == NULL ) + { +#ifdef _DEBUG + allegro_message("Error reading: %s", prefsFilename); +#endif + globalError(PLAYER_PREFS_LOST, prefsFilename); + return false; + } + + // read a short version number + int vnum = checkFileVersion(fp, "DMXp"); + if ( vnum != CURRENT_VERSION_NUMBER ) + { + globalError(PLAYER_PREFS_LOST, prefsFilename); + } + + fread(&p.displayName, sizeof(char), 8, fp); + fread(&p.pinDigits, sizeof(char), 4, fp); + fread(&p.numPlaysSP, sizeof(long), 1, fp); + fread(&p.numPlaysDP, sizeof(long), 1, fp); + + fclose(fp); + + // then read all the scores to the scores file + if ( (fp = safeLoadFile(scoreFilename)) == NULL ) + { +#ifdef _DEBUG + allegro_message("Error reading: %s", scoreFilename); +#endif + globalError(PLAYER_SCORES_LOST, scoreFilename); + return false; + } + + vnum = checkFileVersion(fp, "DMXs"); + if ( vnum != CURRENT_VERSION_NUMBER ) + { + globalError(PLAYER_SCORES_LOST, scoreFilename); + } + + for ( int i = 0; i < NUM_SONGS; i++ ) // loop through each song + for ( int j = 0; j < 6; j++ ) // loop through each chart + { + SONG_RECORD temp; + if ( fread(&temp.songID, sizeof(int), 1, fp) == 0 || fread(&temp.chartID, sizeof(int), 1, fp) == 0 ) + { + i = NUM_SONGS; // file ended short. use the default blank scores for any new songs added to the DB + j = 6; + break; + } + fread(&temp.grade, sizeof(char), 1, fp); + fread(&temp.status, sizeof(char), 1, fp); + fread(&temp.time, sizeof(long), 1, fp); + fread(&temp.maxCombo, sizeof(int), 1, fp); + fread(&temp.points, sizeof(int), 1, fp); + fread(&temp.maxPoints, sizeof(int), 1, fp); + fread(&temp.perfects, sizeof(int), 1, fp); + fread(&temp.greats, sizeof(int), 1, fp); + fread(&temp.goods, sizeof(int), 1, fp); + fread(&temp.misses, sizeof(int), 1, fp); + fread(&temp.unlockStatus, sizeof(char), 1, fp); + + int songIndex = songID_to_listID(temp.songID); + int chartIndex = getChartIndexFromType(temp.chartID); + + if ( songIndex >= 0 && chartIndex >= 0 ) // otherwise would indicate a song which was cut + { + p.allTime[songIndex][chartIndex] = temp; + } + else + { + TRACE("Unable to use high score for song %d chart %d.", temp.songID, temp.chartID); + } + } + + fclose(fp); + return true; +} + +void ScoreManager::savePlayersToDisk() +{ + for ( int side = 0; side < 2; side++ ) + { + if ( player[side].isLoggedIn ) + { + mergeCurrentScores(player[side], side); + savePlayerToDisk(player[side]); + } + } +} + +void ScoreManager::mergeCurrentScores(PLAYER_DATA &p, int side) +{ + UNUSED(side); + for ( int i = 0; i < 7; i++ ) + { + if ( p.currentSet[i].songID < 100 ) + { + continue; + } + + int songindex = songID_to_listID(p.currentSet[i].songID); + int chartindex = getChartIndexFromType(p.currentSet[i].chartID); + + if ( songindex == -1 || chartindex == -1 ) + { + continue; // it may be possible to play non-existant songs (somehow) + } + + // compare status, grade, maxcombo, and score separately + bool changedSomething = false; + if ( p.allTime[songindex][chartindex].status < p.currentSet[i].status ) + { + p.allTime[songindex][chartindex].status = p.currentSet[i].status; + changedSomething = true; + } + if ( p.allTime[songindex][chartindex].grade < p.currentSet[i].grade ) + { + p.allTime[songindex][chartindex].grade = p.currentSet[i].grade; + changedSomething = true; + } + if ( p.allTime[songindex][chartindex].maxCombo < p.currentSet[i].maxCombo ) + { + p.allTime[songindex][chartindex].maxCombo = p.currentSet[i].maxCombo; + changedSomething = true; + } + if ( p.allTime[songindex][chartindex].points < p.currentSet[i].points || p.allTime[songindex][chartindex].maxPoints != p.currentSet[i].maxPoints ) + { + p.allTime[songindex][chartindex].maxPoints = p.currentSet[i].maxPoints; + p.allTime[songindex][chartindex].points = p.currentSet[i].points; + p.allTime[songindex][chartindex].perfects = p.currentSet[i].perfects; + p.allTime[songindex][chartindex].greats = p.currentSet[i].greats; + p.allTime[songindex][chartindex].goods = p.currentSet[i].goods; + p.allTime[songindex][chartindex].misses = p.currentSet[i].misses; + changedSomething = true; + } + if ( changedSomething ) + { + p.allTime[songindex][chartindex].time = time(NULL); + } + + // updating the unlocks doesn't update the timestamp (though that probably happened) + if ( p.allTime[songindex][chartindex].unlockStatus < p.currentSet[i].unlockStatus ) + { + p.allTime[songindex][chartindex].unlockStatus = p.currentSet[i].unlockStatus; + } + } +} + +bool ScoreManager::doesPlayerNameExist(char* name) +{ + FILE* fp = NULL; + char filename[64] = "PLAYERS/"; + strcat_s(filename, 64, name); + strcat_s(filename, 64, ".prefs"); + if ( fopen_s(&fp, filename, "rb") != 0 ) // only care if the player exists, not if the file is corrupt + { + return false; + } + fclose(fp); + return true; +} + +bool ScoreManager::isPinCorrect(int pin, int side) +{ + if ( player[side].pinDigits[3] == pin % 10 && + player[side].pinDigits[2] == (pin/10) % 10 && + player[side].pinDigits[1] == (pin/100) % 10 && + player[side].pinDigits[0] == (pin/1000) % 10 ) + { + return true; + } + return false; +} + +void ScoreManager::savePlayerToDisk(PLAYER_DATA &p) +{ + FILE* fp = NULL; + char baseFilename[64] = "PLAYERS/"; + char prefsFilename[64] = ""; + char scoreFilename[64] = ""; + + // calculate the filenames + for ( int i = 0; i < 8; i++ ) + { + baseFilename[8+i] = p.displayName[i]; //can't strcat because it isn't null terminated + } + strcat_s(prefsFilename, 64, baseFilename); + strcat_s(prefsFilename, 64, ".prefs"); + strcat_s(scoreFilename, 64, baseFilename); + strcat_s(scoreFilename, 64, ".score"); + + // first wirte the name, pin, and general stats to the prefs file + if ( fopen_s(&fp, prefsFilename, "wb") != 0 ) + { + allegro_message("Error saving: %s", prefsFilename); + return; + } + + fprintf(fp, "DMXp"); + int vnum = CURRENT_VERSION_NUMBER; + fwrite(&vnum, sizeof(long), 1, fp); + + fwrite(&p.displayName, sizeof(char), 8, fp); + fwrite(&p.pinDigits, sizeof(char), 4, fp); + fwrite(&p.numPlaysSP, sizeof(long), 1, fp); + fwrite(&p.numPlaysDP, sizeof(long), 1, fp); + + safeCloseFile(fp, prefsFilename); + + // then write all the scores to the scores file + if ( fopen_s(&fp, scoreFilename, "wb") != 0 ) + { + allegro_message("Error saving: %s", scoreFilename); + return; + } + + fprintf(fp, "DMXs"); + vnum = CURRENT_VERSION_NUMBER; + fwrite(&vnum, sizeof(long), 1, fp); + + for ( int i = 0; i < NUM_SONGS; i++ ) // loop through each song + for ( int j = 0; j < 6; j++ ) // loop through each chart + { + fwrite(&p.allTime[i][j].songID, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].chartID, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].grade, sizeof(char), 1, fp); + fwrite(&p.allTime[i][j].status, sizeof(char), 1, fp); + fwrite(&p.allTime[i][j].time, sizeof(long), 1, fp); + fwrite(&p.allTime[i][j].maxCombo, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].points, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].maxPoints, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].perfects, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].greats, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].goods, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].misses, sizeof(int), 1, fp); + fwrite(&p.allTime[i][j].unlockStatus, sizeof(char), 1, fp); + } + + safeCloseFile(fp, scoreFilename); +} diff --git a/src/source/VideoManager.cpp b/src/source/VideoManager.cpp new file mode 100644 index 0000000..a616ae2 --- /dev/null +++ b/src/source/VideoManager.cpp @@ -0,0 +1,198 @@ +// videoManager.cpp implements a class which implements the background videos +// source file created by Allen Seitz 6/27/2012 + +#include +#include "videoManager.h" + +VideoManager::VideoManager() +{ + haxLowerFramerate = haxNoVideos = false; + m_noVideo = loadImage("DATA/gameplay/no_video.png"); + + if ( fileExists("videofix") ) + { + haxLowerFramerate = true; + } + if ( fileExists("novideo") ) + { + haxNoVideos = true; + } + reset(); +} + +void VideoManager::update(UTIME dt, bool skipLoad) +{ + bool reloadFrame = false; + if ( isStopped ) + { + return; + } + currentTime += dt; + msSinceFrame += dt; + + // check for a frame advance + if ( msSinceFrame >= msPerFrame && numFrames > 0 ) + { + currentFrame = playDirection == 1 ? currentFrame+1 : currentFrame-1; + currentFrame = (currentFrame + numFrames) % numFrames; // implement looping fowards and backwards + + msSinceFrame -= msPerFrame; + reloadFrame = true; + } + + // check for a script step advance + if ( (script[currentStep+1].timing != -1) && currentTime/10 >= script[currentStep+1].timing/3 ) // because there are 300 ticks per second + { + currentStep++; + + msSinceFrame = 0; + msPerFrame = 33; + currentFrame = 0; + playDirection = 1; // foward + reloadFrame = true; + numFrames = calculateNumFrames(); + + if ( numFrames <= 80 && haxLowerFramerate ) + { + msPerFrame = 100; // slow it down a bunch. sync be damned + } + if ( numFrames <= 80 && haxNoVideos ) + { + msPerFrame = 99999999; // STOP + } + } + + if ( reloadFrame && !skipLoad ) + { + loadFrame(); + } +} + +void VideoManager::renderToSurface(BITMAP* surface, int x, int y) +{ + //renderWhiteNumber(currentTime, 100, 84); + if ( frameData == NULL ) + { + renderWhiteString("stop", 100, 52); + return; + } + blit(frameData, surface, 0, 0, x, y, 320, 192); + + //renderWhiteNumber(script[currentStep].beta, 100, 52); + //renderWhiteNumber(numFrames, 120, 52); + //renderWhiteNumber(script[currentStep].delta, 200, 52); + //renderWhiteNumber(script[currentStep].timing/300, 100, 64); + //renderWhiteString(script[currentStep].filename, 200, 64); + //renderWhiteNumber(currentTime, 100, 84); +} + +void VideoManager::renderToSurfaceStretched(BITMAP* surface, int x, int y, int width, int height) +{ + if ( frameData == NULL ) + { + return; + } + stretch_blit(frameData, surface, 0, 0, 320, 192, x, y, width, height); +} + +void VideoManager::loadScript(const char* filename) +{ + reset(); + FILE* fp = NULL; + + if ( fopen_s(&fp, filename, "rb") != 0 ) + { + return; + } + + // load script steps until the file is exhausted + while ( fread(&script[currentStep], sizeof(struct MOVIE_SEQ_STEP), 1, fp) > 0 ) + { + currentStep++; + } + script[currentStep].clear(); // so that I'll know later when the script has ended + if ( currentStep > 1 && script[2].timing == 0 ) + { + currentStep = 0; // skip the loading crap (start at 5000 then drop to a lower time) that is present in the original files + } + else + { + currentStep = 0; // start at the beginning like normal + } + + fclose(fp); +} + +void VideoManager::loadFrame() +{ + // are hax required? + if ( numFrames <= 80 && haxNoVideos ) + { + frameData = m_noVideo; + return; + } + + // yes this is expensive to do every frame! + char filename[256] = "MOV/"; + if ( script[currentStep].filename[1] == 0 ) // a simple test for null filenames and "*" filenames + { + destroy_bitmap(frameData); + frameData = NULL; + return; + } + strcat_s(filename, 256, script[currentStep].filename); + strcat_s(filename, 256, "/000"); + filename[strlen(filename)-3] = (currentFrame/100 % 10) + '0'; + filename[strlen(filename)-2] = (currentFrame/10 % 10) + '0'; + filename[strlen(filename)-1] = (currentFrame/1 % 10) + '0'; + strcat_s(filename, 256, ".png"); + + destroy_bitmap(frameData); + frameData = load_bitmap(filename, NULL); + + if ( frameData == NULL ) + { + frameData = create_bitmap(320, 192); + clear_to_color(frameData, makecol(255,255,255)); + textprintf_centre(frameData, font, 160, 90, makecol(0,0,0), "%s", script[currentStep].filename); + } +} + +int VideoManager::calculateNumFrames() +{ + // first check for special videos - with "E_" as the prefix + if ( _stricmp(script[currentStep].filename, "E_DMX1") == 0 ) + { + return 255; + } + else if ( _stricmp(script[currentStep].filename, "E_TITLE0") == 0 ) + { + return 450; + } + else if ( _stricmp(script[currentStep].filename, "E_HOWTO0") == 0 ) + { + return 512; + } + else if ( _stricmp(script[currentStep].filename, "E_DMX1") == 0 ) + { + return 255; + } + else if ( script[currentStep].filename[0] == 'E' && script[currentStep].filename[2] != 'I' ) + { + return 302; // the demo loop videos of the girls playing one of four songs + } + else if ( script[currentStep].filename[0] == 'J' ) + { + return 150; // the four videos extracted from the flash memory + } + + // the video is a generic video, so it will always be 75 or 80 frames + char filename[256] = "DATA/mov/"; + strcat_s(filename, 256, script[currentStep].filename); + strcat_s(filename, 256, "/079.png"); + if ( fileExists(filename) ) + { + return 80; + } + return 75; +} \ No newline at end of file diff --git a/src/source/attractMode.cpp b/src/source/attractMode.cpp new file mode 100644 index 0000000..94264ec --- /dev/null +++ b/src/source/attractMode.cpp @@ -0,0 +1,253 @@ +// attractMode.cpp implements the attract loop +// source file created by Allen Seitz 7/11/2012 + +#include "common.h" +#include "GameStateManager.h" +#include "inputManager.h" +#include "scoreManager.h" +#include "songwheelMode.h" +#include "videoManager.h" + +extern GameStateManager gs; +extern RenderingManager rm; +extern InputManager im; +extern ScoreManager sm; +extern VideoManager vm; +extern EffectsManager em; + +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; +extern UTIME hideCreditsTimer; +extern SongEntry* songs; +extern BITMAP** m_banners; + +extern int* songIDs; +extern std::string* songTitles; +extern std::string* songArtists; +extern std::string* movieScripts; + +extern UTIME timeRemaining; +extern void renderTimeRemaining(int xc, int yc); + +int attractState = 0; // 0 = movie, 1 = title, 2 = how to play, 3 = hit chart, 4 = recent logins +int attractSubState = 0; // for convenience, rather than checking elapsed time over and over +UTIME submodeTimer = 0; + +int hitlist[20]; +int numplays[20]; + +BITMAP* m_title = NULL; +BITMAP* m_tile = NULL; +BITMAP* m_logo = NULL; +BITMAP* m_mask = NULL; +BITMAP* m_hitchart = NULL; + +void advanceToNextMode() +{ + attractState = (attractState + 1) % 4; + attractSubState = submodeTimer = 0; + hideCreditsTimer = 1000; + + switch ( attractState ) + { + case 0: // movie + vm.loadScript("DATA/mov/A_TITLE2.seq"); + vm.play(); + break; + case 1: // title + vm.stop(); + break; + case 2: // how to + vm.loadScript("DATA/mov/A_HOWTO.seq"); + vm.play(); + break; + case 3: // hitchart + vm.stop(); + break; + } +} + + +void calculateTop20() +{ + int i = 0, j = 0; + + for ( i = 0; i < 20; i++ ) + { + hitlist[i] = -1; + numplays[i] = -1; + } + + for ( int i = 0; i < NUM_SONGS; i++ ) + { + if ( songs[i].version == 0 || songs[i].version == 100 ) // a song that is not in the game or a mission mode special + { + continue; + } + + // check this song against each index of the hitlist + for ( j = 19; j >= 0; j-- ) + { + if ( songs[i].numPlays > numplays[j] ) + { + if ( j != 19 ) + { + numplays[j+1] = numplays[j]; // move it down the list + hitlist[j+1] = hitlist[j]; + } + numplays[j] = songs[i].numPlays; + hitlist[j] = songs[i].songID; + } + } + } +} + +void firstAttractLoop() +{ + if ( m_title == NULL ) + { + m_title = loadImage("DATA/attract/title.png"); + m_tile = loadImage("DATA/attract/tile.png"); + m_logo = loadImage("DATA/attract/logo.png"); + m_mask = loadImage("DATA/attract/mask.png"); + m_hitchart = loadImage("DATA/attract/hitchart.tga"); + } + + calculateTop20(); + attractSubState = submodeTimer = 0; + advanceToNextMode(); + gs.killSong(); // when time runs out on the main menu +} + +void mainAttractLoop(UTIME dt) +{ + static int blinkTimer = 0; + static int numBlinks = 0; + if ( blinkTimer + dt >= 1000 ) + { + numBlinks++; + } + blinkTimer = (blinkTimer + dt) % 1000; + submodeTimer += dt; + + // begin a game from any sub-mode + if ( gs.isFreeplay || gs.numCoins >= gs.numCoinsPerCredit ) + { + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN ) + { + gs.g_currentGameMode = CAUTIONMODE; + gs.g_gameModeTransition = 1; + em.playSample(SFX_CREDIT_BEGIN); + em.announcerQuip(GUY_GAME_BEGIN); + } + } + + // skip to the next submode? + bool holdingLeft = (im.getHoldLength(MENU_LEFT_1P) > 0 && im.getHoldLength(MENU_LEFT_1P) < 1000) || (im.getHoldLength(MENU_LEFT_2P) > 0 && im.getHoldLength(MENU_LEFT_2P) < 1000); + bool holdingRight = (im.getHoldLength(MENU_RIGHT_1P) > 0 && im.getHoldLength(MENU_RIGHT_1P) < 1000) || (im.getHoldLength(MENU_RIGHT_2P) > 0 && im.getHoldLength(MENU_RIGHT_2P) < 1000); + if ( holdingLeft && holdingRight && submodeTimer > 2000 ) + { + advanceToNextMode(); + } + + // render the attract loop + rectfill(rm.m_backbuf, 0, 0, 640, 480, makeacol(0, 0, 0, 255)); + switch ( attractState ) + { + case 0: // movie + vm.renderToSurfaceStretched(rm.m_backbuf, 0, 0, 640, 460); + if ( submodeTimer > 8000 && submodeTimer <= 11300 ) + { + masked_blit(m_mask, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + rm.dimScreen(getValueFromRange(100, 0, (submodeTimer-8000)*100/3200)); + } + if ( submodeTimer > 11300 ) + { + //masked_blit(m_mask, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + advanceToNextMode(); + } + if ( submodeTimer > 15500 ) + { + advanceToNextMode(); + } + break; + case 1: // title + blit(m_title, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + if ( submodeTimer > 5000 ) + { + advanceToNextMode(); + } + break; + case 2: // how to play + vm.renderToSurfaceStretched(rm.m_backbuf, 0, 0, 640, 460); + if ( submodeTimer > 17000 ) + { + advanceToNextMode(); + } + break; + case 3: // hit chart + int scroll = (submodeTimer/20) % 96; + for ( int x = 0; x < 9; x++ ) + for ( int y = 0; y < 7; y++ ) + { + blit(m_tile, rm.m_backbuf, 0, 0, (-96+scroll) + x*96, (-96+scroll) + y*96, 96, 96); + } + masked_blit(m_hitchart, rm.m_backbuf, 0, 0, 34, 32, 573, 34); + + // render banners and stuff for each of the top 20 + for ( int i = 19; i >= 0; i-- ) + { + int y = -3000 + submodeTimer/6; + if ( y > 100 ) + { + y = 100; // don't scroll down too far + } + y += 150*i; + + if ( hitlist[i] == -1 ) + { + continue; // should not happen + } + + int x = 80; + if (y < 180 && submodeTimer < 18600 ) // slide in from the right + { + x = getValueFromRange(640, 80, (y*100/180)); + } + if ( submodeTimer >= 18600 ) // the last item needs a special case + { + int tempy = (-3000 + submodeTimer/6) + 150*i; + x = getValueFromRange(640, 80, (tempy*100/180)); + x = MAX(80, x); + } + + int bannerIndex = songID_to_listID(hitlist[i]); + if ( bannerIndex == -1 ) + { + songIndexError(hitlist[i]); + } + stretch_blit(m_banners[bannerIndex], rm.m_backbuf, 0, 0, 256, 256, x, y + 11, 128, 128); + int color = i % 2; + if ( i == 0 ) + { + color = (submodeTimer/50) % 3 + 1; + } + renderBoldString(songTitles[bannerIndex].c_str(), x + 140, y+11, 400, false, color); + renderArtistString(songArtists[bannerIndex].c_str(), x + 140, y + 51, 400, 32); + renderScoreNumber(i+1, x-55, y+11, 2); + //renderWhiteNumber(numplays[i], x-55, y+64); + } + + if ( submodeTimer > 28000 ) + { + advanceToNextMode(); + } + break; + } + + if ( (gs.isFreeplay || gs.numCoins >= gs.numCoinsPerCredit) && blinkTimer < 500 ) + { + renderBoldString("PUSH START!", 262, (numBlinks/400)%2 == 1 ? 325 : 275, 400, false); + } + rm.flip(); +} \ No newline at end of file diff --git a/src/source/bookManager.cpp b/src/source/bookManager.cpp new file mode 100644 index 0000000..c780837 --- /dev/null +++ b/src/source/bookManager.cpp @@ -0,0 +1,247 @@ +// bookManager.cpp implements bookkeeping for Dance Maniax +// source file created by Allen Seitz 3/6/2012 + +#include +#include + +#include "bookManager.h" + +#define BKEEP_FILENAME "conf/bkeep.dat" + +BookManager::BookManager() +{ + resetData(); + loadData(); + saveData(); + timeSinceLastSave = 0; +} + +void BookManager::resetData() +{ + for ( int i = 0; i < 7; i++ ) + { + allTime[i].reset(); + thisWeek[i].reset(); + } + + lastPowerOnMonth = 1; + lastPowerOnDay = 1; + lastPowerOnYear = 1970; + currentDay = 0; + timeSinceLastSave = 0; +} + +void BookManager::loadData() +{ + FILE* fp = NULL; + tm timePtr; + + // get the current month/day/year + time_t t = time(NULL); + localtime_s(&timePtr, &t); // if this returns non-zero, something is horribly wrong + int todayMonth = timePtr.tm_mon + 1; + int todayDay = timePtr.tm_mday; + int todayYear = timePtr.tm_year + 1900; + + // which day of the week is today? (0-6) + currentDay = timePtr.tm_wday; + + // does bookkeeping exist? + if ( (fp = safeLoadFile(BKEEP_FILENAME)) == NULL ) + { + return; // saveData() will handle this next + } + + // read a short version number + int vnum = checkFileVersion(fp, "DMXB"); + if ( vnum != CURRENT_VERSION_NUMBER ) + { + TRACE("Wrong bookkeeping version number."); + return; // later when multiple versions exist, ideas for converting them + } + + // okay, read everything + fread(&lastPowerOnMonth, sizeof(long), 1, fp); + fread(&lastPowerOnDay, sizeof(long), 1, fp); + fread(&lastPowerOnYear, sizeof(long), 1, fp); + for ( int i = 0; i < 7; i++ ) + { + fread(&thisWeek[i].uptime, sizeof(long), 1, fp); + fread(&thisWeek[i].playtime, sizeof(long), 1, fp); + fread(&thisWeek[i].coins, sizeof(long), 1, fp); + fread(&thisWeek[i].services, sizeof(long), 1, fp); + fread(&thisWeek[i].logins, sizeof(long), 1, fp); + fread(&thisWeek[i].nonLogins, sizeof(long), 1, fp); + fread(&thisWeek[i].spGames, sizeof(long), 1, fp); + fread(&thisWeek[i].dpGames, sizeof(long), 1, fp); + fread(&thisWeek[i].vpGames, sizeof(long), 1, fp); + fread(&thisWeek[i].mpGames, sizeof(long), 1, fp); + + fread(&allTime[i].uptime, sizeof(long), 1, fp); + fread(&allTime[i].playtime, sizeof(long), 1, fp); + fread(&allTime[i].coins, sizeof(long), 1, fp); + fread(&allTime[i].services, sizeof(long), 1, fp); + fread(&allTime[i].logins, sizeof(long), 1, fp); + fread(&allTime[i].nonLogins, sizeof(long), 1, fp); + fread(&allTime[i].spGames, sizeof(long), 1, fp); + fread(&allTime[i].dpGames, sizeof(long), 1, fp); + fread(&allTime[i].vpGames, sizeof(long), 1, fp); + fread(&allTime[i].mpGames, sizeof(long), 1, fp); + } + + // now, based on the last power-on time, how much data is over a week old? + long grandDaysLast = countDaysIn(lastPowerOnYear, lastPowerOnMonth, lastPowerOnDay); + long grandDaysToday = countDaysIn(todayYear, todayMonth, todayDay); + int difference = grandDaysToday - grandDaysLast; + for ( int i = 0; i < 7; i++ ) + { + int dayIndex = (currentDay - i + 7) % 7; // loop 0-6 "days backwards" + if ( difference + i >= 7 ) + { + thisWeek[dayIndex].reset(); + } + } + + lastPowerOnMonth = todayMonth; + lastPowerOnDay = todayDay; + lastPowerOnYear = todayYear; + + fclose(fp); +} + +void BookManager::saveData() +{ + FILE* fp = NULL; + + if ( fopen_s(&fp, BKEEP_FILENAME, "wb") != 0 ) + { + TRACE("UNABLE TO SAVE BOOKKEEPING"); + return; // this is bad + } + + // write the version and the last power-on time + fprintf(fp, "DMXB"); + int vnum = CURRENT_VERSION_NUMBER; + fwrite(&vnum, sizeof(long), 1, fp); + fwrite(&lastPowerOnMonth, sizeof(long), 1, fp); + fwrite(&lastPowerOnDay, sizeof(long), 1, fp); + fwrite(&lastPowerOnYear, sizeof(long), 1, fp); + + // write all data + for ( int i = 0; i < 7; i++ ) + { + fwrite(&thisWeek[i].uptime, sizeof(long), 1, fp); + fwrite(&thisWeek[i].playtime, sizeof(long), 1, fp); + fwrite(&thisWeek[i].coins, sizeof(long), 1, fp); + fwrite(&thisWeek[i].services, sizeof(long), 1, fp); + fwrite(&thisWeek[i].logins, sizeof(long), 1, fp); + fwrite(&thisWeek[i].nonLogins, sizeof(long), 1, fp); + fwrite(&thisWeek[i].spGames, sizeof(long), 1, fp); + fwrite(&thisWeek[i].dpGames, sizeof(long), 1, fp); + fwrite(&thisWeek[i].vpGames, sizeof(long), 1, fp); + fwrite(&thisWeek[i].mpGames, sizeof(long), 1, fp); + + fwrite(&allTime[i].uptime, sizeof(long), 1, fp); + fwrite(&allTime[i].playtime, sizeof(long), 1, fp); + fwrite(&allTime[i].coins, sizeof(long), 1, fp); + fwrite(&allTime[i].services, sizeof(long), 1, fp); + fwrite(&allTime[i].logins, sizeof(long), 1, fp); + fwrite(&allTime[i].nonLogins, sizeof(long), 1, fp); + fwrite(&allTime[i].spGames, sizeof(long), 1, fp); + fwrite(&allTime[i].dpGames, sizeof(long), 1, fp); + fwrite(&allTime[i].vpGames, sizeof(long), 1, fp); + fwrite(&allTime[i].mpGames, sizeof(long), 1, fp); + } + + //fclose(fp); + safeCloseFile(fp, BKEEP_FILENAME); +} + +void BookManager::logCoin(bool wasService) +{ + if ( wasService ) + { + thisWeek[currentDay].services++; + allTime[currentDay].services++; + } + else + { + thisWeek[currentDay].coins++; + allTime[currentDay].coins++; + } +} + +void BookManager::logTime(int ms, int mode) +{ + thisWeek[currentDay].uptime += ms; + allTime[currentDay].uptime += ms; + timeSinceLastSave += ms; + + // is someone playing? + if ( mode != SPLASH && mode != WARNING && mode != TESTMODE && mode != ATTRACT ) + { + thisWeek[currentDay].playtime += ms; + allTime[currentDay].playtime += ms; + } + // periodically write the bookkeeping to disk, but only if no one is playing + else if ( timeSinceLastSave > 600000 ) + { + saveData(); + timeSinceLastSave = 0; + } +} + +void BookManager::logLogin(bool wasAnonymous) +{ + if ( wasAnonymous ) + { + thisWeek[currentDay].nonLogins++; + allTime[currentDay].nonLogins++; + } + else + { + thisWeek[currentDay].logins++; + allTime[currentDay].logins++; + } +} + +void BookManager::logMode(int mode) +{ + switch (mode) + { + case SINGLES_PLAY: + thisWeek[currentDay].spGames++; + allTime[currentDay].spGames++; + break; + case DOUBLES_PLAY: + thisWeek[currentDay].dpGames++; + allTime[currentDay].dpGames++; + break; + case VERSUS_PLAY: + thisWeek[currentDay].vpGames++; + allTime[currentDay].vpGames++; + break; + case MISSION_PLAY: + thisWeek[currentDay].mpGames++; + allTime[currentDay].mpGames++; + break; + } +} + +// takes a specific date and returns the number of days since 1/1/1900 +long BookManager::countDaysIn(int year, int month, int day) +{ + static int dpm[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + + int days = ((year-1900) * 365) + ((year-1900)/4); + for ( int m = 0; m < 12; m++ ) + { + if ( m < month-1 ) + { + days += dpm[m]; + } + } + days += day-1; + + return days; +} \ No newline at end of file diff --git a/src/source/common.cpp b/src/source/common.cpp new file mode 100644 index 0000000..3ded572 --- /dev/null +++ b/src/source/common.cpp @@ -0,0 +1,854 @@ +// common.cpp implements the functions described in common.h +// source file created + +#include "common.h" +#include +#include +#include "gameStateManager.h" // for error mode, is all +#include "loadpng.h" // for the RenderingManager initialization + +extern RenderingManager rm; +extern GameStateManager gs; + +extern int NUM_SONGS; +extern int* songIDs; +extern std::string* songTitles; +extern std::string* songArtists; +extern std::string* movieScripts; + +void RenderingManager::Initialize() +{ + register_bitmap_file_type("png", load_png, NULL); // needed for certain asset loading + + // set up double buffering + m_backbuf1 = create_system_bitmap(640, 480); + m_backbuf2 = create_system_bitmap(640, 480); + + m_temp64 = create_bitmap(64, 64); + currentPage = 1; + m_backbuf = rm.m_backbuf1; + + // load other stuff + m_whiteFont = loadImage("DATA/etc/white_font.bmp"); + m_textFont = loadImage("DATA/etc/text_font.bmp"); + m_boldFont[0] = loadImage("DATA/etc/bold_font.bmp"); + m_boldFont[1] = loadImage("DATA/etc/bold_font.bmp"); + m_boldFont[2] = loadImage("DATA/etc/bold_font.bmp"); + m_boldFont[3] = loadImage("DATA/etc/bold_font.bmp"); + replaceColor(m_boldFont[1], makecol(248,248,248), makecol(170,255,170)); + replaceColor(m_boldFont[2], makecol(248,248,248), makecol(255,170,170)); + replaceColor(m_boldFont[3], makecol(248,248,248), makecol(170,170,255)); + m_artistFont = loadImage("DATA/etc/artist_font.bmp"); + m_scoreFont = loadImage("DATA/etc/score_font.bmp"); + m_nameFont[0] = loadImage("DATA/etc/name_font_white.bmp"); + m_nameFont[1] = loadImage("DATA/etc/name_font_green.bmp"); + m_nameFont[2] = loadImage("DATA/etc/name_font_red.bmp"); +} + +int pickRandomInt(int n, ...) +{ + va_list args; + va_start(args, n); + + int retval = va_arg(args, int); + int random = rand() % n; + + // loop a random portion of the way through the argument list + for (int i = 0; i < random; i++) + { + retval = va_arg(args, int); + } + va_end(args); + + return retval; +} + +int getValueFromRange(int min, int max, int percent) +{ + if ( max < min ) + { + int maxrange = min - max; + return min - (maxrange * percent / 100); + } + else + { + int minrange = max - min; + return min + (minrange * percent / 100); + } +} + +void addLeadingZeros(char* buffer, int desiredLength) +{ + while ( (int)strlen(buffer) < desiredLength ) + { + memmove_s(&buffer[1], desiredLength+1, buffer, strlen(buffer)); + buffer[0] = '0'; + } +} + +void globalError(long errorCode, char* errorInfo) +{ + gs.g_currentGameMode = ERRORMODE; + gs.g_gameModeTransition = 1; + gs.g_errorCode = errorCode; + strcpy_s(gs.g_errorInfo, 256, errorInfo); +} + +void songIndexError(int id) +{ + if ( id < 0 ) + { + id *= -1; + globalError(INVALID_SONG_ID, "song id was -1"); + return; + } + + char helpString[64] = "0000 song id"; + helpString[0] = (id / 1000 ) % 10 + '0'; + helpString[1] = (id / 100 ) % 10 + '0'; + helpString[2] = (id / 10 ) % 10 + '0'; + helpString[3] = (id / 1 ) % 10 + '0'; + globalError(INVALID_SONG_ID, helpString); +} + +BITMAP* loadImage(const char* filename) +{ + BITMAP* temp = load_bitmap(filename, NULL); + if ( temp == NULL ) + { + allegro_message("Couldn't load %s", filename); + } + return temp; +} + +FILE* safeLoadFile(char* filename) +{ + char checksum = calculateChecksum(filename); + + FILE* fp = NULL; + if ( checksum != 0 || fopen_s(&fp, filename, "rbc") != 0 ) + { + // uh-oh! file problem. is there a backup? + char bakFilename[256] = "backup/"; + strcat_s(bakFilename, 256, filename); + checksum = calculateChecksum(bakFilename); + if ( checksum != 0 || fopen_s(&fp, bakFilename, "rbc") != 0 ) + { + return NULL; // oh darn + } + } + + return fp; +} + +void safeCloseFile(FILE* fp, char* filename) +{ + fflush(fp); + fclose(fp); + + // calculate the checksum and append it to the original file + FILE* oldfile = NULL; + char checksum = calculateChecksum(filename); + if ( fopen_s(&oldfile, filename, "a+b") != 0 ) // if an error happens while appending the checksum then the resulting file will be interpreted as corrupt later, bummer + { + TRACE("ERROR APPENDING CHECKSUM"); + } + else + { + fprintf_s(oldfile, "%c", -checksum); + fclose(oldfile); + makeBackupFile(filename); + } +} + +char calculateChecksum(char* filename) // calculates the checksum for any file and should return 0 on any legit file +{ + FILE* fp = NULL; + if ( fopen_s(&fp, filename, "rb") != 0 ) + { + return 0; // returning non-zero here could be disasterous, but "file not found" is obviously caught elsewhere + } + + // literally sum every byte in the file and return it + char sum = 0, temp = 0; + while ( fread_s(&temp, 1, 1, 1, fp) == 1 ) + { + sum += temp; + } + + fclose(fp); + return sum; +} + +bool fileExists(char* filename) +{ + FILE* fp = NULL; + if ( fopen_s(&fp, filename, "rb") != 0 ) + { + return false; + } + fclose(fp); + return true; +} + +void makeBackupFile(char* filename) +{ + // and make a backup + char bakFilename[256] = "backup/"; + strcat_s(bakFilename, 256, filename); + + FILE* bakFile = NULL, *origFile = NULL; + if ( fopen_s(&bakFile, bakFilename, "wb") != 0 || fopen_s(&origFile, filename, "rb") != 0 ) + { + return; // well darn + } + + // none of these files are ever very large + char temp = 0; + while ( fread_s(&temp, 1, sizeof(char), 1, origFile) > 0 ) + { + fwrite(&temp, sizeof(char), 1, bakFile); + } + + fflush(bakFile); + fclose(bakFile); + fclose(origFile); +} + +int checkFileVersion(FILE* fp, char* expected) +{ + char version[4]; + long vnum = 0; + + fread(&version, sizeof(char), 4, fp); + fread(&vnum, sizeof(long), 1, fp); + if ( version[0] != expected[0] || version[1] != expected[1] || version[2] != expected[2] || version[3] != expected[3] ) + { + return -1; // completely wrong file + } + return vnum; +} + +void renderWhiteLetter(char letter, int x, int y) +{ + // make the letter uppercase + if ( letter >= 'a' && letter <= 'z' ) + { + letter = 'A' + letter - 'a'; + } + + // render an uppercase letter + if ( letter >= 'A' && letter <= 'M' ) + { + masked_blit(rm.m_whiteFont, rm.m_backbuf, 10*(letter-'A'), 0, x, y, 10, 12); + return; + } + if ( letter >= 'N' && letter <= 'Z' ) + { + masked_blit(rm.m_whiteFont, rm.m_backbuf, 10*(letter-'N'), 12, x, y, 10, 12); + return; + } + + // render a number, punctuation mark, or unknown character + int row = 5, col = 5; + if ( letter >= '0' && letter <= '9' ) + { + row = 2; + col = letter - '0'; + } + switch (letter) + { + case '?': + row = 3; col = 2; break; + case '!': + row = 3; col = 1; break; + case '#': + row = 3; col = 3; break; + case '$': + row = 2; col = 11; break; + case '&': + row = 3; col = 0; break; + case '*': + row = 3; col = 4; break; + case '-': + row = 2; col = 10; break; + case ' ': + row = 3; col = 5; break; + case '.': + row = 2; col = 12; break; + case '(': + row = 3; col = 9; break; + case ')': + row = 3; col = 10; break; + case '+': + row = 3; col = 11; break; + case ',': + row = 3; col = 12; break; + case '~': + row = 5; col = 3; break; + case '%': + row = 3; col = 7; break; + case '"': + row = 3; col = 6; break; + case '\'': + row = 3; col = 8; break; + case '/': + row = 4; col = 0; break; + case ':': + row = 4; col = 1; break; + case ';': + row = 4; col = 2; break; + case '<': + row = 4; col = 3; break; + case '>': + row = 4; col = 4; break; + case '=': + row = 4; col = 5; break; + case 16: // shaded arrow + row = 4; col = 6; break; + case '[': + row = 4; col = 7; break; + case ']': + row = 4; col = 8; break; + case 153: // yen + row = 4; col = 9; break; + case '^': + row = 4; col = 10; break; + case '_': + row = 4; col = 11; break; + case '`': + row = 4; col = 12; break; + case '{': + row = 5; col = 0; break; + case '|': + row = 5; col = 1; break; + case '}': + row = 5; col = 2; break; + case 151: // a copyright symbol + row = 5; col = 4; break; + } + masked_blit(rm.m_whiteFont, rm.m_backbuf, 10*col, 12*row, x, y, 10, 12); +} + +void RenderingManager::flip() +{ + blit(m_backbuf, screen, 0, 0, 0, 0, 640, 460); // intentionally leave the bottom 20 pixels alone + if ( currentPage == 1 ) + { + m_backbuf = m_backbuf2; + currentPage = 2; + } + else + { + m_backbuf = m_backbuf1; + currentPage = 1; + } +} + +void RenderingManager::screenshot() +{ + // get the current time + time_t rawtime = 0; + struct tm timeinfo; + rawtime = time(NULL); + localtime_s(&timeinfo, &rawtime); + + // build a filename + char filename[] = "dd-mm-yy hh-mm-ss.bmp"; + filename[0] = (timeinfo.tm_mday/10)%10 + '0'; + filename[1] = timeinfo.tm_mday%10 + '0'; + filename[3] = (timeinfo.tm_mon/10)%10 + '0'; + filename[4] = timeinfo.tm_mon%10 + '0'; + filename[6] = (timeinfo.tm_year/10)%10 + '0'; + filename[7] = timeinfo.tm_year%10 + '0'; + filename[9] = (timeinfo.tm_hour/10)%10 + '0'; + filename[10] = timeinfo.tm_hour%10 + '0'; + filename[12] = (timeinfo.tm_min/10)%10 + '0'; + filename[13] = timeinfo.tm_min%10 + '0'; + filename[15] = (timeinfo.tm_sec/10)%10 + '0'; + filename[16] = timeinfo.tm_sec%10 + '0'; + + save_bitmap(filename, m_backbuf, NULL); +} + +void RenderingManager::renderWipeAnim(int frame) +{ + if ( frame < 0 || frame > 14 ) + { + TRACE("Don't do that."); + return; + } + + char filename[] = "DATA/wipe/wipe_0000.tga"; + filename[17] = (frame/10) + '0'; + filename[18] = (frame%10) + '0'; + + BITMAP* temp = loadImage(filename); + masked_stretch_blit(temp, m_backbuf, 0, 0, 320, 240, 0, 0, 640, 480); + destroy_bitmap(temp); +} + +void RenderingManager::dimScreen(int percent) +{ + drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); + rectfill(m_backbuf, 0, 0, 640, 480, makeacol(0, 0, 0, getValueFromRange(0, 255, percent))); + set_alpha_blender(); // the game assumes the graphics are left in this mode +} + +void EffectsManager::initialize() +{ + char filename[] = "DATA/sfx/GAME_0000.wav"; + currentAnnouncer = NULL; + for ( int i = 0; i < TOTAL_NUM_SFX; i++ ) + { + filename[14] = (i/1000)%10 + '0'; + filename[15] = (i/100)%10 + '0'; + filename[16] = (i/10)%10 + '0'; + filename[17] = (i % 10) + '0'; + basic_sfx[i] = load_sample(filename); + } +} + +void EffectsManager::playSample(int which) +{ + if ( which < 41 || which > 156 ) // exclude announcers + { + playSFXOnce(basic_sfx[which]); + } +} + +void EffectsManager::announcerQuip(int which) +{ + //destroy_sample(currentAnnouncer); + stop_sample(currentAnnouncer); + + if ( which >= 41 && which < 156 ) // only do announcers + { + //char filename[] = "DATA/sfx/GAME_0000.wav"; + //filename[15] = (which/100)%10 + '0'; + //filename[16] = (which/10)%10 + '0'; + //filename[17] = (which % 10) + '0'; + currentAnnouncer = basic_sfx[which];// load_sample(filename); + if ( currentAnnouncer != NULL ) + { + playSFXOnce(currentAnnouncer); + } + } +} + +bool EffectsManager::announcerQuipChance(int which, int percent) +{ + if ( rand()%100 <= percent ) + { + announcerQuip(which); + return true; + } + return false; +} + +void replaceColor(BITMAP* bmp, long col1, long col2) +{ + for ( int y = 0; y < bmp->w; y++ ) + for ( int x = 0; x < bmp->h; x++ ) + { + if ( ((long *)bmp->line[y])[x] == col1 ) + { + ((long *)bmp->line[y])[x] = col2; + } + } +} + +void renderWhiteString(const char* string, int x, int y) +{ + int i = 0; + while ( string[i] != 0 ) + { + renderWhiteLetter(string[i], x, y); + x += 10; + i++; + } +} + +void renderWhiteNumber(int number, int x, int y) +{ + char str[10] = ""; + sprintf_s(str, 10, "%d", number); + renderWhiteString(str, x, y); +} + +void renderTextString(const char* string, int x, int y, int width, int height) +{ + static char puncs[27] = "!@#$%^&*()-=+[]:;'\"`~,.?/\\"; + int left = x, top = y; + + // loop through each character in the string, find it, render it, advance + for ( int i = 0; string[i] != 0; i++ ) + { + int row = 2, col = 11; // default to a space + + // find the glyph in the bitmap font + if ( string[i] >= 'A' && string[i] <= 'Z' ) + { + row = 0; + col = string[i] - 'A'; + } + else if ( string[i] >= 'a' && string[i] <= 'z' ) + { + row = 1; + col = string[i] - 'a'; + } + else if ( string[i] >= '0' && string[i] <= '9' ) + { + row = 2; + col = string[i] - '0'; + } + else + { + for ( int j = 0; j < 26; j++ ) + { + if ( string[i] == puncs[j] ) + { + row = 3; + col = j; + break; + } + } + } + + // render it! + masked_blit(rm.m_textFont, rm.m_backbuf, 10*col, 19*row, x, y, 10, 18); + + // if row is full then next row. out of rows? then end early. + x += 10; + if ( x-left > width ) + { + x = left; + y += 15; + } + if ( y-top > height ) + { + break; + } + } +} + +static char boldTextWidths[] = +{ + 7, 7, 10, 17, 14, 17, 15, 7, 7, 7, + 15, 14, 7, 14, 7, 10, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 7, 7, 13, 13, + 13, 17, 24, 14, 14, 14, 14, 10, 10, 14, // >?@ABCDEFG + 14, 9, 9, 14, 10, 20, 15, 14, 14, 14, // Q + 14, 14, 14, 14, 14, 22, 14, 13, 12, 7, // Z[ + 10, 7, 13, 14, 9, 14, 14, 14, 14, 14, + 10, 14, 14, 7, 8, 13, 8, 21, 14, 14, + 14, 14, 11, 14, 9, 14, 12, 19, 13, 13, + 10, 10, 10, 13, 24, 24, 24, 24, 24, 24, +}; + +void renderBoldString(const unsigned char* string, int x, int y, int maxWidth, bool fixedWidth, int color) +{ + int left = x; + bool smallermode = false; + + // loop through each character in the string, find it, render it, advance + for ( int i = 0; string[i] != 0; i++ ) + { + int row = 0, col = 0; // default to a space + int yoff = 0; // for lowercase letters and some punctuation + + // find the glyph on the sprite sheet + unsigned char temp = string[i]; + if ( temp == 199 ) // alt-128 Ç + { + temp = 128; // heart + } + if ( temp >= 32 && temp <= 128 ) + { + int ascii = temp - 32; + row = (ascii/10) % 10; + col = ascii % 10; + } + + // some characters such as 'g' 'y' 'p' and 'q' hang below the line + if ( string[i] == 'g' || string[i] == 'q' || string[i] == 'j' || string[i] == 'Q' ) + { + yoff = +3; + } + if ( string[i] == 'y' || string[i] == 'p' ) + { + yoff = +2; + } + + if ( string[i] == '|' ) // a convention I saw used in the original DMX to note a subtitle + { + smallermode = !smallermode; + continue; + } + + // render it! + if ( smallermode ) + { + if ( yoff > 0 ) + { + yoff -= 1; + } + masked_stretch_blit(rm.m_boldFont[color], rm.m_backbuf, 24*row, 24*col, 24, 24, x, y+yoff+6, 18, 18); + } + else + { + masked_blit(rm.m_boldFont[color], rm.m_backbuf, 24*row, 24*col, x, y+yoff, 24, 24); + } + + // find the width of this glyph + int width = 24; + if ( !fixedWidth ) + { + width = boldTextWidths[row*10 + col]; + } + if ( smallermode ) + { + width = (width * 3/4) + 1; + } + + // if row is full then end early. + x += width; + if ( x-left >= maxWidth ) + { + return; + } + } +} + +void renderBoldString(const char* string, int x, int y, int maxWidth, bool fixedWidth, int color) +{ + renderBoldString((unsigned char*)string, x, y, maxWidth, fixedWidth, color); +} + +static char artistTextWidths[] = +{ + 6, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 6, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 6, 6, 11, 11, 11, 11, 11, 12, 11, 11, // ends with A B C + 11, 11, 11, 11, 11, 11, 11, 12, 11, 13, 12, 11, // D - O + 10, 11, 12, 10, 11, 12, 12, 14, 11, 11, 10, 6, // P - Z, [ + 10, 6, 10, 10, 7, 11, 12, 11, 12, 11, 11, 11, // ends wuth a b c d e f g + 12, 9, 9, 10, 9, 13, 11, 10, 11, 11, 10, 9, + 10, 11, 11, 11, 10, 11, 9, 6, 6, 6, 10, 10, // begins with t - z +}; + +// 'artist' is the name of the typewriter font +void renderArtistString(const unsigned char* string, int x, int y, int width, int height) +{ + int left = x, top = y; + + // loop through each character in the string, find it, render it, advance + for ( int i = 0; string[i] != 0; i++ ) + { + int row = 0, col = 0; // default to a space + int yoff = 0; + + // find the glyph in the bitmap font + if ( string[i] >= 32 || string[i] <= 126 ) + { + row = (string[i] - 32) % 12; + col = (string[i] - 32) / 12; + } + + // some characters such as 'g' 'y' 'p' and 'q' hang below the line + if ( string[i] == 'g' || string[i] == 'q' || string[i] == 'j' || string[i] == 'Q' ) + { + yoff = +3; + } + if ( string[i] == 'y' || string[i] == 'p' || string[i] == '(' || string[i] == ')' ) + { + yoff = +3; + } + if ( string[i] == 's' ) + { + //yoff = +1; + } + // render it! + masked_blit(rm.m_artistFont, rm.m_backbuf, 16*col, 16*row, x, y+yoff, 16, 16); + + // if row is full then next row. out of rows? then end early. + x += artistTextWidths[col*12 + row] + 1; + if ( x-left > width ) + { + x = left; + y += 16; + } + if ( y-top > height ) + { + break; + } + } +} + +void renderArtistString(const char* string, int x, int y, int width, int height) +{ + renderArtistString((unsigned char*)string, x, y, width, height); +} + +static char scoreTextWidths[] = +{ + 8, 8, 11, 11, 14, 16, 16, 10, 10, 10, 10, 10, + 6, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 7, 8, 9, 10, 9, 11, 15, 16, 15, 16, // ends with A B C + 16, 13, 13, 16, 16, 9, 15, 15, 14, 16, 16, 16, // D - O + 15, 16, 15, 15, 15, 16, 16, 16, 16, 16, 14, 8, // P - Z, [ + 14, 8, 9, 14, 8, 11, 12, 11, 12, 11, 11, 11, // ends wuth a b c d e f g + 12, 9, 9, 10, 9, 13, 11, 10, 11, 11, 10, 9, + 10, 11, 11, 11, 10, 11, 9, 6, 6, 6, 10, 10, // begins with t - z +}; + +// 'score' is the name of the font with the grey/white gradient +void renderScoreString(const char* string, int x, int y, int width, int height) +{ + int left = x, top = y; + + // loop through each character in the string, find it, render it, advance + for ( int i = 0; string[i] != 0; i++ ) + { + int row = 0, col = 0; // default to a space + int yoff = 0; + + // find the glyph in the bitmap font + if ( string[i] >= 32 || string[i] <= 126 ) + { + row = (string[i] - 32) % 12; + col = (string[i] - 32) / 12; + } + + /* some characters such as 'g' 'y' 'p' and 'q' hang below the line + // untested for this font, don't use lower case letters + if ( string[i] == 'g' || string[i] == 'q' || string[i] == 'j' || string[i] == 'Q' ) + { + yoff = +3; + } + if ( string[i] == 'y' || string[i] == 'p' || string[i] == '(' || string[i] == ')' ) + { + yoff = +3; + } + if ( string[i] == 's' ) + { + //yoff = +1; + } + //*/ + + // render it! + masked_blit(rm.m_scoreFont, rm.m_backbuf, 32*col, 32*row, x, y+yoff, 32, 32); + + // if row is full then next row. out of rows? then end early. + x += (scoreTextWidths[col*12 + row] + 1) * 2; // times two because this font is twice as large + if ( x-left > width ) + { + x = left; + y += 32; + } + if ( y-top > height ) + { + break; + } + } +} + +void renderScoreNumber(int number, int x, int y, int requiredDigits) +{ + char str[16] = ""; + sprintf_s(str, 10, "%.*d", requiredDigits, number); + renderScoreString(str, x, y, 256, 32); +} + +void renderNameString(const char* string, int x, int y, int color) +{ + for ( int i = 0; string[i] != 0; i++ ) + { + renderNameLetter(string[i], x, y, color); + x += 32; + } +} + +void renderNameLetter(char letter, int x, int y, int color) +{ + int row = 5, col = 10, pos = 65; // default to a space + static char puncs[40] = "[]()<>0123456789+-*/=@:;`',.?!\"#%&^_ |~"; + + if ( letter >= 'A' && letter <= 'Z' ) + { + pos = letter - 'A'; + } + else if ( letter >= 'a' && letter <= 'z' ) + { + pos = letter - 'a'; + } + else + { + for ( int i = 0; i < 39; i++ ) + { + if ( letter == puncs[i] ) + { + pos = i + 26; + break; + } + } + } + col = pos/6; + row = pos%6; + + masked_blit(rm.m_nameFont[color], rm.m_backbuf, 32*col, 32*row, x, y, 32, 32); +} + +int songID_to_listID(int songID) +{ + for ( int i = 0; i < NUM_SONGS; i++ ) + { + if ( songIDs[i] == songID ) + { + return i; + } + } + + return -1; // up to the caller to throw and invalid song id error if necessary +} + +int listID_to_songID(int index) +{ + if ( index >= NUM_SONGS || index < 0) + { + return -1; // programmer error + } + return songIDs[index]; +} + +int getChartIndexFromType(int type) +{ + switch(type) + { + case SINGLE_MILD: return 0; + case SINGLE_WILD: return 1; + case SINGLE_ANOTHER: return 2; + case DOUBLE_MILD: return 3; + case DOUBLE_WILD: return 4; + case DOUBLE_ANOTHER: return 5; + } + return -1; +} + +void playSFXOnce(SAMPLE* sample) +{ + stop_sample(sample); + play_sample(sample, 255, 127, 1000, 0); +} + +int getSampleLength(SAMPLE* sample) +{ + return (sample->len + sample->freq/2) * 10 / MAX(sample->freq, 1); +} + +int calculateArrowColor(unsigned long timing, int timePerBeat) +{ + int t = timing % timePerBeat; + int fraction16 = t * 16 / timePerBeat; + return fraction16 / 4; +} \ No newline at end of file diff --git a/src/source/dwi_read.cpp b/src/source/dwi_read.cpp new file mode 100644 index 0000000..b3d20ce --- /dev/null +++ b/src/source/dwi_read.cpp @@ -0,0 +1,638 @@ +// dwi_read.cpp reads a .DWI file, for older DMX simfiles +// source file created 1/14/12 by Catastrophe +// 10-17-12 the fix for tempo changes ended up being a major rewrite + +#include +#include +#include + +#include "common.h" + +// these are only written to by readNextTag(). This is cleaner than 5 reference parameters +char tagName[32]; +char tagValue[32]; +char tagLevel[16]; +char tagLeftSide[4096]; +char tagRightSide[4096]; + +// first the chart is read in as a series of these, then sorted, then the beats are turned into milliseconds (and a real chart) +struct BEAT_NOTE +{ + float beat; + int type; // one of the enumerated note types + float param; // the length of the stop, or the new bpm, or the beat the hold ends on + char column; // which column this note appears in + + BEAT_NOTE() + { + reset(); + } + void reset() + { + beat = type = param = column = 0; + } +}; + +// this is a special BEAT_NOTE type only used within this source file +#define HOLD_START 3 + +void readNextTag(FILE* fp); +// precondition: the globals noted above are only written to by this function, and fp is not null +// postcondition: starts reading at '#', ends reading at ';', and saves whatever it finds to these strings + +int getColumn(char ch, char which); +// precondition: ch is valid DWI code, which is 0 or 1 for which side is needed +// postcondition: returns a column index for that DWI code, or -1 for no column + +bool sortNoteFunction(struct BEAT_NOTE a, struct BEAT_NOTE b); +// precondition: only to be used by readDWI() +// postcondition: returns true is a is earlier than b + +void processChartString(std::vector *chart, char* string, int side); +// precondition: the songID and chartType must exist on disk +// postcondition: appends a bunch of BEAT_NOTE objects to the chart (singles or doubles) + +UTIME getMillisecondsAtBeat(float targetBeat, std::vector *chart, int startIndex, UTIME startTime, float currentTimePerBeat); +// precondition: the chart is sorted and startIndex is a valid index +// postcondition: loops through the chart until the number of beats have passed, noting any tempo changes + +void readNextTag(FILE* fp) +{ + char* parts[5] = { tagName, tagValue, tagLevel, tagLeftSide, tagRightSide }; + int ch = 0; + int currentPart = -1; + int currentIndex = 0; + + tagName[0] = tagValue[0] = tagLevel[0] = tagLeftSide[0] = tagRightSide[0] = 0; + + while ( (ch = getc(fp)) != EOF ) + { + // start with '#' and ignore anything (like extra \r\n) before it + if ( ch == '#' ) + { + currentPart = currentIndex = 0; + continue; + } + else if ( currentPart == -1 ) + { + continue; + } + // begin the next section? + else if ( ch == ':' ) + { + parts[currentPart][currentIndex] = 0; + currentPart++; + currentIndex = 0; + ASSERT(currentPart < 5); + } + // done with all parts? + else if ( ch == ';' ) + { + parts[currentPart][currentIndex] = 0; + return; + } + else + { + parts[currentPart][currentIndex] = ch; + currentIndex++; + } + } +} + +int getColumn(char ch, char which) +{ + if ( which == 0 ) + { + switch (ch) + { + case '4': return 0; + case '2': return 1; + case '8': return 2; + case '6': return 3; + case '1': return 0; + case '7': return 0; + case '9': return 2; + case '3': return 1; + case 'B': return 0; + case 'A': return 1; + } + } + else + { + switch (ch) + { + case '1': return 1; + case '7': return 2; + case '9': return 3; + case '3': return 3; + case 'B': return 3; + case 'A': return 2; + } + } + return -1; +} + +bool sortNoteFunction(struct BEAT_NOTE a, struct BEAT_NOTE b) +{ + if ( a.beat == b.beat ) + { + return a.type < b.type; // puts taps ahead of tempo changes, pretty much + } + return a.beat < b.beat; +} + +void processChartString(std::vector *chart, char* string, int side) +{ + int currentIndex = 0; + int beatDivision = 2; // 1/8 beats are the default in DWI Files + float totalBeatsProcessed = 0.0; + float prevBeatProcessed = 0.0; // crtical for hold notes + float beatOfHold[4] = { -1, -1, -1, -1 }; + + // when side == 1 then add 4 to every column for the right half of a doubles chart + int doublesFactor = side == 1 ? 4 : 0; + + while ( string[currentIndex] != 0 ) + { + unsigned char ch = string[currentIndex]; + int columns[4] = { -1, -1, -1, -1 }; + + // punctuation has various meanings + if ( ch == '0' ) + { + prevBeatProcessed = totalBeatsProcessed; + totalBeatsProcessed += 1.0/beatDivision; + currentIndex++; + continue; + } + else if ( ch == '\r' || ch == '\n' ) + { + currentIndex++; + continue; // not needed, but nice for debugging below + } + else if ( ch == '(' ) + { + beatDivision = 4; // parens mean 1/16th notes + currentIndex++; + continue; + } + else if ( ch == '[' ) + { + beatDivision = 6; // brackets mean 1/24th notes + currentIndex++; + continue; + } + else if ( ch == '{' ) + { + beatDivision = 16; // curly braces mean 1/64th notes + currentIndex++; + continue; + } + else if ( ch == '`' ) // == 96 + { + beatDivision = 48; // this `00000' nonsense means 192nd notes + currentIndex++; + continue; + } + else if ( ch == ')' || ch == ']' || ch == '}' || ch == 250 || ch == 39 ) + { + beatDivision = 2; // back to 1/8th notes + currentIndex++; + continue; + } + else if ( ch == '!' ) + { + // what is to the right of the bang? + currentIndex++; // skip over the bang + columns[0] = getColumn(string[currentIndex], 0); + columns[1] = getColumn(string[currentIndex], 1); + + if ( columns[0] != -1 && beatOfHold[columns[0]] == -1 ) + { + beatOfHold[columns[0]] = prevBeatProcessed; // store when the hold starts + } + if ( columns[1] != -1 && beatOfHold[columns[1]] == -1 ) + { + beatOfHold[columns[1]] = prevBeatProcessed; // store when the hold starts + } + } + + // look for regular notes + else if ( (ch >= '0' && ch <= '9') || ch == 'A' || ch == 'B' ) + { + columns[0] = getColumn(ch, 0); + columns[1] = getColumn(ch, 1); + } + else if ( ch == '<' ) // this special character means "tie columns together" to make triples and quads + { + int currentColumn = 0; + currentIndex++; + + while ( string[currentIndex] != '>' ) + { + ch = string[currentIndex]; + if ( getColumn(ch, 0) != -1 ) + { + columns[currentColumn] = getColumn(ch, 0); + currentColumn = currentColumn == 3 ? 3 : currentColumn + 1; + } + if ( getColumn(ch, 1) != -1 ) + { + columns[currentColumn] = getColumn(ch, 1); + currentColumn = currentColumn == 3 ? 3 : currentColumn + 1; + } + currentIndex++; + } + } + else + { + al_trace("Unknown symbol: %c", ch); + } + + // create a freeze note? the end of a hold is signaled by a tap note in a column that was marked as held on a previous pass + if ( ch != '!' ) + { + for ( int d = 0; d < 4; d++ ) + { + if ( columns[d] != -1 && beatOfHold[columns[d]] != -1 ) + { + struct BEAT_NOTE a; + a.beat = beatOfHold[columns[d]]; + a.column = columns[d] + doublesFactor; + a.type = HOLD_START; + a.param = totalBeatsProcessed; + + beatOfHold[columns[d]] = -1; // clear the hold + columns[d] = -1; // clear the tap which ended this hold + chart->push_back(a); + } + } + } + + // this can happen if a hold ends - sort all the -1 columns to the end of the list + // for example {-1, 2, -1, -1} becomes {2, -1, -1, -1} + if ( columns[0] == -1 && (columns[1] != -1 || columns[2] != -1 || columns[3] != -1) ) + { + columns[0] = columns[1]; + columns[1] = columns[2]; + columns[2] = columns[3]; + columns[3] = -1; + } + if ( columns[1] == -1 && (columns[2] != -1 || columns[3] != -1) ) + { + columns[1] = columns[2]; + columns[2] = columns[3]; + columns[3] = -1; + } + if ( columns[2] == -1 && columns[3] != -1 ) + { + columns[2] = columns[3]; + columns[3] = -1; + } + + // create any notes that need to be made + if ( string[currentIndex-1] != '!' ) // this doesn't count as a note, nor should it increment time + { + for ( int d = 0; d < 4; d++ ) + { + if ( columns[d] != -1 ) + { + struct BEAT_NOTE a; + a.beat = totalBeatsProcessed; + a.column = columns[d] + doublesFactor; + a.type = TAP; + chart->push_back(a); + } + } + + prevBeatProcessed = totalBeatsProcessed; + totalBeatsProcessed += 1.0/beatDivision; + } + currentIndex++; + } + + // finally, put an end-of-song marker here + struct BEAT_NOTE endmarker; + endmarker.beat = totalBeatsProcessed; + endmarker.type = END_SONG; + chart->push_back(endmarker); +} + +UTIME getMillisecondsAtBeat(float targetBeat, std::vector *chart, int startIndex, UTIME startTime, float currentTimePerBeat) +{ + UTIME retval = startTime; + float timePerBeat = currentTimePerBeat; + float lastBeatProcessed = chart->at(startIndex).beat; + float overshoot = 0; + unsigned int i = 0; + + if ( lastBeatProcessed > targetBeat ) + { + al_trace("Searching for a past beat. Set breakpoint.\r\n"); + } + + for ( i = startIndex; i < chart->size(); i++ ) + { + // check for finishing + if ( targetBeat == chart->at(i).beat ) + { + break; + } + if ( targetBeat < chart->at(i).beat ) + { + overshoot = chart->at(i).beat - targetBeat; // fix a bug where not taking this into account was causing holds to run until the next note! + break; + } + + if ( chart->at(i).type == BPM_CHANGE ) + { + retval += ((chart->at(i).beat - lastBeatProcessed) * timePerBeat); + lastBeatProcessed = chart->at(i).beat; + } + if ( chart->at(i).type == SCROLL_STOP ) + { + retval += chart->at(i).param; + } + } + + if ( i == chart->size() ) + { + i--; + } + + retval += ((chart->at(i).beat - lastBeatProcessed - overshoot) * timePerBeat); + return retval; +} + +int readDWI(std::vector *chart, std::vector *holds, int songID, int chartType) +{ + char filename[] = "DATA/dwis/101.dwi"; + FILE* fp = NULL; + std::vector beats; + + // hopefully open the target DWI file + filename[10] = (songID/100 % 10) + '0'; + filename[11] = (songID/10 % 10) + '0'; + filename[12] = (songID % 10) + '0'; + + if ( fopen_s(&fp, filename, "rt") != 0 ) + { + allegro_message("Unable to open %s", filename); + return 0; + } + + // fix any potential bugs regarding data from one chart accidentally merging into the next chart + chart->clear(); + holds->clear(); + int gap = 0; + float timePerBeat = 400.0; // 150 BPM + + // start reading tags + readNextTag(fp); + while ( tagName[0] != 0 ) + { + if ( _strcmpi("SINGLE", tagName) == 0 ) + { + if ( _strcmpi("BASIC", tagValue) == 0 && chartType == SINGLE_MILD ) + { + processChartString(&beats, tagLeftSide, 0); + } + else if ( _strcmpi("ANOTHER", tagValue) == 0 && chartType == SINGLE_WILD ) + { + processChartString(&beats, tagLeftSide, 0); + } + } + if ( _strcmpi("DOUBLE", tagName) == 0 ) + { + if ( _strcmpi("BASIC", tagValue) == 0 && chartType == DOUBLE_MILD ) + { + processChartString(&beats, tagLeftSide, 0); + processChartString(&beats, tagRightSide, 1); + } + else if ( _strcmpi("ANOTHER", tagValue) == 0 && chartType == DOUBLE_WILD ) + { + processChartString(&beats, tagLeftSide, 0); + processChartString(&beats, tagRightSide, 1); + } + } + if ( _strcmpi("BPM", tagName) == 0 ) + { + float bpm = atof(tagValue); + timePerBeat = BPM_TO_MSEC(bpm); + + // set the initial scroll rate // WHY DOES THIS MAKE SONG NOT END? affects end of song marker somehow? + struct ARROW a; + a.timing = 0; + a.color = bpm; + a.type = BPM_CHANGE; + a.judgement = UNSET; + chart->push_back(a); + } + if ( _strcmpi("GAP", tagName) == 0 ) + { + gap = atoi(tagValue); + al_trace("gap = %d\r\n", gap); + } + if ( _strcmpi("CHANGEBPM", tagName) == 0 ) // #CHANGEBPM:992.000=95.000,1016.000=190.000; + { + char* token, *next; + token = strtok_s(tagValue, ",;", &next); + + while ( token != NULL ) + { + char leftSide[32], rightSide[32]; + char* equalsPos = strchr(token, '='); + if ( equalsPos == NULL ) + { + continue; + } + strncpy_s(leftSide, token, equalsPos - token); + strcpy_s(rightSide, equalsPos+1); + + struct BEAT_NOTE b; + b.beat = atof(leftSide)/4.0; + b.param = atof(rightSide); + b.type = BPM_CHANGE; + beats.push_back(b); + + token = strtok_s(NULL, ",;", &next); + } + } + if ( _strcmpi("FREEZE", tagName) == 0 ) // #FREEZE:668.000=327.000,1292.000=967.000; + { + char* token, *next; + token = strtok_s(tagValue, ",;", &next); + + while ( token != NULL ) + { + char leftSide[32], rightSide[32]; + char* equalsPos = strchr(token, '='); + if ( equalsPos == NULL ) + { + continue; + } + strncpy_s(leftSide, token, equalsPos - token); + strcpy_s(rightSide, equalsPos+1); + + struct BEAT_NOTE b; + b.beat = atof(leftSide)/4.0; + b.param = atof(rightSide); + b.type = SCROLL_STOP; + beats.push_back(b); + + token = strtok_s(NULL, ",;", &next); + } + } + + // next loop + readNextTag(fp); + } + + sort(beats.begin(), beats.end(), sortNoteFunction); + + // for each item in the beats vector, create a struct ARROW (real chart object) and translate 'DWI beats' to milliseconds + int numNotes = beats.size(); + float currentTime = gap; + float lastBeatProcessed = 0.0; + + for ( int i = 0; i < numNotes; i++ ) + { + struct ARROW a; + struct FREEZE f; + float beatsDifference = beats[i].beat - lastBeatProcessed; + lastBeatProcessed = beats[i].beat; + + currentTime += timePerBeat*beatsDifference; + + if (currentTime < 0) + { + continue; // uh-oh; + } + al_trace("%f\r\n", currentTime); + + switch ( beats[i].type ) + { + case TAP: + a.timing = currentTime; + a.color = calculateArrowColor(a.timing, timePerBeat); + a.type = TAP; + a.columns[0] = beats[i].column; + a.judgement = UNSET; + chart->push_back(a); + break; + case HOLD_START: + f.startTime = currentTime; + f.columns[0] = beats[i].column; + f.endTime1 = getMillisecondsAtBeat(beats[i].param, &beats, i, currentTime, timePerBeat); //it ends at beat beats[i].param + holds->push_back(f); + break; + case BPM_CHANGE: + a.timing = currentTime; + a.color = beats[i].param; + a.type = BPM_CHANGE; + a.judgement = UNSET; + chart->push_back(a); + + timePerBeat = BPM_TO_MSEC(beats[i].param); // new tempo! the length of a beat has henceforth and immediately changed + break; + case SCROLL_STOP: + a.timing = currentTime; + a.color = beats[i].param; + a.type = SCROLL_STOP; + chart->push_back(a); + + currentTime += beats[i].param; // advance the time + break; + case END_SONG: + a.timing = currentTime + 1000; // TODO: something better than this, maybe check the mp3? + a.type = END_SONG; + chart->push_back(a); + break; + default: + al_trace("IMPOSSIBLE NOTE TYPE IN readDWI() %d\r\n", beats[i].type); + } + } + + fclose(fp); + + // count the maximum score that this chart is worth. it is needed while the chart is being played + int maxScore = 0; + for ( size_t i = 0; i < chart->size(); i++ ) + { + if ( chart->at(i).type == TAP || chart->at(i).type == JUMP ) + { + maxScore += 2; + } + } + maxScore += holds->size()*2; + return maxScore; +} + +int readDWI2P(std::vector *chart, std::vector *holds, int songID, int chartType) +{ + int retval = readDWI(chart, holds, songID, chartType); + + for ( std::vector::iterator c = chart->begin(); c != chart->end(); c++ ) + { + for ( int i = 0; i < 4; i++ ) + { + if ( c->columns[i] >= 0 && c->columns[i] < 4 ) + { + c->columns[i] += 4; + } + } + } + + for ( std::vector::iterator f = holds->begin(); f != holds->end(); f++ ) + { + for ( int i = 0; i < 2; i++ ) + { + if ( f->columns[i] >= 0 && f->columns[i] < 4 ) + { + f->columns[i] += 4; + } + } + } + + return retval; +} + +int readDWICenter(std::vector *chart, std::vector *holds, int songID, int chartType) +{ + int retval = readDWI(chart, holds, songID, chartType); + + for ( std::vector::iterator c = chart->begin(); c != chart->end(); c++ ) + { + for ( int i = 0; i < 4; i++ ) + { + switch ( c->columns[i] ) + { + case 0: c->columns[i] = 3; break; + case 1: c->columns[i] = 2; break; + case 2: c->columns[i] = 5; break; + case 3: c->columns[i] = 4; break; + default: + break; + } + } + } + + for ( std::vector::iterator f = holds->begin(); f != holds->end(); f++ ) + { + for ( int i = 0; i < 2; i++ ) + { + switch ( f->columns[i] ) + { + case 0: f->columns[i] = 3; break; + case 1: f->columns[i] = 2; break; + case 2: f->columns[i] = 5; break; + case 3: f->columns[i] = 4; break; + default: + break; + } + } + } + + return retval; +} + diff --git a/src/source/gameoverMode.cpp b/src/source/gameoverMode.cpp new file mode 100644 index 0000000..78784d4 --- /dev/null +++ b/src/source/gameoverMode.cpp @@ -0,0 +1,83 @@ +// gameoverMode.cpp implements the transition between the results screen and the attract loop +// source file created by Allen Seitz 6/15/2012 + +#include "common.h" +#include "GameStateManager.h" +#include "inputManager.h" +#include "scoreManager.h" +#include "songwheelMode.h" +#include "videoManager.h" + +extern GameStateManager gs; +extern RenderingManager rm; +extern InputManager im; +extern ScoreManager sm; +extern VideoManager vm; +extern EffectsManager em; + +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; + +extern UTIME timeRemaining; +extern void renderTimeRemaining(int xc, int yc); + +void renderGameoverLoop(); +// +// + +void firstGameoverLoop() +{ + timeRemaining = 16000; + gs.loadSong(BGM_GAMEOVER); + gs.playSong(); + vm.loadScript("DATA/mov/gameover_0.seq"); + if ( sm.player[0].currentSet[gs.numSongsPerSet].songID == 126 ) // got megamix 1 for an extra stage + { + vm.loadScript("DATA/mov/gameover_1.seq"); + em.announcerQuipChance(GUY_SPECIAL_GAMEOVER, 25); + } + vm.play(); +} + +void mainGameoverLoop(UTIME dt) +{ + SUBTRACT_TO_ZERO(timeRemaining, dt); + + if ( timeRemaining > 1250 && (im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN) ) + { + timeRemaining = 1250; // player says "hurry up I want to start a new game!" + } + + if ( timeRemaining <= 0 ) + { + gs.g_currentGameMode = ATTRACT; + gs.g_gameModeTransition = 1; + gs.killSong(); + } + + renderGameoverLoop(); +} + +void renderGameoverLoop() +{ + rectfill(rm.m_backbuf, 0, 0, 640, 480, makeacol(0, 0, 0, 255)); + + vm.renderToSurface(rm.m_backbuf, 0, 0); + vm.renderToSurface(rm.m_backbuf, 320, 288); + rectfill(rm.m_backbuf, 0, 192, 640, 288, makeacol(255,255,255,255)); + + renderArtistString("GAME OVER", 107, 240+135, 600, 40); + renderArtistString("DANCE MANIAX", 320+88, 86, 600, 40); + renderBoldString("THANK YOU FOR PLAYING!", 187, 227, 640, false, (timeRemaining/200)%3 + 1); + + if ( timeRemaining < 1000 ) + { + rm.dimScreen(100-(timeRemaining/10)); + } + if ( timeRemaining > 15700 ) + { + rm.dimScreen(getValueFromRange(0, 100, (timeRemaining-15700)*100)/300); + } + + rm.flip(); +} \ No newline at end of file diff --git a/src/source/gameplayMode.cpp b/src/source/gameplayMode.cpp new file mode 100644 index 0000000..cd449e0 --- /dev/null +++ b/src/source/gameplayMode.cpp @@ -0,0 +1,1120 @@ +// gameplayMode.cpp implements the main gameplay loop for DMX +// source file created by Allen Seitz 7/18/2009 +// 12-21-09: major refactoring to move all rendering and proceedurally generated graphics to gameplayRendering + +#include "common.h" + +#include "dwi_read.h" + +#include "gameStateManager.h" +#include "inputManager.h" +#include "scoreManager.h" +#include "gameplayRendering.h" +#include "videoManager.h" + +extern int* songIDs; +extern std::string* songTitles; +extern std::string* songArtists; +extern std::string* movieScripts; + +////////////////////////////////////////////////////////////////////////////// +// Constants +////////////////////////////////////////////////////////////////////////////// +// timing windows +#define EARLY_MARVELLOUS 24 +#define EARLY_PERFECT 48 +#define EARLY_GREAT 120 +#define EARLY_GOOD 150 +//#define EARLY_BAD 248 + +#define LATE_MARVELLOUS 24 +#define LATE_PERFECT 48 +#define LATE_GREAT 120 +#define LATE_GOOD 150 +//#define LATE_BAD 248 + +#define JUMP_WINDOW 100 +#define HOLD_WINDOW 500 + +// how long it takes a BPM_CHANGE event to smoothly animate +const int BPM_UPDATE_LENGTH = 400; + +// for the between-stage banner animation +const UTIME BANNER_ANIM_LENGTH = 1500; + +const UTIME RETIRE_TIMEOUT = 30000; + +// macros +#define ISNOTE(x) (x == TAP || x == JUMP) + + +////////////////////////////////////////////////////////////////////////////// +// Program Variables +////////////////////////////////////////////////////////////////////////////// +// graphics +extern RenderingManager rm; +extern GameStateManager gs; +extern VideoManager vm; +extern ScoreManager sm; +extern EffectsManager em; +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; + +bool gameplayInitialized = false; +extern BITMAP* m_banner1; +extern BITMAP* m_banner2; + +// song transition +bool isMidTransition = false; +UTIME songTransitionTime = 0; +int rememberedCurrentStage = 1; + +// input +bool autoplay = false; +bool useAssistClap = false; +bool debugCheats = false; +extern InputManager im; +int retireTimer = 0; // for ending the game early when there is a lack of input + +// full combo +int fullComboAnimStep = 0; // 0 = not started, 1 = started +int fullComboAnimTimer = 0; +bool fullComboP1 = false; +bool fullComboP2 = false; + +// announcer +int announcerPlusPoints = 0; +int announcerMinusPoints = 0; +int announcerQuipCycle = 0; +int announcerLastCheckTotal = 0; +int announcerTargetSpeak = 0; // how many "announcer points" are scored before he makes a comment + +// songlist - for unlocks +extern SongEntry* songs; + +SAMPLE* assistClap = NULL; +SAMPLE* shockSound = NULL; + + +////////////////////////////////////////////////////////////////////////////// +// function declarations +////////////////////////////////////////////////////////////////////////////// +void doStepZoneLogic(UTIME dt, int player); +// precondition: dt > 0 +// postcondition: this function blinks the stepzone and handles other stepzone animations + +void doChartLogic(UTIME dt, int player); +// precondition: dt > 0, a frame of logic has run since the last call +// postcondition: a frame of input logic will be run + +int findNextNoteLate(int player, int column); +int findNextNoteEarly(int player, int column); +// precondition: currentChart is initialized, the column is 0-9 +// postcondition: returns a note index if successful, or -1 + +void scoreNote(int player, int judgement, int column); +// precondition: the current game state is valid +// postcondition: updates the combo, lifebar, and score + +void loadNextSong(); +// precondition: gs.player[] has a setlist setlist, the chart data is loaded +// postcondition: reloads the audio and resets certain variables + +void arrangeChart(std::vector *chart, std::vector *holds, char type, bool isDoubles); +// precondition: see description of arguments at function declaration +// postcondition: if type != 0 then the chart and holds will be modified + +int checkForExtraStages(); +// precondition: the game is between stages, and at least gs.numStagesPerCredit have been cleared +// postcondition: modifies the song choices and returns 0-2, the number of bonus songs awarded + +////////////////////////////////////////////////////////////////////////////// +// function implementations +////////////////////////////////////////////////////////////////////////////// +void firstGameplayLoop() +{ +#ifdef DMXDEBUG + debugCheats = true; +#endif + + // reset the player's stats + for ( int p = 0; p < 2; p++ ) + { + gs.player[p].nextStage(); + if ( gs.currentStage == 0 ) + { + gs.player[p].displayCombo = 0; + gs.player[p].comboColor = 0; + announcerQuipCycle = rand()%4; + retireTimer = fullComboAnimTimer = fullComboAnimStep = 0; + fullComboP1 = fullComboP2 = false; + } + } + rememberedCurrentStage = gs.currentStage; // this won't change during the transition. for most of the song it will remain the same + announcerPlusPoints = 0; + announcerMinusPoints = 0; + announcerLastCheckTotal = 0; + announcerTargetSpeak = 0; + + // load certain sound effects only during the first run of the game + if ( !gameplayInitialized ) + { + assistClap = load_sample("data/sfx/clap.wav"); + shockSound = load_sample("data/sfx/shock.wav"); + assistClap->priority = 100; + shockSound->priority = 100; + } + + // DEBUG: if booting directly into gameplay mode, set stuff + if ( gs.player[0].stagesPlayed[0] <= 0 ) + { + TRACE("DEBUG START IN GAME MODE"); + gs.player[0].stagesPlayed[0] = gs.player[0].stagesPlayed[1] = gs.player[0].stagesPlayed[2] = 101; + gs.player[0].stagesLevels[0] = gs.player[0].stagesLevels[1] = gs.player[0].stagesLevels[2] = SINGLE_WILD; + gs.player[1].stagesPlayed[0] = gs.player[1].stagesPlayed[1] = gs.player[1].stagesPlayed[2] = 101; + gs.player[1].stagesLevels[0] = gs.player[1].stagesLevels[1] = gs.player[1].stagesLevels[2] = SINGLE_WILD; + gs.isDoubles = false; + gs.isVersus = true; + } + clear_keybuf(); // also for debug + + loadNextSong(); + gameplayInitialized = true; + + im.setCooldownTime(67); // 1/15th of a second +} + +void mainGameplayLoop(UTIME dt) +{ + int p = 0; + for ( p = 0; p < (gs.isVersus ? 2 : 1); p++ ) + { + doStepZoneLogic(dt, p); + doChartLogic(dt, p); + + // process BPM gimmicks + SUBTRACT_TO_ZERO(gs.player[p].stopLength, dt); + SUBTRACT_TO_ZERO(gs.player[p].bpmUpdateTimer, dt); + gs.player[p].scrollRate = WEIGHTED_AVERAGE(gs.player[p].scrollRate, gs.player[p].newScrollRate, gs.player[p].bpmUpdateTimer, BPM_UPDATE_LENGTH); + } + + SUBTRACT_TO_ZERO(songTransitionTime, dt); + + // do full combo anim + if ( fullComboAnimStep > 0 ) + { + fullComboAnimTimer += dt; + fullComboAnimStep = fullComboAnimTimer/1000 + 1; + if ( fullComboAnimTimer >= 4000 ) + { + fullComboAnimStep = fullComboAnimTimer = 0; + fullComboP1 = fullComboP2 = false; + } + } + + renderGameplay(); + + gs.player[0].timeElapsed += dt; + gs.player[1].timeElapsed += dt; + gs.player[0].judgementTime += dt; + gs.player[1].judgementTime += dt; + + // implement the "retire" timer (game was abandoned) + if ( !autoplay ) + { + retireTimer += dt; + } + for ( int i = 0; i < 8; i++ ) + { + if ( im.getReleaseLength(i) < retireTimer ) + { + retireTimer = 0; + } + } + if ( retireTimer > 20000 ) + { + gs.g_currentGameMode = RESULTS; + gs.g_gameModeTransition = 1; + sm.savePlayersToDisk(); + em.announcerQuip(86); // say "I can't wait anymore" + return; + } + + // check for the player changing their speed-mod at the start of the song + if ( gs.player[0].timeElapsed < 10000 ) + { + if ( gs.player[0].speedMod > 10 && im.getKeyState(MENU_LEFT_1P) == JUST_DOWN ) + { + gs.player[0].speedMod -= 5; + } + if ( gs.player[0].speedMod < 80 && im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN ) + { + gs.player[0].speedMod += 5; + } + if ( gs.player[1].speedMod > 10 && im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + gs.player[1].speedMod -= 5; + } + if ( gs.player[1].speedMod < 80 && im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN ) + { + gs.player[1].speedMod += 5; + } + } + + // update the per-column judgements and the "step zone resize" effect when a panel is newly hit (DDR only) + for ( int i = 0; i < 10; i++ ) + for ( p = 0; p < (gs.isVersus ? 2 : 1); p++ ) + { + gs.player[p].columnJudgeTime[i] += dt; + + if ( im.getKeyState(i) == JUST_DOWN ) // only matters for DDR + { + gs.player[p].stepZoneResizeTimers[i] = RESIZE_TIME; + } + } + + // check for the announcer making a comment + if ( announcerPlusPoints + announcerMinusPoints > announcerLastCheckTotal ) + { + announcerLastCheckTotal = announcerPlusPoints + announcerMinusPoints; + + if ( announcerLastCheckTotal > announcerTargetSpeak ) + { + // index 0 and 2 are "long", index 1 and 3 are "short" + static int GUY_PLAYING_PERFECT[4] = { 107, 132, 99, 140 }; + static int GUY_PLAYING_GREAT[4] = { 65, 117, 98, 119 }; + static int GUY_PLAYING_UNWELL[4] = { 102, 144, 111, 146 }; + static int GUY_PLAYING_GIVEUP[4] = { 93, 127, 94, 128 }; + bool talked = false; + + if ( announcerPlusPoints > 0 && announcerMinusPoints == 0 ) + { + talked = em.announcerQuipChance(GUY_PLAYING_PERFECT[announcerQuipCycle], 10); + } + else if ( announcerPlusPoints > announcerMinusPoints*12 ) + { + talked = em.announcerQuipChance(GUY_PLAYING_GREAT[announcerQuipCycle], 10); + } + else if ( announcerPlusPoints > announcerMinusPoints ) + { + talked = em.announcerQuipChance(GUY_PLAYING_UNWELL[announcerQuipCycle], 10); + } + else if ( announcerPlusPoints < announcerMinusPoints ) + { + talked = em.announcerQuipChance(GUY_PLAYING_GIVEUP[announcerQuipCycle], 10); + } + + if ( talked ) + { + announcerLastCheckTotal = announcerPlusPoints = announcerMinusPoints = 0; + announcerQuipCycle = (announcerQuipCycle + 1) % 4; + } + } + } + + // check for the game ending suddenly due ot the battery lifebar + if ( gs.player[0].useBattery && gs.player[0].lifebarLives <= 0 ) + { + if ( !gs.isVersus || (gs.player[1].useBattery && gs.player[1].lifebarLives <= 0) ) + { + gs.g_currentGameMode = FAILURE; + gs.g_gameModeTransition = 1; + gs.killSong(); + sm.savePlayersToDisk(); + em.playSample(SFX_FAILURE_WHOOSH); + em.announcerQuip(GUY_STAGE_FAILED); + return; + } + } + + // these should only work in debug mode + while (keypressed() == TRUE && debugCheats) + { + int k = readkey() >> 8; + + if ( k == KEY_F6 ) + { + gs.player[0].useBattery = true; + gs.player[0].lifebarLives = 4; + if ( gs.isVersus ) + { + gs.player[1].useBattery = true; + gs.player[1].lifebarLives = 4; + } + } + if ( k == KEY_F7 ) + { + gs.player[0].useBattery = false; + if ( gs.isVersus ) + { + gs.player[1].useBattery = false; + } + } + + if ( k == KEY_PRTSCR ) + { + rm.screenshot(); + } + + if ( k == KEY_F10 ) + { + autoplay = !autoplay; + } + if ( k == KEY_F11 ) + { + useAssistClap = !useAssistClap; + } + if ( k == KEY_M ) + { + gs.player[0].danceManiaxMode = !gs.player[0].danceManiaxMode; + } + if ( k == KEY_COMMA ) + { + gs.player[0].drummaniaMode = !gs.player[0].drummaniaMode; + } + if ( k == KEY_OPENBRACE && fullComboAnimTimer == 0 ) + { + gs.setSongPosition(-5000); + } + if ( k == KEY_CLOSEBRACE && fullComboAnimTimer == 0 ) + { + gs.setSongPosition(+5000); + } + if ( k == KEY_K ) + { + gs.player[0].shockAnimTimer = SHOCK_ANIM_TIME; + playSFXOnce(shockSound); + } + } +} + +void doStepZoneLogic(UTIME dt, int p) +{ + gs.player[p].stepZoneBeatTimer += dt; + SUBTRACT_TO_ZERO(gs.player[p].stepZoneBlinkTimer, dt); + SUBTRACT_TO_ZERO(gs.player[p].shockAnimTimer, dt); + for ( int i = 0; i < 10; i++ ) + { + SUBTRACT_TO_ZERO(gs.player[p].stepZoneResizeTimers[i], dt); + SUBTRACT_TO_ZERO(gs.player[p].laneFlareTimers[i], dt); + } + for ( int i = 0; i < 4; i++ ) + { + SUBTRACT_TO_ZERO(gs.player[p].drummaniaCombo[i], dt); + } + + if ( gs.player[p].stepZoneBeatTimer > gs.player[p].stepZoneTimePerBeat ) + { + gs.player[p].stepZoneBeatTimer -= gs.player[p].stepZoneTimePerBeat; + gs.player[p].stepZoneBlinkTimer = gs.player[p].stepZoneTimePerBeat / 4; + gs.player[p].colorCycle = gs.player[p].colorCycle == 3 ? 0 : gs.player[p].colorCycle + 1; + } + //al_trace("%d\n", stepZoneBlinkTimer); +} + +void doChartLogic(UTIME dt, int p) +{ + unsigned int n = gs.player[p].currentNote; + + // step through the chart until the next non-current note is found + while ( gs.player[p].currentChart.size() > 0 && gs.player[p].currentChart[n].timing < gs.player[p].timeElapsed ) + { + al_trace("time elapsed is %d\r\n", gs.player[p].timeElapsed); + // mark notes as hit + if ( autoplay ) + { + if ( ISNOTE(gs.player[p].currentChart[n].type) ) + { + scoreNote(p, PERFECT, gs.player[p].currentChart[n].columns[0]); + gs.player[p].currentChart[n].judgement = PERFECT; + gs.player[p].laneFlareTimers[gs.player[p].currentChart[n].columns[0]] = HIT_FLASH_DISPLAY_TIME; + gs.player[p].laneFlareColors[gs.player[p].currentChart[n].columns[0]] = 0; + } + } + if ( useAssistClap && assistClap && ISNOTE(gs.player[p].currentChart[n].type) ) + { + playSFXOnce(assistClap); + } + if ( gs.player[p].currentChart[n].type == BPM_CHANGE ) + { + gs.player[p].bpmUpdateTimer = BPM_UPDATE_LENGTH; + gs.player[p].newScrollRate = gs.player[p].currentChart[n].color; + } + if ( gs.player[p].currentChart[n].type == SCROLL_STOP ) + { + gs.player[p].stopLength = gs.player[p].currentChart[n].color; + gs.player[p].stopTime = gs.player[p].timeElapsed; + } + if ( gs.player[p].currentChart[n].type == NEW_SECTION ) + { + // should not happen in DMX + } + if ( p == 0 && gs.player[p].currentChart[n].type == END_SONG ) // NOT A BUG! Only P1's chart ends the song (could be weird in versus mode) + { + int bestStatus = MAX(sm.player[0].currentSet[gs.currentStage].calculateStatus(), sm.player[1].currentSet[gs.currentStage].calculateStatus()); + TRACE("Best Clear Status: %d (%d %d)", bestStatus, sm.player[0].currentSet[gs.currentStage].status, sm.player[1].currentSet[gs.currentStage].status); + + gs.currentStage++; + isMidTransition = false; // prevent a crash with the fast-foward debug key + + int numBonusStages = 0; + if ( gs.currentStage >= gs.numSongsPerSet ) + { + numBonusStages = checkForExtraStages(); + } + + if ( gs.currentStage >= gs.numSongsPerSet + numBonusStages ) // if failing were possible in DMX, make sure that the bestStatus is at least CLEARED + { + if ( fullComboAnimStep > 0 ) // let the full combo animation play out on the way to the results + { + gs.currentStage--; + return; + } + gs.g_currentGameMode = RESULTS; + gs.g_gameModeTransition = 1; + sm.savePlayersToDisk(); + } + else + { + //loadNextSong(); // this goes off-sync by stage 2, restart the mode instead + gs.g_currentGameMode = GAMEPLAY; + gs.g_gameModeTransition = 1; + } + return; + } + n++; + + ++gs.player[p].currentNote; + + if ( gs.player[p].currentNote == (int)gs.player[p].currentChart.size() ) + { + gs.player[p].currentNote = (int)gs.player[p].currentChart.size() - 1; + break; + } + } + + // check for late misses + n = gs.player[p].lastLateNote; + while ( (int)n < gs.player[p].currentNote ) + { + // time to advance? + if ( gs.player[p].currentChart[n].timing + LATE_GOOD < gs.player[p].timeElapsed ) + { + if ( gs.player[p].currentChart[n].judgement == UNSET ) + { + if ( gs.player[p].currentChart[n].type == TAP || gs.player[p].currentChart[n].type == JUMP ) + { + scoreNote(p, MISS, gs.player[p].currentChart[n].columns[0]); + + // Drummania and IIDX don't have 'jumps', each note is separate, hmm.... + if ( gs.player[p].drummaniaMode && gs.player[p].currentChart[n].columns[1] != -1 ) + { + gs.player[p].columnJudgement[gs.player[p].currentChart[n].columns[1]] = MISS; + gs.player[p].columnJudgeTime[gs.player[p].currentChart[n].columns[1]] = 0; + } + gs.player[p].currentChart[n].judgement = MISS; + } + + // shock arrows use a slightly smaller late window + if ( gs.player[p].currentChart[n].type == SHOCK && (gs.player[p].currentChart[n].timing + LATE_GOOD < gs.player[p].timeElapsed) ) + { + gs.player[p].currentChart[n].judgement = OK; + scoreNote(p, OK, -1); + gs.player[p].displayCombo++; + gs.player[p].currentSongCombo++; + } + } + gs.player[p].lastLateNote++; + } + n++; + } + + // check for player input + if ( !autoplay ) + { + for (int i = 0; i < 10; i++ ) // each column + { + int lateNote = findNextNoteLate(p, i); + int earlyNote = findNextNoteEarly(p, i); + int diff = 0, closestNote = -1; + + // which is closer, the next early note, or the next late note? + if ( lateNote == -1 && earlyNote != -1 ) + { + closestNote = earlyNote; + diff = gs.player[p].currentChart[earlyNote].timing - gs.player[p].timeElapsed; + } + else if ( lateNote != -1 && earlyNote == -1 ) + { + closestNote = lateNote; + diff = gs.player[p].timeElapsed - gs.player[p].currentChart[lateNote].timing; + } + else if ( lateNote != -1 && earlyNote != -1 ) + { + int late = gs.player[p].timeElapsed - gs.player[p].currentChart[lateNote].timing; + int early = gs.player[p].currentChart[earlyNote].timing - gs.player[p].timeElapsed; + closestNote = late < early ? lateNote : earlyNote; // HELL: reverse this condition + diff = MIN(late, early); // HELL: change this to a MAX as well + } + + if ( closestNote == -1 ) + { + continue; + } + + if ( im.getKeyState(i) == JUST_DOWN ) + { + //char debugJudges[11] = "?MPGDBMon!"; + int judgement = 0; + + // check the time difference against the late or early windows + if ( gs.player[p].currentChart[closestNote].timing > gs.player[p].timeElapsed ) + { + if ( diff < EARLY_MARVELLOUS ) + judgement = MARVELLOUS; + else if ( diff < EARLY_PERFECT ) + judgement = PERFECT; + else if ( diff < EARLY_GREAT ) + judgement = GREAT; + else if ( diff < EARLY_GOOD ) + judgement = GOOD; + //else if ( diff < EARLY_BAD ) + // judgement = BAD; + + //al_trace("[%d] EARLY %c: %ld\r\n", closestNote, debugJudges[judgement], diff); + } + else + { + if ( diff < EARLY_MARVELLOUS ) + judgement = MARVELLOUS; + else if ( diff < EARLY_PERFECT ) + judgement = PERFECT; + else if ( diff < EARLY_GREAT ) + judgement = GREAT; + else if ( diff < EARLY_GOOD ) + judgement = GOOD; + //else if ( diff < EARLY_BAD ) + // judgement = BAD; + + //al_trace("[%d] LATE %c: %ld\r\n", closestNote, debugJudges[judgement], diff); + } + + // jumps need both arrows to be pressed (NOTE: unless a special exception is made, 'jumps' in DMX charts are read as separate singles!) + int col1 = gs.player[p].currentChart[closestNote].columns[0]; + int col2 = gs.player[p].currentChart[closestNote].columns[1]; + if ( gs.player[p].currentChart[closestNote].type == JUMP ) + { + if ( !im.isKeyDown(col1) || !im.isKeyDown(col2) || im.getHoldLength(col1) > JUMP_WINDOW || im.getHoldLength(col2) > JUMP_WINDOW ) + { + continue; // failed to hit the two keys simultaneously + } + } + + if ( gs.player[p].currentChart[closestNote].type == SHOCK ) + { + // oops! did the player tap a shock arrow? + if ( im.isKeyInUse(i) && judgement >= MARVELLOUS && judgement <= GOOD && gs.player[p].currentChart[closestNote].judgement == UNSET ) + { + scoreNote(p, NG, -1); + gs.player[p].currentChart[closestNote].judgement = NG; + gs.player[p].shockAnimTimer = SHOCK_ANIM_TIME; + playSFXOnce(shockSound); + } + } + else + { + scoreNote(p,judgement, col1); + if ( judgement == MARVELLOUS || judgement == PERFECT || judgement == GREAT ) + { + gs.player[p].laneFlareTimers[col1] = HIT_FLASH_DISPLAY_TIME; + gs.player[p].laneFlareColors[col1] = judgement == MARVELLOUS ? 0 : 1; + if ( col2 != -1 ) + { + gs.player[p].laneFlareTimers[col2] = HIT_FLASH_DISPLAY_TIME; + gs.player[p].laneFlareColors[col2] = judgement == MARVELLOUS ? 0 : 1; + } + } + gs.player[p].currentChart[closestNote].judgement = judgement; + } + } + else if ( im.getKeyState(i) == HELD_DOWN ) + { + if ( gs.player[p].currentChart[closestNote].type == SHOCK ) + { + // oops! did the player hold a shock arrow + if ( im.isKeyInUse(i) && im.getHoldLength(i) > JUMP_WINDOW && gs.player[p].currentChart[closestNote].judgement == UNSET ) + { + scoreNote(p, NG, -1); + gs.player[p].currentChart[closestNote].judgement = NG; + gs.player[p].shockAnimTimer = SHOCK_ANIM_TIME; + playSFXOnce(shockSound); + } + } + } + } + } + + // process freeze arrow logic + n = gs.player[p].currentFreeze; + while ( n < (int)gs.player[p].freezeArrows.size() ) + { + int col1 = gs.player[p].freezeArrows[n].columns[0]; + int col2 = gs.player[p].freezeArrows[n].columns[1]; + + // first, is this hold graded? if so no further work needs to be done on it + if ( gs.player[p].freezeArrows[n].judgement == OK || gs.player[p].freezeArrows[n].judgement == NG ) + { + UTIME tailTime = 3000 + MAX(gs.player[p].freezeArrows[n].endTime1, gs.player[p].freezeArrows[n].endTime2); + bool holdIsAncientHistory = (gs.player[p].freezeArrows[n].judgement == NG && tailTime < gs.player[p].timeElapsed) || gs.player[p].freezeArrows[n].judgement == OK; + + if ( (int)n == gs.player[p].currentFreeze && holdIsAncientHistory ) + { + gs.player[p].currentFreeze++; + } + n++; + continue; + } + + // did the player start this hold? + if ( gs.player[p].freezeArrows[n].startTime < gs.player[p].timeElapsed && im.isKeyDown(col1) && (col2 == -1 || im.isKeyDown(col2)) ) + { + gs.player[p].freezeArrows[n].isHeld = 1; + } + + // next, would this hold melt? update the melt time + if ( gs.player[p].freezeArrows[n].startTime < gs.player[p].timeElapsed || gs.player[p].freezeArrows[n].isHeld == 1 ) + { + // update flashing (holding) animation + if ( gs.player[p].freezeArrows[n].isHeld == 1 ) + { + gs.player[p].laneFlareTimers[col1] = HIT_FLASH_DISPLAY_TIME; + gs.player[p].laneFlareColors[col1] = 2; //(gs.player[p].timeElapsed / 50) % 2 + 1; + } + + // autoplay needs this to render properly + if ( autoplay ) + { + gs.player[p].freezeArrows[n].isHeld = 1; + } + + if ( (!im.isKeyDown(col1) || gs.player[p].freezeArrows[n].isHeld != 1 ) && !autoplay ) + { + gs.player[p].freezeArrows[n].meltTime1 += dt; + } + else if ( gs.player[p].freezeArrows[n].isHeld == 1 ) + { + gs.player[p].freezeArrows[n].meltTime1 = 0; + } + + if ( col2 != -1 ) + { + // update flashing (holding) animation on column 2 + if ( gs.player[p].freezeArrows[n].isHeld == 1 ) + { + gs.player[p].laneFlareTimers[col2] = HIT_FLASH_DISPLAY_TIME; + gs.player[p].laneFlareColors[col2] = 2; //(gs.player[p].timeElapsed / 50) % 2 + 1; + } + + if ( (!im.isKeyDown(col2) || gs.player[p].freezeArrows[n].isHeld != 1 ) && !autoplay ) + { + gs.player[p].freezeArrows[n].meltTime2 += dt; + } + else if ( gs.player[p].freezeArrows[n].isHeld == 1 ) + { + gs.player[p].freezeArrows[n].meltTime2 = 0; + } + } + + // did it completely melt? + if ( gs.player[p].freezeArrows[n].meltTime1 > HOLD_WINDOW || gs.player[p].freezeArrows[n].meltTime2 > HOLD_WINDOW ) + { + gs.player[p].freezeArrows[n].judgement = NG; + scoreNote(p, NG, gs.player[p].freezeArrows[n].columns[0]); + gs.player[p].freezeArrows[n].isHeld = 0; + + gs.player[p].laneFlareColors[col1] = 0; + if ( col2 != -1 ) + { + gs.player[p].laneFlareColors[col2] = 0; + } + } + } + + // next, is this hold completed OK? + if ( gs.player[p].freezeArrows[n].endTime1 <= gs.player[p].timeElapsed && ( gs.player[p].freezeArrows[n].endTime2 == -1 || gs.player[p].freezeArrows[n].endTime2 <= gs.player[p].timeElapsed ) ) + { + // but for really short hold notes, if you never even began to hold them, then they're NG + if ( gs.player[p].freezeArrows[n].isHeld == 0 ) + { + gs.player[p].freezeArrows[n].judgement = NG; + scoreNote(p, NG, gs.player[p].freezeArrows[n].columns[0]); + } + else + { + gs.player[p].freezeArrows[n].judgement = OK; + scoreNote(p, OK, gs.player[p].freezeArrows[n].columns[0]); + + gs.player[p].laneFlareTimers[col1] = HIT_FLASH_DISPLAY_TIME; + gs.player[p].laneFlareColors[col1] = 4; + if ( col2 != -1 ) + { + gs.player[p].laneFlareTimers[col2] = HIT_FLASH_DISPLAY_TIME; + gs.player[p].laneFlareColors[col2] = 4; + } + } + gs.player[p].freezeArrows[n].isHeld = 0; + } + + // finally, are we done looping through freeze arrows in the early+late window? + if ( gs.player[p].freezeArrows[n].startTime >= gs.player[p].timeElapsed + EARLY_GOOD ) + { + break; + } + n++; + } +} + +int findNextNoteLate(int p, int column) +{ + unsigned int n = gs.player[p].currentNote - 1; + UTIME endTime = gs.player[p].timeElapsed - LATE_GOOD; + + if ( gs.player[p].currentNote == 0 || gs.player[p].timeElapsed < LATE_GOOD ) + { + return -1; // prevent a crash + } + + while ( n >= 0 && gs.player[p].currentChart[n].timing > endTime ) + { + if ( ISNOTE(gs.player[p].currentChart[n].type) && gs.player[p].currentChart[n].judgement == UNSET ) + { + if ( gs.player[p].currentChart[n].columns[0] == column || gs.player[p].currentChart[n].columns[1] == column ) + { + return n; + } + } + if ( gs.player[p].currentChart[n].type == SHOCK ) + { + return n; + } + + if ( n == 0 ) + { + break; + } + else + { + n--; + } + } + return -1; +} + +int findNextNoteEarly(int p, int column) +{ + unsigned int n = gs.player[p].currentNote; + UTIME endTime = gs.player[p].timeElapsed + EARLY_GOOD; + + while ( n < (int)gs.player[p].currentChart.size() && gs.player[p].currentChart[n].timing < endTime ) + { + if ( ISNOTE(gs.player[p].currentChart[n].type) && gs.player[p].currentChart[n].judgement == UNSET ) + { + if ( gs.player[p].currentChart[n].columns[0] == column || gs.player[p].currentChart[n].columns[1] == column ) + { + return n; + } + } + if ( gs.player[p].currentChart[n].type == SHOCK ) + { + return n; + } + n++; + } + return -1; +} + +void scoreNote(int p, int judgement, int column) +{ + // set the judgement display + if ( (gs.player[p].drummaniaMode || judgement == OK || judgement == NG) && column != -1 ) + { + gs.player[p].columnJudgement[column] = judgement; + gs.player[p].columnJudgeTime[column] = 0; + } + else + { + gs.player[p].lastJudgement = judgement; + gs.player[p].judgementTime = 0; + } + + // tally the judgement + switch (judgement) + { + case MARVELLOUS: + case PERFECT: + case OK: + sm.player[p].currentSet[gs.currentStage].perfects += 1; break; + case GREAT: + sm.player[p].currentSet[gs.currentStage].greats += 1; break; + case GOOD: + sm.player[p].currentSet[gs.currentStage].goods += 1; break; + //case BAD: + case MISS: + case NG: + sm.player[p].currentSet[gs.currentStage].misses += 1; break; + default: + TRACE("Strange judgement encountered: %d", judgement); + } + sm.player[p].currentSet[gs.currentStage].calculateGrade(); + sm.player[p].currentSet[gs.currentStage].calculatePoints(); + gs.player[p].lifebarPercent = sm.player[p].currentSet[gs.currentStage].getScore()/1000; // yes really + + // how does this judgement affect the combo? + if ( judgement == MISS || judgement == NG ) + { + if ( gs.player[p].displayCombo >= 500 ) + { + em.announcerQuip(126); // ouch! your combos end here + announcerLastCheckTotal = 0; + } + gs.player[p].displayCombo = 0; + gs.player[p].currentSongCombo = 0; + gs.player[p].comboColor = COMBO_MISS; + announcerMinusPoints++; + if ( gs.player[p].useBattery && gs.player[p].lifebarLives > 0 ) + { + SUBTRACT_TO_ZERO(gs.player[p].lifebarLives, 1); + em.playSample(SFX_BATTERY_ZAP); + } + } + if ( judgement == MARVELLOUS || judgement == PERFECT || judgement == GREAT || judgement == GOOD ) + { + gs.player[p].currentSongCombo++; + gs.player[p].displayCombo++; + announcerPlusPoints++; + + // what happens to the drummania combo animation? + gs.player[p].drummaniaCombo[0] = DRUMMANIA_COMBO_BOUNCE_TIME; + if ( gs.player[p].displayCombo % 10 == 0 ) + { + gs.player[p].drummaniaCombo[1] = DRUMMANIA_COMBO_BOUNCE_TIME; + } + if ( gs.player[p].displayCombo % 100 == 0 ) + { + gs.player[p].drummaniaCombo[2] = DRUMMANIA_COMBO_BOUNCE_TIME; + em.announceCombo(gs.player[p].displayCombo); + } + if ( gs.player[p].displayCombo % 1000 == 0 ) + { + gs.player[p].drummaniaCombo[3] = DRUMMANIA_COMBO_BOUNCE_TIME; + } + } + + // update the max combo (NOTE: this needs to be tracked different from the display combo) + if ( gs.player[p].currentSongMaxCombo < gs.player[p].currentSongCombo ) + { + gs.player[p].currentSongMaxCombo = gs.player[p].currentSongCombo; + } + if ( sm.player[p].currentSet[gs.currentStage].maxCombo < gs.player[p].currentSongMaxCombo ) + { + sm.player[p].currentSet[gs.currentStage].maxCombo = gs.player[p].currentSongMaxCombo; + } + + // set the combo color + if ( judgement == MARVELLOUS && gs.player[p].displayCombo == 1 ) + { + gs.player[p].comboColor = COMBO_MARVELOUS; + } + if ( judgement == PERFECT && (gs.player[p].comboColor == COMBO_MARVELOUS || gs.player[p].displayCombo == 1) ) + { + gs.player[p].comboColor = COMBO_PERFECT; + } + if ( judgement == GREAT && (gs.player[p].comboColor == COMBO_MARVELOUS || gs.player[p].comboColor == COMBO_PERFECT || gs.player[p].displayCombo == 1) ) + { + gs.player[p].comboColor = COMBO_GREAT; + } + + // did a full combo happen? start the animation + int totalSteps = sm.player[p].currentSet[rememberedCurrentStage].perfects + sm.player[p].currentSet[rememberedCurrentStage].greats + sm.player[p].currentSet[rememberedCurrentStage].goods; + if ( totalSteps == sm.player[p].currentSet[rememberedCurrentStage].maxPoints/2 ) // works for holds, since OK == perfect and NG == miss + { + em.playSample(SFX_FULL_COMBO_SPLASH); + fullComboAnimStep = 1; + fullComboAnimTimer = 0; + if ( p == 0 ) + { + fullComboP1 = true; + } + else + { + fullComboP2 = true; + } + } +} + +void loadNextSong() +{ + int p1maxscore = 0, p2maxscore = 0; + + if ( gs.isVersus ) + { + p1maxscore = readDWI(&gs.player[0].currentChart, &gs.player[0].freezeArrows, gs.player[0].stagesPlayed[gs.currentStage], gs.player[0].stagesLevels[gs.currentStage]); + p2maxscore = readDWI2P(&gs.player[1].currentChart, &gs.player[1].freezeArrows, gs.player[1].stagesPlayed[gs.currentStage], gs.player[1].stagesLevels[gs.currentStage]); + } + else if ( !gs.isDoubles && !gs.isVersus ) // single, center play + { + p1maxscore = readDWICenter(&gs.player[0].currentChart, &gs.player[0].freezeArrows, gs.player[0].stagesPlayed[gs.currentStage], gs.player[0].stagesLevels[gs.currentStage]); + } + else + { + p1maxscore = readDWI(&gs.player[0].currentChart, &gs.player[0].freezeArrows, gs.player[0].stagesPlayed[gs.currentStage], gs.player[0].stagesLevels[gs.currentStage]); + } + + for ( int p = 0; p < (gs.isVersus ? 2 : 1); p++ ) + { + gs.player[p].nextStage(); + + sm.player[p].currentSet[gs.currentStage].resetData(); + sm.player[p].currentSet[gs.currentStage].time = time(NULL); + sm.player[p].currentSet[gs.currentStage].status = STATUS_NONE; + sm.player[p].currentSet[gs.currentStage].songID = gs.player[p].stagesPlayed[gs.currentStage]; + sm.player[p].currentSet[gs.currentStage].chartID = gs.player[p].stagesLevels[gs.currentStage]; + sm.player[p].currentSet[gs.currentStage].grade = GRADE_NONE; + sm.player[p].currentSet[gs.currentStage].maxPoints = p == 0 ? p1maxscore : p2maxscore; + if ( gs.currentStage != 0 ) + { + sm.player[p].currentSet[gs.currentStage - 1].calculateStatus(); + } + + if ( gs.player[p].arrangeModifier > 0 ) + { + arrangeChart(&gs.player[p].currentChart, &gs.player[p].freezeArrows, gs.player[p].arrangeModifier, gs.isDoubles); + } + } + + gs.loadSong(gs.player[0].stagesPlayed[gs.currentStage]); + vm.loadScript(movieScripts[songID_to_listID(gs.player[0].stagesPlayed[gs.currentStage])].c_str()); // I love the "])]" on this line!!! + gs.playSong(); + vm.play(); + isMidTransition = true; + songTransitionTime = BANNER_ANIM_LENGTH; + + announcerTargetSpeak = (p1maxscore + p2maxscore)/7; // speak approximately 7 times per song (although it is both random and dependant on other factors) +} + +// chart - list of tap notes +// holds - list of hold notes +// type - 0 = no change, 1 = mirror (horizontal), 2 = upside down (v-mirror), 3 = shuffle +// isDoubles - matters for some types +void arrangeChart(std::vector *chart, std::vector *holds, char type, bool isDoubles) +{ + char arrangeMatrix[4][2][8] = { + { {0,1,2,3,4,5,6,7}, {0,1,2,3,4,5,6,7} }, // original chart + { {3,2,1,0,3,2,1,0}, {7,6,5,4,3,2,1,0} }, // mirror + { {1,0,3,2,1,0,3,2}, {1,0,3,2,5,4,7,6} }, // upside down + { {2,1,0,3,2,1,0,3}, {0,1,2,3,4,5,6,7} }, // one shuffle pattern + }; + char doubles = isDoubles ? 1 : 0; + + for ( std::vector::iterator c = chart->begin(); c != chart->end(); c++ ) + { + for ( int i = 0; i < 4; i++ ) + { + if ( c->columns[i] >= 0 && c->columns[i] <= 7 ) // -1 means no note here (very important for triples + { + c->columns[i] = arrangeMatrix[type][doubles][c->columns[i]]; + } + } + } + + UNUSED(holds); // modifying the head of the freezes automatically moves the holds +} + +int checkForExtraStages() +{ + bool awardedExtra = false; + bool awardedEncore = false; + + awardedExtra = gs.player[0].stagesPlayed[gs.numSongsPerSet] > 0; // extra stage was already awarded + awardedEncore = gs.player[0].stagesPlayed[gs.numSongsPerSet+1] > 0; // encore stage was already awarded + + if ( !awardedExtra ) + { + // basic extra stage: are your combined scores above 900,000 per stage? + int sumP1 = 0, sumP2 = 0; + int levelP1 = 0, levelP2 = 0; + for ( int i = 0; i < gs.numSongsPerSet; i++ ) + { + sumP1 += sm.player[0].currentSet[i].getScore(); + sumP2 += sm.player[1].currentSet[i].getScore(); + levelP1 += sm.player[0].currentSet[i].chartID; + levelP2 += sm.player[1].currentSet[i].chartID; + } + sumP1 /= gs.numSongsPerSet; + sumP2 /= gs.numSongsPerSet; + levelP1 /= gs.numSongsPerSet; + levelP2 /= gs.numSongsPerSet; + if ( levelP1 % SINGLE_ANOTHER == SINGLE_ANOTHER ) + { + levelP1 -= 1; + } + if ( levelP2 % SINGLE_ANOTHER == SINGLE_ANOTHER ) + { + levelP2 -= 1; + } + + // check for (126) "Jet World + Drop Out + Paranoia Max type 2" -OR- (303) POSSESSION if versus + if ( sumP1 >= 900000 || sumP2 >= 900000 ) + { + awardedExtra = true; + gs.player[0].stagesPlayed[gs.numSongsPerSet] = 126; + gs.player[0].stagesLevels[gs.numSongsPerSet] = levelP1; + gs.player[0].useBattery = true; + gs.player[0].lifebarLives = 4; + if ( gs.isVersus ) + { + gs.player[1].stagesPlayed[gs.numSongsPerSet] = 126; + gs.player[1].stagesLevels[gs.numSongsPerSet] = levelP2; + gs.player[1].useBattery = true; + gs.player[1].lifebarLives = 4; + } + + // I realize that I just checked for versus a minute ago. This will change soon. + if ( gs.isVersus || gs.isDoubles ) + { + gs.player[0].stagesPlayed[gs.numSongsPerSet] = 303; + gs.player[1].stagesPlayed[gs.numSongsPerSet] = 303; + gs.player[0].lifebarLives = 5; + gs.player[1].lifebarLives = 5; + em.announcerQuip(GUY_EARN_SPECIAL_EXTRA); + } + else + { + em.announcerQuip(GUY_EARN_EXTRA); + } + } + } + + // check for permanently unlocking an extra stage by scoring 90% while on the extra stage + if ( awardedExtra ) + { + int songIndex = songID_to_listID(gs.player[0].stagesPlayed[gs.numSongsPerSet]); + if ( songIndex == -1 ) + { + songIndexError(gs.player[0].stagesPlayed[gs.numSongsPerSet]); + } + if ( awardedExtra && songs[songIndex].unlockFlag == UNLOCK_METHOD_EXTRA_STAGE ) + { + if ( sm.player[0].currentSet[gs.numSongsPerSet].getScore() >= 900000 ) + { + sm.player[0].currentSet[gs.numSongsPerSet].unlockStatus = 1; + } + if ( sm.player[1].currentSet[gs.numSongsPerSet].getScore() >= 900000 ) + { + sm.player[0].currentSet[gs.numSongsPerSet].unlockStatus = 1; + } + } + } + + return 0 + (awardedExtra) + (awardedEncore); +} \ No newline at end of file diff --git a/src/source/gameplayRendering.cpp b/src/source/gameplayRendering.cpp new file mode 100644 index 0000000..323f906 --- /dev/null +++ b/src/source/gameplayRendering.cpp @@ -0,0 +1,796 @@ +// gameplayRendering.cpp contains functions for rendering the game loop +// source file created by Allen Seitz 12-20-09 +// 12-22-09: major refactoring to isolate DDR specific functions +// 12-26-11: yet again, even more refactoring for each game mode (as well as adding DMX) + +#include "gameStateManager.h" +#include "gameplayRendering.h" +#include "scoreManager.h" +#include "specialEffects.h" +#include "videoManager.h" + +extern RenderingManager rm; +extern GameStateManager gs; +extern ScoreManager sm; +extern VideoManager vm; +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; +extern int retireTimer; +extern int fullComboAnimStep; // 0 = not started, 1 = started +extern int fullComboAnimTimer; +extern bool fullComboP1; +extern bool fullComboP2; + +// song transition +extern bool isMidTransition; +extern UTIME songTransitionTime; +extern BITMAP** m_banners; +extern const UTIME BANNER_ANIM_LENGTH; +const UTIME BANNER_ANIM_STEP = 500; + + +////////////////////////////////////////////////////////////////////////////// +// Graphics +////////////////////////////////////////////////////////////////////////////// +BITMAP* m_stepZoneSource[6][2]; +BITMAP* m_arrowSource[6][4][9]; // 6 arrows x 4 animation frames x 9 colors (4 vivid, 1 grey, 2 freeze, 1 shock, 1 melt) +BITMAP* m_judgements[8][3]; // the second dimension is only used for M/P/G +BITMAP* m_columnJudgements[8][3]; +BITMAP* m_combo[5]; +BITMAP* m_comboNums; +BITMAP* m_flashes[4][2]; // 4 frames x 6 colors, played on top of the step zone for marvellouses and OKs +BITMAP* m_flares[6][4][3]; // 6 arrows x 4 animations frames x 3 colors, for when a note is hit +BITMAP* m_stageDisplay; +BITMAP* m_grades; +BITMAP* m_banner1 = NULL; +BITMAP* m_banner2 = NULL; +BITMAP* m_fullComboAnim[11]; +BITMAP* m_fcRays[4]; + +//BITMAP* m_notesBM[3]; // 2 colors + shock color, animations are built in +//BITMAP* m_notesDM[6]; // 5 colors + shock color, animations are built in +BITMAP* m_comboNumsDM; +BITMAP* m_comboWordDM; + +BITMAP* m_dmxHeader; +BITMAP* m_dmxFooter; +BITMAP* m_leftLifeGaugeCover; +BITMAP* m_rightLifeGaugeCover; +BITMAP* m_leftSideHalo[4][2]; +BITMAP* m_rightSideHalo[4][2]; + +BITMAP* m_stepZoneSourceDMX[2]; +BITMAP* m_notesDMX[3]; + +BITMAP* m_dmxCombos[8]; +BITMAP* m_dmxFevers[8]; +BITMAP* m_comboDMX; +BITMAP* m_judgementsDMX; +BITMAP* m_dmxFireworks[2][6][16]; + +// the timer is global - it is also used on other menus +BITMAP* m_time; +BITMAP* m_timeDigits[2]; + + +////////////////////////////////////////////////////////////////////////////// +// Functions +////////////////////////////////////////////////////////////////////////////// +int getNumColumns() +{ + int numColumns = 4; + if ( gs.isSolo ) + { + numColumns += 2; + } + if ( gs.isDoubles ) + { + numColumns += 4; + } + return numColumns; +} + +void loadGameplayGraphics() +{ + int arrow = 0, frame = 0, color = 0; + BITMAP* temp = NULL; + + // load these once and use them throughout the program + m_time = loadImage("DATA/songwheel/time.tga"); + m_timeDigits[0] = loadImage("DATA/songwheel/timer_blue.tga"); + m_timeDigits[1] = loadImage("DATA/songwheel/timer_red.tga"); + m_stageDisplay = loadImage("DATA/gameplay/stage_nums.tga"); + m_grades = loadImage("DATA/gameplay/grades.tga"); + + // load graphics once and leave them loaded for the whole program (meh) + m_stepZoneSource[0][0] = loadImage("DATA/gameplay/SPR_DanceZoneLR_02.tga"); + m_stepZoneSource[1][0] = loadImage("DATA/gameplay/SPR_DanceZoneSolo_02.tga"); + m_stepZoneSource[2][0] = loadImage("DATA/gameplay/SPR_DanceZoneUD_02.tga"); + m_stepZoneSource[3][0] = loadImage("DATA/gameplay/SPR_DanceZoneUD_02.tga"); + m_stepZoneSource[4][0] = loadImage("DATA/gameplay/SPR_DanceZoneSolo_02.tga"); + m_stepZoneSource[5][0] = loadImage("DATA/gameplay/SPR_DanceZoneLR_02.tga"); + m_stepZoneSource[0][1] = loadImage("DATA/gameplay/SPR_DanceZoneLR_01.tga"); + m_stepZoneSource[1][1] = loadImage("DATA/gameplay/SPR_DanceZoneSolo_01.tga"); + m_stepZoneSource[2][1] = loadImage("DATA/gameplay/SPR_DanceZoneUD_01.tga"); + m_stepZoneSource[3][1] = loadImage("DATA/gameplay/SPR_DanceZoneUD_01.tga"); + m_stepZoneSource[4][1] = loadImage("DATA/gameplay/SPR_DanceZoneSolo_01.tga"); + m_stepZoneSource[5][1] = loadImage("DATA/gameplay/SPR_DanceZoneLR_01.tga"); + draw_sprite_v_flip(m_stepZoneSource[3][0], m_stepZoneSource[2][0], 0, 0); + draw_sprite_h_flip(m_stepZoneSource[4][0], m_stepZoneSource[1][0], 0, 0); + draw_sprite_h_flip(m_stepZoneSource[5][0], m_stepZoneSource[0][0], 0, 0); + draw_sprite_v_flip(m_stepZoneSource[3][1], m_stepZoneSource[2][1], 0, 0); + draw_sprite_h_flip(m_stepZoneSource[4][1], m_stepZoneSource[1][1], 0, 0); + draw_sprite_h_flip(m_stepZoneSource[5][1], m_stepZoneSource[0][1], 0, 0); + + ////////////////////////////////////////////////////////////////////////// + // allocate memory, pre-flip, and pre-color each arrow + ////////////////////////////////////////////////////////////////////////// + for ( arrow = 0; arrow < 6; arrow++ ) + for ( frame = 0; frame < 4; frame++ ) + for ( color = 0; color < 9; color++ ) + { + m_arrowSource[arrow][frame][color] = create_bitmap_ex(32, 64, 64); + if ( arrow >= 3 ) // because draw_sprite_h_flip omits the mask color + { + clear_to_color(m_arrowSource[arrow][frame][color], 0xFF00FF); + } + } + + temp = loadImage("DATA/gameplay/SPR_ArrowLR.tga"); + for ( frame = 0; frame < 4; frame++ ) + for ( color = 0; color < 9; color++ ) + { + blit(temp, m_arrowSource[0][frame][color], 0, frame*64, 0, 0, 64, 64); + draw_sprite_h_flip(m_arrowSource[5][frame][color], m_arrowSource[0][frame][color], 0, 0); + } + destroy_bitmap(temp); + + temp = loadImage("DATA/gameplay/SPR_ArrowSolo.tga"); + for ( frame = 0; frame < 4; frame++ ) + for ( color = 0; color < 9; color++ ) + { + blit(temp, m_arrowSource[1][frame][color], 0, frame*64, 0, 0, 64, 64); + draw_sprite_h_flip(m_arrowSource[4][frame][color], m_arrowSource[1][frame][color], 0, 0); + } + destroy_bitmap(temp); + + temp = loadImage("DATA/gameplay/SPR_ArrowUD.tga"); + for ( frame = 0; frame < 4; frame++ ) + for ( color = 0; color < 9; color++ ) + { + blit(temp, m_arrowSource[2][frame][color], frame*64, 0, 0, 0, 64, 64); + draw_sprite_v_flip(m_arrowSource[3][frame][color], m_arrowSource[2][frame][color], 0, 0); + } + destroy_bitmap(temp); + + // arrow 8 is the shock arrow, and looks different from the rest + for ( arrow = 0; arrow < 6; arrow++ ) + for ( frame = 0; frame < 4; frame++ ) + { + replaceColor(m_arrowSource[arrow][frame][7], 0x4E4E4E, makecol(255, 255, 255)); + replaceColor(m_arrowSource[arrow][frame][7], 0xFFFFFF, makecol(255, 255, 255)); + } + + //* pre-color the first four arrows, leave the 4th intentionally grey, make the 5th green for holds, and make the 7th blue for shocks + for ( color = 0; color < 8; color++ ) + { + if ( color == 4 ) + { + continue; + } + + for ( arrow = 0; arrow < 6; arrow++ ) + for ( frame = 0; frame < 4; frame++ ) + { + for ( int y = 0; y < 64; y++ ) + for ( int x = 0; x < 64; x++ ) + { + unsigned long c = ((long *)m_arrowSource[arrow][frame][color]->line[y])[x]; + int a = (c & 0xFF000000) >> 24; + int r = (c & 0x00FF0000) >> 16; + int g = (c & 0x0000FF00) >> 8; + int b = (c & 0x000000FF); + if ( (r>0 || g>0 || b>0) && c != 0xFFFFFF && c != 0x4E4E4E && c != 0xFF00FF ) // skip three specific colors in the asset + { + int blendedR = WEIGHTED_AVERAGE((arrowColors[color][0]), (arrowColors[color+1][0]), y, 64); + int blendedG = WEIGHTED_AVERAGE((arrowColors[color][1]), (arrowColors[color+1][1]), y, 64); + int blendedB = WEIGHTED_AVERAGE((arrowColors[color][2]), (arrowColors[color+1][2]), y, 64); + r = WEIGHTED_AVERAGE(blendedR, ARROW_BRIGHTNESS, r, 256); + g = WEIGHTED_AVERAGE(blendedG, ARROW_BRIGHTNESS, g, 256); + b = WEIGHTED_AVERAGE(blendedB, ARROW_BRIGHTNESS, b, 256); + //r = r * (78+(y/2)) / 100; // implement a weak shading + //g = g * (78+(y/2)) / 100; + //b = b * (78+(y/2)) / 100; + c = (a << 24) + (r << 16) + (g << 8) + b; + ((long *)m_arrowSource[arrow][frame][color]->line[y])[x] = c; + } + } + } + } + + // arrow 7 is the same as arrow 6, but the black outline is replaced with the freeze arrow color + for ( arrow = 0; arrow < 6; arrow++ ) + for ( frame = 0; frame < 4; frame++ ) + { + blit(m_arrowSource[arrow][frame][5], m_arrowSource[arrow][frame][6], 0, 0, 0, 0, 64, 64); + replaceColor(m_arrowSource[arrow][frame][6], 0, makecol(arrowColors[5][0], arrowColors[5][1], arrowColors[5][2])); + } + + // arrow 8 is the shock arrow, and looks different from the rest (add dark lines and lightning) + for ( arrow = 0; arrow < 6; arrow++ ) + for ( frame = 0; frame < 4; frame++ ) + { + // first replace the outline color + replaceColor(m_arrowSource[arrow][frame][7], 0, SHOCK_OUTLINE_COLOR); + + int Ys[9] = {11, 12, 13, 31, 32, 33, 51, 52, 53}; + + // second draw a few dark lines through the arrow to give it a texture + for ( int yi = 0; yi < 9; yi++ ) + for ( int x = 0; x < 64; x++ ) + { + unsigned long c = ((long *)m_arrowSource[arrow][frame][7]->line[Ys[yi]])[x]; + int r = (c & 0x00FF0000) >> 16; + int g = (c & 0x0000FF00) >> 8; + int b = (c & 0x000000FF); + if ( c != SHOCK_OUTLINE_COLOR && c != 0xFF00FF ) // skip two specific colors in the asset + { + r = (r * 4) / ((yi%3)+5); + g = (g * 4) / ((yi%3)+5); + b = (b * 4) / ((yi%3)+5); + c = (r << 16) + (g << 8) + b; + ((long *)m_arrowSource[arrow][frame][7]->line[Ys[yi]])[x] = c; + } + } + } + + // arrow 9 is the melted freeze arrow, and is basically just black + for ( arrow = 0; arrow < 6; arrow++ ) + for ( frame = 0; frame < 4; frame++ ) + { + // darken the entire image + for ( int y = 0; y < 64; y++ ) + for ( int x = 0; x < 64; x++ ) + { + unsigned long c = ((long *)m_arrowSource[arrow][frame][8]->line[y])[x]; + if ( c != 0xFF00FF ) + { + int r = ((c & 0x00FF0000) >> 16) / 2; + int g = ((c & 0x0000FF00) >> 8) / 2; + int b = (c & 0x000000FF) / 2; + c = (r << 16) + (g << 8) + b; + ((long *)m_arrowSource[arrow][frame][8]->line[y])[x] = c; + } + } + } + + //*/ + ////////////////////////////////////////////////////////////////////////// + // end overly-complicated arrow graphics initialization + ////////////////////////////////////////////////////////////////////////// + + // load and tint each Drummania note + /* + for ( color = 0; color < 6; color++ ) + { + m_notesDM[color] = loadImage("DATA/gameplay/drummania/SPR_DM.tga"); + + for ( int y = 0; y < 32; y++ ) + for ( int x = 0; x < 114; x++ ) + { + unsigned long c = ((long *)m_notesDM[color]->line[y])[x]; + int r = (c & 0x00FF0000) >> 16; + int g = (c & 0x0000FF00) >> 8; + int b = (c & 0x000000FF); + r = WEIGHTED_AVERAGE(drummaniaColors[color][0], ARROW_BRIGHTNESS, r, 256); + g = WEIGHTED_AVERAGE(drummaniaColors[color][1], ARROW_BRIGHTNESS, g, 256); + b = WEIGHTED_AVERAGE(drummaniaColors[color][2], ARROW_BRIGHTNESS, b, 256); + c = (r << 16) + (g << 8) + b; + ((long *)m_notesDM[color]->line[y])[x] = c; + } + } + //*/ + + // load and tint each beatmania note + /* + for ( color = 0; color < 3; color++ ) + { + m_notesBM[color] = loadImage("DATA/gameplay/beatmania/SPR_BM.tga"); + + for ( int y = 0; y < 56; y++ ) + for ( int x = 0; x < 90; x++ ) + { + unsigned long c = ((long *)m_notesBM[color]->line[y])[x]; + int r = (c & 0x00FF0000) >> 16; + int g = (c & 0x0000FF00) >> 8; + int b = (c & 0x000000FF); + r = WEIGHTED_AVERAGE(beatmaniaColors[color][0], ARROW_BRIGHTNESS, r, 256); + g = WEIGHTED_AVERAGE(beatmaniaColors[color][1], ARROW_BRIGHTNESS, g, 256); + b = WEIGHTED_AVERAGE(beatmaniaColors[color][2], ARROW_BRIGHTNESS, b, 256); + c = (r << 16) + (g << 8) + b; + ((long *)m_notesBM[color]->line[y])[x] = c; + } + } + //*/ + + // load the judgements + int i = 0; + for ( i = 0; i < 8; i++ ) + { + char filename[] = "DATA/gameplay/judge_0.tga"; + filename[20] = i + '0'; + m_judgements[i][0] = loadImage(filename); + + char dmfilename[] = "DATA/gameplay/drummania/judge_0.tga"; + dmfilename[30] = i + '0'; + m_columnJudgements[i][0] = loadImage(dmfilename); + } + for ( i = 1; i < 3; i++ ) // marvellous, perfect, and great need animation frames + { + int j = 0; + for ( j = 0; j < 8; j++ ) + { + m_judgements[j][i] = create_bitmap(256+i*5, 32+i*5); + stretch_blit(m_judgements[j][0], m_judgements[j][i], 0, 0, 256, 32, 0, 0, 256+i*5, 32+i*5); + + m_columnJudgements[j][i] = create_bitmap(256+i*5, 32+i*5); + stretch_blit(m_columnJudgements[j][0], m_columnJudgements[j][i], 0, 0, 256, 32, 0, 0, 256+i*5, 32+i*5); + } + } + + // load the 'lane flashes' (marvellous/OK notebombs, really) + for ( color = 0; color < 2; color++ ) + { + char filename[] = "DATA/gameplay/flash_0.tga"; + filename[20] = color + '0'; + temp = loadImage(filename); + + for ( frame = 0; frame < 4; frame++ ) + { + m_flashes[frame][color] = create_bitmap(75, 75); + blit(temp, m_flashes[frame][color], 0, frame*75, 0, 0, 75, 75); + } + destroy_bitmap(temp); + } + + // generate the 'lane flares' (the fade for when any note is hit) + for ( arrow = 0; arrow < 6; arrow++ ) + for ( frame = 0; frame < 4; frame++ ) + for ( color = 0; color < 3; color++ ) + { + m_flares[arrow][frame][color] = create_bitmap(64, 64); + blit(m_stepZoneSource[arrow][0], m_flares[arrow][frame][color], 0, 0, 0, 0, 64, 64); + replaceColor(m_flares[arrow][frame][color], 0xFF797979, ((frame*24+160)<<24) + (flareColors[color][0]<<16) + (flareColors[color][1]<<8) + (flareColors[color][2]) ); + replaceColor(m_flares[arrow][frame][color], 0x40000000, ((frame*24+160)<<24) + (flareColors[color][0]<<16) + (flareColors[color][1]<<8) + (flareColors[color][2]) ); + replaceColor(m_flares[arrow][frame][color], 0xFFF6F6F6, ((frame*24+160)<<24) + (flareColors[color][0]<<16) + (flareColors[color][1]<<8) + (flareColors[color][2]) ); + } + + // load combo graphics + temp = loadImage("DATA/gameplay/combo.tga"); + for ( color = 0; color < 5; color++ ) + { + m_combo[color] = create_bitmap(128, 24); + blit(temp, m_combo[color], 0, color*24, 0, 0, 128, 24); + } + destroy_bitmap(temp); + m_comboNums = loadImage("DATA/gameplay/combo_nums.tga"); + + // load the special drummania graphics + m_comboNumsDM = loadImage("DATA/gameplay/drummania/combo_nums.tga"); + m_comboWordDM = loadImage("DATA/gameplay/drummania/combo.tga"); + + // load the special dmx graphics + m_dmxHeader = loadImage("DATA/gameplay/dmx/header.tga"); + m_dmxFooter = loadImage("DATA/gameplay/dmx/footer.tga"); + m_stepZoneSourceDMX[0] = loadImage("DATA/gameplay/dmx/default_hitzone_00.tga"); + m_stepZoneSourceDMX[1] = loadImage("DATA/gameplay/dmx/default_hitzone_01.tga"); + m_notesDMX[0] = loadImage("DATA/gameplay/dmx/default_donut_00.tga"); + m_notesDMX[1] = loadImage("DATA/gameplay/dmx/default_donut_01.tga"); + m_notesDMX[2] = loadImage("DATA/gameplay/dmx/default_donut_02.tga"); + m_comboDMX = loadImage("DATA/gameplay/dmx/combo_word.BMP"); + for ( color = 0; color < 8; color++ ) + { + char cFilename[] = "DATA/gameplay/dmx/combo_0000.BMP"; + char fFilename[] = "DATA/gameplay/dmx/fever_0000.BMP"; + cFilename[27] = fFilename[27] = color + '0'; + m_dmxCombos[color] = loadImage(cFilename); + m_dmxFevers[color] = loadImage(fFilename); + } + m_leftLifeGaugeCover = loadImage("DATA/gameplay/dmx/left_blank.tga"); + m_rightLifeGaugeCover = loadImage("DATA/gameplay/dmx/right_blank.tga"); + for ( color = 0; color < 4; color++ ) + { + char lFilename[] = "DATA/gameplay/dmx/1P_halo_0.tga"; + char rFilename[] = "DATA/gameplay/dmx/2P_halo_1.tga"; + lFilename[26] = rFilename[26] = color + '0'; + m_leftSideHalo[color][0] = loadImage(lFilename); + m_rightSideHalo[color][0] = loadImage(rFilename); + lFilename[21] = rFilename[21] = 'l'; + lFilename[22] = rFilename[22] = 'o'; + lFilename[23] = rFilename[23] = 'w'; + lFilename[24] = rFilename[24] = 'h'; + m_leftSideHalo[color][1] = loadImage(lFilename); + m_rightSideHalo[color][1] = loadImage(rFilename); + } + + m_judgementsDMX = loadImage("DATA/gameplay/dmx/judgements.tga"); + for ( color = 0; color < 6; color++ ) + { + char sFilename[] = "DATA/gameplay/dmx/smallbomb_0000.tga"; + char lFilename[] = "DATA/gameplay/dmx/largebomb_0000.tga"; + sFilename[31] = lFilename[31] = color + '0'; + BITMAP* sbmp = loadImage(sFilename); + BITMAP* lbmp = loadImage(lFilename); + + // separate each frame - this is needed for a special rendering mode later + for ( int frame = 0; frame < 16; frame++ ) + { + m_dmxFireworks[0][color][frame] = create_bitmap_ex(32, 128, 128); + m_dmxFireworks[1][color][frame] = create_bitmap_ex(32, 128, 128); + int sx = (frame / 4) * 128; + int sy = (frame % 4) * 128; + blit(sbmp, m_dmxFireworks[0][color][frame], sx, sy, 0, 0, 128, 128); + blit(lbmp, m_dmxFireworks[1][color][frame], sx, sy, 0, 0, 128, 128); + } + destroy_bitmap(sbmp); + destroy_bitmap(lbmp); + } + + // load full combo graphics + temp = loadImage("DATA/gameplay/full_combo_anim.tga"); + for ( frame = 0; frame < 11; frame++ ) + { + m_fullComboAnim[frame] = create_bitmap_ex(32, 266, 32); + blit(temp, m_fullComboAnim[frame], 0, frame*32, 0, 0, 266, 32); + } + destroy_bitmap(temp); + m_fcRays[0] = loadImage("DATA/gameplay/fc_rays_00.tga"); + m_fcRays[1] = loadImage("DATA/gameplay/fc_rays_01.tga"); + m_fcRays[2] = loadImage("DATA/gameplay/fc_rays_02.tga"); + m_fcRays[3] = loadImage("DATA/gameplay/fc_rays_03.tga"); +} + +void renderStageDisplay() +{ + int y = 140; + if ( gs.currentStage == -1 ) + { + y = 140; // demo play = blank + } + else if ( gs.currentStage < gs.numSongsPerSet-1 ) + { + y = 20*gs.currentStage; + } + else if ( gs.currentStage == gs.numSongsPerSet-1 ) + { + y = 80; // "FINAL STAGE" + } + else + { + y = (gs.player[0].timeElapsed % 200) < 100 ? 120 : 100; // "EXTRA STAGE" blinks + } + masked_blit(m_stageDisplay, rm.m_backbuf, 0, y, 241, 10, 160, 20); + + // render the between-stage transition + if ( isMidTransition ) + { + int bannerx = 192; // centered + if ( songTransitionTime < BANNER_ANIM_STEP ) + { + bannerx = getValueFromRange(-256, 192, songTransitionTime*100 / BANNER_ANIM_STEP); + } + else if ( songTransitionTime > BANNER_ANIM_STEP*2 ) + { + bannerx = getValueFromRange(192, 640, (songTransitionTime-(BANNER_ANIM_STEP*2))*100 / BANNER_ANIM_STEP); + } + + if ( songTransitionTime <= 0 ) + { + isMidTransition = false; + } + + //al_trace("bannerx = %d\r\n", bannerx); + int bannerIndex = songID_to_listID(gs.player[0].stagesPlayed[gs.currentStage]); + blit(m_banners[bannerIndex], rm.m_backbuf, 0, 0, bannerx, 112, 256, 256); + } +} + +void renderGrade(int player) +{ + int grade = sm.player[player].currentSet[gs.currentStage].calculateGrade(); + int sy = 48 * grade; // F,E,D,C,...,A,AA (S),AAA (SS) + + int color = 0; // yellow/green/blue/red + if ( grade <= GRADE_F ) + { + color = 3; + } + else if ( grade <= GRADE_D ) + { + color = 2; + } + else if ( grade <= GRADE_B ) + { + color = 1; + } + int sx = 48 * color; + + masked_blit(m_grades, rm.m_backbuf, sx, sy, player == 0 ? 6 : 586, 0, 48, 48); +} + +void renderSpeedMod(int scrollRate, int speedMod, int x, int y) +{ + renderWhiteNumber(speedMod/10, x, y); + renderWhiteLetter('.', x+10, y); + renderWhiteNumber(speedMod%10, x+20, y); + renderWhiteLetter('x', x+40, y); + renderWhiteNumber(scrollRate*speedMod/10, x+70, y); + renderWhiteLetter('=', x+100, y); + renderWhiteNumber(MSEC_TO_BPM(scrollRate), x+120, y); +} + +void renderLifebar(int player) +{ + static int blueColors[15] = { 0x6B84FF, 0x8494FF, 0x8494FF, 0xBDCEFF, 0xFFFFFF, 0xC6CEFF, 0xA5B5FF, 0x8494FF, 0x8494FF, + 0x6B84FF, 0x8494FF, 0x8494FF, 0x6B84FF, 0x8494FF, 0x8494FF }; + static int goldColors[15] = { 0xFFA851, 0xFFC171, 0xFFC171, 0xFFCDAF, 0xFFFFFF, 0xFFE0BC, 0xFFC895, 0xFFC171, 0xFFC171, + 0xFFA851, 0xFFC171, 0xFFC171, 0xFFA851, 0xFFC171, 0xFFC171 }; + int bgc1 = 0x525E60; + int bgc2 = 0x525EB0; //0x62699B; + + int startx = player == 0 ? 234 : 404; + int direction = player == 0 ? -1 : +1; // right to left or left to right? + int numPixels = getValueFromRange(0, 170, gs.player[player].lifebarPercent/10); + int ci = getValueFromRange( 0, 14, (gs.player[player].stepZoneBeatTimer*100 / gs.player[player].stepZoneTimePerBeat) ); + + solid_mode(); + for ( int i = 0; i < 170; i++ ) + { + if ( i < numPixels ) + { + line(rm.m_backbuf, startx + (direction*i), 0, startx + (direction*i), 46, numPixels >= 119 ? goldColors[ci] : blueColors[ci]); + ci = (ci + 1) % 15; + } + else // use a background color instead of the "color index" ci + { + int color = ci < 8 ? getValueFromRange(bgc2, bgc1, (ci-8)*100/8) : getValueFromRange(bgc1, bgc2, ci*100/7); // pulse the blue color back and forth [0..7] then [8..14] then [0..7] + if ( gs.player[player].useBattery ) + { + int red = ci < 8 ? getValueFromRange(0, 255, (ci-8)*100/8) : getValueFromRange(255, 0, ci*100/7); + color = makecol(red, 0, 0); + } + line(rm.m_backbuf, startx + (direction*i), 0, startx + (direction*i), 46, color); + } + } + set_alpha_blender(); // the game assumes the graphics are left in this mode + + if ( gs.player[player].useBattery ) + { + renderBatteryLivesDMX(player); + } +} + +void renderFullComboAnim(int x, int time, int step) +{ + int frame = (time / 50) % 4; + int y = 86; + //y = (gs.player[player].isColumnReversed(i) ? DMX_STEP_ZONE_REV_Y-34 : DMX_STEP_ZONE_Y)-46; + time %= 1000; + + if ( step == 1 ) + { + set_add_blender(0,0,0,256); + draw_trans_sprite(rm.m_backbuf, m_fcRays[frame], x, y-300+time); + //blit(m_fcRays[frame], rm.m_backbuf, 0, 0, x+65, y, 128, 216); + set_alpha_blender(); // the game assumes the graphics are left in this mode + } + else if ( step == 2 ) + { + frame = MIN(time/60, 10); + draw_trans_sprite(rm.m_backbuf, m_fullComboAnim[frame], x-69, 320); + } + else if ( step == 3 ) + { + draw_trans_sprite(rm.m_backbuf, m_fullComboAnim[10], x-69, 320); + } + else if ( step > 3 ) + { + frame = 10 - time/60; + if ( frame >= 0 ) + { + draw_trans_sprite(rm.m_backbuf, m_fullComboAnim[frame], x-69, 320); + } + } +} + +void renderEndSongMarker(int x1, int x2, int y) +{ + line(rm.m_backbuf, x1, y+0, x2, y+0, END_SECTION_COLOR1); + line(rm.m_backbuf, x1, y+1, x2, y+1, END_SECTION_COLOR2); + line(rm.m_backbuf, x1, y+2, x2, y+2, END_SECTION_COLOR1); + line(rm.m_backbuf, x1, y+3, x2, y+3, COLOR_WHITE); +} + +void renderBPMMarker(int x1, int x2, int y, int bpm) +{ + line(rm.m_backbuf, x1, y+0, x2, y+0, BPM_CHANGE_COLOR1); + line(rm.m_backbuf, x1, y+1, x2, y+1, BPM_CHANGE_COLOR2); + line(rm.m_backbuf, x1, y+2, x2, y+2, BPM_CHANGE_COLOR1); + line(rm.m_backbuf, x1, y+3, x2, y+3, COLOR_WHITE); + renderWhiteNumber(bpm, x2+3, y-10); +} + +void renderTempoStopMarker(int x1, int x2, int y, int len) +{ + line(rm.m_backbuf, x1, y+0, x2, y+0, SCROLL_STOP_COLOR1); + line(rm.m_backbuf, x1, y+1, x2, y+1, SCROLL_STOP_COLOR2); + line(rm.m_backbuf, x1, y+2, x2, y+2, SCROLL_STOP_COLOR1); + line(rm.m_backbuf, x1, y+3, x2, y+3, COLOR_WHITE); + renderWhiteNumber(len, x2+3, y+15); +} + +void renderGameplay() +{ + //blit(m_bg, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + clear_to_color(rm.m_backbuf, 0); + vm.renderToSurfaceStretched(rm.m_backbuf, 0, 46, 640, 384); + + if ( gs.player[0].danceManiaxMode ) + { + renderUnderFrameDMX(); + } + + // do this whole thing once for each player + for ( int p = 0; p < (gs.isVersus ? 2 : 1); p++ ) + { + // this makes rendering the combo and judgements easier later + int centered_x = getColumnOffsetX_DMX(p==0 ? 0 : 4) + 64; + if ( gs.player[p].danceManiaxMode == false ) + { + centered_x = getColumnOffsetX_DDR(p==0 ? 0 : 4) + 128; + } + if ( gs.isDoubles || (!gs.isDoubles && !gs.isVersus) ) + { + centered_x = 320; + } + + // usually the combo goes behind the chart + if ( !gs.player[p].drummaniaMode && !gs.player[p].danceManiaxMode ) + { + renderDDRCombo(gs.player[p].displayCombo, gs.player[p].judgementTime, centered_x, gs.player[p].comboColor); + } + + // step zone + if ( gs.player[p].danceManiaxMode ) + { + renderStepZoneDMX(p); + renderDMXCombo(gs.player[p].displayCombo, gs.player[p].judgementTime, centered_x, gs.player[p].comboColor); + } + else + { + renderStepZone_DDR(p); + } + + // timing judgements - under the notes + if ( gs.player[p].judgementTime < JUDGEMENT_DISPLAY_TIME ) + { + if ( gs.player[p].danceManiaxMode ) + { + renderDMXJudgement(gs.player[p].lastJudgement, gs.player[p].judgementTime, centered_x, JUDGEMENT_Y); + } + } + + // chart and arrows/rings/chips/whatever + if ( gs.player[p].currentChart.size() > 0 ) + { + if ( gs.player[p].danceManiaxMode ) + { + renderDMXFlaresAndFlashes(p); + renderDMXChart(p); + } + else + { + renderDDRChart(p); + renderFlaresAndFlashes_DDR(p); + } + } + + renderLifebar(p); + + // timing judgements - on top of the notes + if ( gs.player[p].judgementTime < JUDGEMENT_DISPLAY_TIME ) + { + if ( !gs.player[p].danceManiaxMode ) + { + renderDDRJudgement(gs.player[p].lastJudgement, gs.player[p].judgementTime, centered_x, JUDGEMENT_Y); + } + } + renderColumnJudgements(p); + + // drummania's combo goes on top of the chart + if ( gs.player[p].drummaniaMode ) + { + renderDMCombo(gs.player[p].displayCombo, p); + } + + if ( gs.player[p].timeElapsed < 10000 && !gs.player[p].isColumnReversed(0) ) + { + //renderSpeedMod(gs.player[p].scrollRate, gs.player[p].speedMod, centered_x-64, 380); + } + + } // done with 1P 2P loop + + + // render things on the frame + if ( gs.player[0].danceManiaxMode ) + { + renderOverFrameDMX(); + } + renderStageDisplay(); + for ( int i = 0; i < (gs.isVersus ? 2 : 1); i++ ) + { + renderGrade(i); + renderScoreNumber(sm.player[i].currentSet[gs.currentStage].getScore(), i == 0 ? 32 : 426, 444, 7); + } + + /* current chart time display + renderWhiteNumber(gs.player[0].timeElapsed, 10, 70); + //*/ + + // retire timer + if ( retireTimer > 14000 ) + { + renderBoldString("GIVE UP? RETIRE?", 223, 200, 640, false, (retireTimer/50)%4); + char digit = (retireTimer-14000)/1000; + renderNameLetter('5'-digit, 304, 240, (retireTimer/75)%3); + } + + if ( fullComboP1 ) + { + int xadd = 65; + if ( gs.isDoubles ) + { + xadd = 66; + } + if ( gs.isVersus ) + { + xadd = 1; + } + renderFullComboAnim(getColumnOffsetX_DMX(0)+xadd, fullComboAnimTimer, fullComboAnimStep); + } + if ( fullComboP2 ) + { + renderFullComboAnim(getColumnOffsetX_DMX(4)+1, fullComboAnimTimer, fullComboAnimStep); + } + +#ifdef DMXDEBUG + //* FPS display + if ( totalGameTime > 1000 ) + { + //al_trace("FPS = %d (%d %ld)\n", (int)(frameCounter/((float)timeElapsed/1000.0f)), frameCounter, timeElapsed); + renderWhiteNumber(frameCounter / (totalGameTime/1000), 0, 0); + renderWhiteString("DEBUG MODE", 0, 12); + } + //*/ +#endif + + rm.flip(); +} + +void renderDebugNote(struct ARROW n, int x, int y) +{ + char tempstring[256] = ""; + if ( n.columns[0] == -1 ) + { + sprintf_s(tempstring, 256, "%ld = %d", n.timing, n.type); + } + else if ( n.columns[1] == -1 ) + { + sprintf_s(tempstring, 256, "%ld = %d [%d]", n.timing, n.type, n.columns[0]); + } + else + { + sprintf_s(tempstring, 256, "%ld = %d [%d %d]", n.timing, n.type, n.columns[0], n.columns[1]); + } + renderWhiteString(tempstring, x, y); +} \ No newline at end of file diff --git a/src/source/inputManager.cpp b/src/source/inputManager.cpp new file mode 100644 index 0000000..a21b544 --- /dev/null +++ b/src/source/inputManager.cpp @@ -0,0 +1,191 @@ +// inputManger.cpp implements a class that handles all types of user input +// file created by Allen Seitz 10/12/2009 + +#include "inputManager.h" +#include "gameStateManager.h" + +extern GameStateManager gs; + +// notice what these keybinds accomplish: +// 1P = {q,w} {az,sx} which mimicks the shape of the sensors on the machine +// 2P = play DDR and doubles with the arrow keys, because the 'special' blues are mapped +// while testing singles play, space bar makes triples and quads easier +// mapping the triangles to {g,h} is a convention that started on other 573 hacks +// test/service/coin are just whatever +static int defaultKeyMapping[NUM_INPUTS] = { KEY_SPACE, KEY_Q, KEY_W, KEY_SPACE, + KEY_SPACE, KEY_DOWN, KEY_UP, KEY_SPACE, + KEY_E, KEY_D, // solo is probably not making a comeback + KEY_G, KEY_H, KEY_B, KEY_N, KEY_QUOTE, KEY_ENTER_PAD, + KEY_F1, KEY_F2, KEY_7, + KEY_A, KEY_Z, KEY_S, KEY_X, // 1P blue sensors + KEY_LEFT, KEY_C, KEY_RIGHT, KEY_V // 2P blue sensors +}; + +InputManager::InputManager() +{ + int i = 0; + + for ( i = 0; i < NUM_INPUTS; i++ ) + { + m_panelStates[i] = HELD_UP; + m_panelHoldLength[i] = 0; + m_panelReleaseLength[10] = 0; + } + + for ( i = 0; i < NUM_INPUTS; i++ ) + { + m_keyMapping[i] = defaultKeyMapping[i]; + } +} + +void InputManager::updateKeyStates(UTIME dt) +{ + for ( int i = 0; i < NUM_INPUTS; i++ ) + { + if ( key[m_keyMapping[i]] != 0 || (i == MENU_START_1P && key[KEY_ENTER]) ) // for testing I like Enter + { + if ( m_panelStates[i] < 1 ) // if the key was up + { + m_panelStates[i] = JUST_DOWN; + m_panelHoldLength[i] = dt; + m_panelReleaseLength[i] = 0; + } + else // key stayed held down + { + m_panelStates[i] = HELD_DOWN; + m_panelHoldLength[i] = m_panelHoldLength[i] + dt > 30000 ? 30000 : m_panelHoldLength[i] + dt; + } + } + else + { + if ( m_panelStates[i] > 0 ) // if the key was down + { + m_panelStates[i] = JUST_UP; + m_panelHoldLength[i] = 0; + m_panelReleaseLength[i] = dt; + } + else // key stayed 'held' up + { + m_panelStates[i] = HELD_UP; + m_panelReleaseLength[i] = m_panelReleaseLength[i] + dt > 30000 ? 30000 : m_panelReleaseLength[i] + dt; + } + } + } + + processDanceManiaxBlueSensors(); +} + +char InputManager::getKeyState(int column) +{ + ASSERT(column < NUM_INPUTS && column >= 0); + + // implement the cooldown timer here and in isKeyDown() + if ( m_cooldownThreshold > 0 && column < 8 ) + { + if ( getReleaseLength(column) > 0 && getReleaseLength(column) < m_cooldownThreshold ) + { + return HELD_DOWN; + } + } + + return m_panelStates[column]; +} + +bool InputManager::isKeyDown(int column) +{ + ASSERT(column < NUM_INPUTS && column >= 0); + + // implement the cooldown timer here and in getKeyState() + if ( m_cooldownThreshold > 0 && column < 8 ) + { + if ( getShortestReleaseLength(column) > 0 && getShortestReleaseLength(column) < m_cooldownThreshold ) + { + return HELD_DOWN; + } + } + + return m_panelStates[column] > 0; +} + +// I think this function is only used for making sure that only active panels trigger shock arrows +bool InputManager::isKeyInUse(int column) +{ + ASSERT(column < NUM_INPUTS && column >= 0); + + if ( gs.isSolo && !gs.isDoubles ) + { + return column < 6; + } + else if ( !gs.isSolo && gs.isDoubles ) + { + return column != 1 && column != 4; + } + else if ( gs.isSolo && gs.isDoubles ) + { + return true; + } + return column >= 6; // singles play assumes 2P +} + +int InputManager::getHoldLength(int column) +{ + ASSERT(column < NUM_INPUTS && column >= 0); + return m_panelHoldLength[column]; +} + +int InputManager::getReleaseLength(int column) +{ + ASSERT(column < NUM_INPUTS && column >= 0); + return m_panelReleaseLength[column]; +} + +void InputManager::processDanceManiaxBlueSensors() +{ + processDanceManiaxBlueSensorHelper(BLUE_SENSOR_1PL0, BLUE_SENSOR_1PL1, LL_1P); + processDanceManiaxBlueSensorHelper(BLUE_SENSOR_1PR0, BLUE_SENSOR_1PR1, LR_1P); + processDanceManiaxBlueSensorHelper(BLUE_SENSOR_2PL0, BLUE_SENSOR_2PL1, LL_2P); + processDanceManiaxBlueSensorHelper(BLUE_SENSOR_2PR0, BLUE_SENSOR_2PR1, LR_2P); +} + +void InputManager::processDanceManiaxBlueSensorHelper(int a, int b, int blue) +{ + if ( m_panelStates[a] == JUST_DOWN || m_panelStates[b] == JUST_DOWN ) + { + m_panelStates[blue] = JUST_DOWN; + m_panelHoldLength[blue] = MAX(m_panelHoldLength[a], m_panelHoldLength[b]); + m_panelReleaseLength[blue] = 0; + } + else if ( m_panelStates[a] == HELD_DOWN || m_panelStates[b] == HELD_DOWN ) + { + m_panelStates[blue] = HELD_DOWN; + m_panelHoldLength[blue] = MAX(m_panelHoldLength[a], m_panelHoldLength[b]); + m_panelReleaseLength[blue] = 0; + } + else + { + if ( m_panelStates[blue] > 1 ) // if the blue column was 'down' before + { + m_panelStates[blue] = JUST_UP; + m_panelHoldLength[blue] = 0; + m_panelReleaseLength[blue] = MIN(m_panelReleaseLength[a], m_panelReleaseLength[b]); + } + else // this blue column was already open + { + m_panelStates[blue] = HELD_UP; + m_panelHoldLength[blue] = 0; + m_panelReleaseLength[blue] = MIN(m_panelReleaseLength[a], m_panelReleaseLength[b]); + } + } +} + +int InputManager::getShortestReleaseLength(int column) +{ + switch (column) + { + case LL_1P: return MIN(m_panelReleaseLength[BLUE_SENSOR_1PL0], m_panelReleaseLength[BLUE_SENSOR_1PL1]); + case LR_1P: return MIN(m_panelReleaseLength[BLUE_SENSOR_1PR0], m_panelReleaseLength[BLUE_SENSOR_1PR1]); + case LL_2P: return MIN(m_panelReleaseLength[BLUE_SENSOR_2PL0], m_panelReleaseLength[BLUE_SENSOR_2PL1]); + case LR_2P: return MIN(m_panelReleaseLength[BLUE_SENSOR_2PR0], m_panelReleaseLength[BLUE_SENSOR_2PR1]); + } + return getReleaseLength(column); +} diff --git a/src/source/loginMode.cpp b/src/source/loginMode.cpp new file mode 100644 index 0000000..3a92ead --- /dev/null +++ b/src/source/loginMode.cpp @@ -0,0 +1,992 @@ +// loginMode.cpp implements the login/pass screen for Dance Maniax +// source file created 4/26/2012 by Allen Seitz + +#include "common.h" +#include "bookManager.h" +#include "GameStateManager.h" +#include "inputManager.h" +#include "scoreManager.h" +#include "songwheelMode.h" + +extern GameStateManager gs; +extern RenderingManager rm; +extern InputManager im; +extern ScoreManager sm; +extern EffectsManager em; +extern BookManager bm; + +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; + +extern UTIME timeRemaining; +extern void renderTimeRemaining(int xc, int yc); +extern void playTimeLowSFX(UTIME dt); + + +////////////////////////////////////////////////////////////////////////////// +// Assets +////////////////////////////////////////////////////////////////////////////// +extern BITMAP* m_menuBG; +extern BITMAP* m_mainModes; +extern BITMAP* m_mainPlayers; + +extern BITMAP* m_startButton; +extern BITMAP* m_triangles; + +BITMAP* m_loginSelect = NULL; +BITMAP* m_nameCursor[2][8]; +BITMAP* m_cursorTopper = NULL; +BITMAP* m_nameHelp = NULL; +BITMAP* m_pinHelp = NULL; + +////////////////////////////////////////////////////////////////////////////// +// Variables +////////////////////////////////////////////////////////////////////////////// +extern UTIME blinkTimer; +bool isUse[2] = { false, false }; +bool isSkip[2] = { false, false }; +bool isDone[2] = { false, false }; + +int cursorPos[2] = {0,0}; + +UTIME waggleTimerP1 = 0; // wave the red sensors to pick a recent name +int waggleIndexP1 = 0; +int nameBounceP1 = 0; +UTIME waggleTimerP2 = 0; +int waggleIndexP2 = 0; +int nameBounceP2 = 0; + +static char nameLetters[45] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!+.#@&~^"; +static char prevNames[4][9] = { "", "", "", "" }; +char tempNames[2][9] = { "", "" }; +int pinNums[2][4] = { {-1,-1,-1,-1}, {-1,-1,-1,-1} }; +int currentDigitP1 = 0; +int currentDigitP2 = 0; +char currentStatusP1 = 0; // see current login status enumeration below +char currentStatusP2 = 0; +UTIME messageTimer[2] = { 0, 0 }; + +const int MAX_CURSOR_POS = 44; +const int END_NAME = 43; +const int WAGGLE_TIME = 2750; // how long a waggle input takes (before it is considered not an accidental input) +const int WAGGLE_STEP = 500; +const int LOGIN_MESSAGE_TIME = 3000; +const int UNFOLDED_Y = 416; +#define LOGIN_SHADE_COLOR makeacol(124, 0, 120, 84) + +// for the currentStatusP1 and P2 variables +#define LOGIN_CHOOSE_LOGIN 0 +#define LOGIN_NAME_ENTRY 1 +#define LOGIN_PIN_ENTRY 2 +#define LOGIN_PIN_VERIFY 3 +#define LOGIN_PIN_CORRECT 4 +#define LOGIN_PIN_INCORRECT 5 +#define LOGIN_WAITING 6 +#define LOGIN_SYSTEM_ERROR 7 + +////////////////////////////////////////////////////////////////////////////// +// Functions +////////////////////////////////////////////////////////////////////////////// +void renderLoginLoop(); +// +// + +void renderPrompt(int x, bool isUse, bool isPass); +// +// + +void endLoginMode(); +// +// + +void enterLetter(int player); +// precondition: player is 0-1, tempNames are initialized and null-terminated +// postcondition: uses cursorPosP1 or P2 to append a letter, or not + +bool enterPinDigit(int player); +// precondition: player is 0-1, pinP1 and pinP2 are initialized to {-1,-1,-1,-1} +// postcondition: uses currentDigitP1 or P2 to append a digit +// returns: true if the pin is now complete, or false otherwise + +void renderNameWithWhitespace(char string[9], int x, int y, int color); +// precondition: string[9] should be tempNames[] +// postcondition: just like renderNameString() but spaces are replaced with underscores + +void renderNamePrompt(int x, char side); +// +// + +void renderPinPrompt(int x, char side, bool isVerify); +// +// + +void renderLoginMessage(int xcoord, char* string); +// +// + +void saveRecentNames(); +void loadRecentNames(); +// precondition: none, but the file recent_players.bin is used +// postcondition: reads (if possible) or writes to that file up to 4 strings + +int getIndexOfPrevName(char* name); +// precondition: name is 9 bytes long at most, prevNames[] are loaded +// postcondition: returns an index [3..0] where the name should be inserted + + +void firstLoginLoop() +{ + if ( m_loginSelect == NULL ) + { + m_loginSelect = loadImage("DATA/menus/main_login_select.tga"); + m_cursorTopper = loadImage("DATA/menus/1p2p_topper.tga"); + m_nameHelp = loadImage("DATA/menus/name_help.tga"); + m_pinHelp = loadImage("DATA/menus/pin_help.tga"); + + for ( int i = 0; i < 2; i++ ) + for ( int j = 0; j < 8; j++ ) + { + char cursorFilename[] = "DATA/menus/1Pframe_0000.tga"; + cursorFilename[11] = i + '1'; + cursorFilename[22] = j + '0'; + m_nameCursor[i][j] = loadImage(cursorFilename); + } + } + if ( m_startButton == NULL ) + { + m_startButton = loadImage("DATA/menus/start.tga"); + m_triangles = loadImage("DATA/menus/triangles.tga"); + } + + blinkTimer = 0; + timeRemaining = 10999; // time to choose login + + isUse[0] = isUse[1] = false; + isSkip[0] = isSkip[1] = false; + isDone[0] = isDone[1] = false; + cursorPos[0] = END_NAME;//0; + cursorPos[1] = END_NAME;//10; + nameBounceP1 = nameBounceP2 = 0; + messageTimer[0] = messageTimer[1] = 0; + + waggleTimerP1 = waggleIndexP1 = nameBounceP1 = 0; + waggleTimerP2 = waggleIndexP2 = nameBounceP2 = 0; + + for ( int i = 0; i < 8; i++ ) + { + tempNames[0][i] = tempNames[1][i] = 0; + pinNums[0][i/2] = pinNums[1][i/2] = -1; // -1 for "no digit entered here", legal digits are 0-9 + } + currentDigitP1 = currentDigitP2 = 0; + currentStatusP1 = currentStatusP2 = LOGIN_CHOOSE_LOGIN; + + // ALWAYS do this so that players do not accidentally play as someone else + sm.player[0].resetData(); + sm.player[1].resetData(); + sm.player[0].isLoggedIn = false; + sm.player[1].isLoggedIn = false; + memcpy(sm.player[0].displayName, "PLAYER 1", 8); + memcpy(sm.player[1].displayName, "PLAYER 2", 8); + + loadRecentNames(); +} + +void mainLoginLoop(UTIME dt) +{ + blinkTimer += dt; + blinkTimer %= 1000; + if ( !gs.isEventMode ) + { + SUBTRACT_TO_ZERO(timeRemaining, dt); + } + SUBTRACT_TO_ZERO(waggleTimerP1, dt); + SUBTRACT_TO_ZERO(waggleTimerP2, dt); + SUBTRACT_TO_ZERO(nameBounceP1, (int)dt); + SUBTRACT_TO_ZERO(nameBounceP2, (int)dt); + playTimeLowSFX(dt); + + // precalculate input - this is because the P2 controls also count as P1 controls during singles play + bool isLeftPress[2], isRightPress[2], isStartPress[2], isLeftHeld[2], isRightHeld[2]; + isLeftPress[0] = im.getKeyState(MENU_LEFT_1P) == JUST_DOWN || (!gs.isVersus && im.getKeyState(MENU_LEFT_2P) == JUST_DOWN); + isRightPress[0] = im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || (!gs.isVersus && im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN); + isStartPress[0] = im.getKeyState(MENU_START_1P) == JUST_DOWN || (!gs.isVersus && im.getKeyState(MENU_START_2P) == JUST_DOWN); + isLeftPress[1] = gs.isVersus && im.getKeyState(MENU_LEFT_2P) == JUST_DOWN; + isRightPress[1] = gs.isVersus && im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN; + isStartPress[1] = gs.isVersus && im.getKeyState(MENU_START_2P) == JUST_DOWN; + isLeftHeld[0] = im.isKeyDown(MENU_LEFT_1P) || (!gs.isVersus && im.isKeyDown(MENU_LEFT_2P)); + isRightHeld[0] = im.isKeyDown(MENU_RIGHT_1P) || (!gs.isVersus && im.isKeyDown(MENU_RIGHT_2P)); + isLeftHeld[1] = gs.isVersus && im.isKeyDown(MENU_LEFT_2P); + isRightHeld[1] = gs.isVersus && im.isKeyDown(MENU_RIGHT_2P); + + // debug testing + if ( key[KEY_SPACE] ) + { + timeRemaining = 5000; + } + + // process input depending on the current sub-state of Login Mode + if ( currentStatusP1 == LOGIN_CHOOSE_LOGIN ) // P1 and P2 must perform this step together + { + for ( int side = 0; side < 2; side++ ) + { + if ( isLeftPress[side] ) + { + isSkip[side] = false; + } + if ( isRightPress[side] ) + { + isSkip[side] = true; + em.playSample(SFX_NAME_ENTRY_BACKSPACE); + } + if ( isStartPress[side] ) + { + isUse[side] = true; + em.playSample(SFX_EAMUSE_DIAL); + } + } + } + else if ( currentStatusP1 == LOGIN_NAME_ENTRY ) // P1 and P2 must also pass name entry together + { + for ( int side = 0; side < 2; side++ ) + { + if ( isUse[side] && !isDone[side] ) + { + if ( isLeftPress[side] ) + { + if ( isRightHeld[side] ) + { + cursorPos[side] += 11; // left + right = down a row on the name entry screen + } + else + { + cursorPos[side] -= 1; + } + em.playSample(SFX_NAME_CURSOR_MOVE); + } + if ( isRightPress[side] ) + { + if ( isLeftHeld[side] ) + { + cursorPos[side] += 11; // left + right = down a row on the name entry screen + } + else + { + cursorPos[side] += 1; + } + em.playSample(SFX_NAME_CURSOR_MOVE); + } + if ( isStartPress[side] && isUse[side] && !isDone[side] ) + { + if ( cursorPos[side] == END_NAME ) + { + isDone[side] = true; + if ( tempNames[side][0] == 0 ) + { + isUse[side] = false; // entering a blank name = skip + } + em.playSample(SFX_START_BUTTON); + } + else + { + enterLetter(side); + } + } + } + } + + // P1 waggle controls + bool hitAnyRedSensor = im.getKeyState(UL_1P) == JUST_DOWN || im.getKeyState(UR_1P) == JUST_DOWN; + if ( !gs.isVersus ) + { + hitAnyRedSensor = hitAnyRedSensor || im.getKeyState(UL_2P) == JUST_DOWN || im.getKeyState(UR_2P) == JUST_DOWN; // one player (center, doubles) can waggle anywhere + } + if ( hitAnyRedSensor && isUse[0] && !isDone[0] ) + { + waggleTimerP1 += WAGGLE_STEP; + nameBounceP1 = 100; + if ( waggleTimerP1 > WAGGLE_TIME ) + { + waggleTimerP1 = 0; + memcpy_s(tempNames[0], 9, prevNames[waggleIndexP1], 9); + waggleIndexP1 = waggleIndexP1 == 3 ? 0 : waggleIndexP1 + 1; + cursorPos[0] = END_NAME; + em.playSample(SFX_MENU_SORT); + } + else + { + em.playSample(SFX_NAME_CURSOR_WAGGLE); + } + } + + // P2 waggle controls are a litle easier + if ( im.getKeyState(UL_2P) == JUST_DOWN || im.getKeyState(UR_2P) == JUST_DOWN ) // 2P waggle controls are separate from singles/doubles + { + if ( gs.isVersus && isUse[1] && !isDone[1] ) + { + waggleTimerP2 += WAGGLE_STEP; + nameBounceP2 = 100; + if ( waggleTimerP2 > WAGGLE_TIME ) + { + waggleTimerP2 = 0; + memcpy_s(tempNames[1], 9, prevNames[waggleIndexP2], 9); + waggleIndexP2 = waggleIndexP2 == 3 ? 0 : waggleIndexP2 + 1; + cursorPos[1] = END_NAME; + em.playSample(SFX_START_BUTTON); + } + else + { + em.playSample(SFX_NAME_CURSOR_WAGGLE); + } + } + } + + cursorPos[0] = (cursorPos[0] + MAX_CURSOR_POS) % MAX_CURSOR_POS; + cursorPos[1] = (cursorPos[1] + MAX_CURSOR_POS) % MAX_CURSOR_POS; + } + else // now P1 and P2 can be in different status + { + for ( int side = 0; side < 2; side++ ) + { + int* pdigit = side == 0 ? ¤tDigitP1 : ¤tDigitP2; + + switch (side == 0 ? currentStatusP1 : currentStatusP2) + { + case LOGIN_PIN_ENTRY: + case LOGIN_PIN_VERIFY: + // scroll through pin digits + if ( isLeftPress[side] && isUse[side] && !isDone[side] ) + { + *pdigit = *pdigit == 0 ? 9 : *pdigit - 1; + em.playSample(SFX_PIN_DIGIT); + } + if ( isRightPress[side] && isUse[side] && !isDone[side] ) + { + *pdigit = *pdigit == 9 ? 0 : *pdigit + 1; + em.playSample(SFX_PIN_DIGIT); + } + if ( isStartPress[side] && isUse[side] && !isDone[side] ) + { + if ( enterPinDigit(side) ) + { + isDone[side] = true; + } + } + break; + case LOGIN_PIN_CORRECT: + case LOGIN_PIN_INCORRECT: + // no input - just an animation + break; + case LOGIN_WAITING: + break; + } + } + } + + // do logic - check for the end of the mode + if ( currentStatusP1 == 0 ) + { + if ( timeRemaining <= 0 ) + { + isSkip[0] = !isUse[0]; + isSkip[1] = !isUse[1]; + } + + bool isDecidedP1 = isUse[0] || isSkip[0]; + bool isDecidedP2 = isUse[1] || isSkip[1] || !gs.isVersus; + + if ( isDecidedP1 && isDecidedP2 ) + { + timeRemaining = 60000; + if ( isUse[0] || isUse[1] ) + { + currentStatusP1 = currentStatusP2 = LOGIN_NAME_ENTRY; + } + else + { + endLoginMode(); + } + } + } + else if ( currentStatusP1 == 1 ) // currently in name entry mode (with the alphabet visible) + { + if ( ((isUse[0] && isDone[0]) || !isUse[0]) && ((isUse[1] && isDone[1]) || !isUse[1]) ) // if each player that is in use, is done + { + if ( tempNames[0][0] == 0 || !isUse[0] ) + { + isUse[0] = false; // P1 entered a blank name - treat it as a pass + sm.player[0].resetData(); + currentStatusP1 = LOGIN_WAITING; + } + else + { + if ( sm.doesPlayerNameExist(tempNames[0]) ) + { + if ( !sm.loadPlayerFromDisk(tempNames[0], 0) ) + { + currentStatusP1 = LOGIN_SYSTEM_ERROR; + em.playSample(SFX_FAILURE_ANIMATION); + } + } + else + { + memcpy(sm.player[0].displayName, tempNames[0], 8); + } + currentStatusP1 = LOGIN_PIN_ENTRY; + } + + if ( tempNames[1][0] == 0 || !isUse[1] ) + { + isUse[1] = false; // P2 entered a blank name - treat it as a pass + sm.player[1].resetData(); + currentStatusP2 = LOGIN_WAITING; + } + else + { + if ( sm.doesPlayerNameExist(tempNames[1]) ) + { + if ( !sm.loadPlayerFromDisk(tempNames[1], 1) ) + { + currentStatusP2 = LOGIN_SYSTEM_ERROR; + em.playSample(SFX_FAILURE_ANIMATION); + } + } + else + { + memcpy(sm.player[1].displayName, tempNames[1], 8); + } + currentStatusP2 = LOGIN_PIN_ENTRY; + } + + isDone[0] = isDone[1] = false; + if ( !isUse[0] && !isUse[1] ) + { + endLoginMode(); + } + } + } + else // after the name entry screen P1 and P2 can each be doing their own thing + { + for ( int side = 0; side < 2; side++ ) + { + char* pstatus = side == 0 ? ¤tStatusP1 : ¤tStatusP2; + + switch (*pstatus) + { + case LOGIN_PIN_ENTRY: + if ( isDone[side] ) + { + if ( sm.doesPlayerNameExist(tempNames[side]) ) + { + if ( sm.isPinCorrect((pinNums[side][0]*1000)+(pinNums[side][1]*100)+(pinNums[side][2]*10)+(pinNums[side][3]), side) ) + { + *pstatus = LOGIN_PIN_CORRECT; + em.playSample(SFX_COURSE_ENTRY_CONFIRM); + em.announcerQuipChance(GUY_LOGIN, 100); + } + else + { + *pstatus = LOGIN_PIN_INCORRECT; + isDone[side] = false; + em.playSample(SFX_FAILURE_ANIMATION); + } + messageTimer[side] = LOGIN_MESSAGE_TIME; + } + else + { + if ( pinNums[side][0] == pinNums[side][1] && pinNums[side][0] == pinNums[side][2] && pinNums[side][0] == pinNums[side][3] ) + { + *pstatus = LOGIN_PIN_INCORRECT; // disallow pin numbers 0000, 1111, 2222, .... 9999 + isDone[side] = false; + em.playSample(SFX_FAILURE_ANIMATION); + messageTimer[side] = LOGIN_MESSAGE_TIME; + } + else + { + *pstatus = LOGIN_PIN_VERIFY; + for ( int i = 0; i < 4; i++ ) + { + sm.player[side].pinDigits[i] = (char)pinNums[side][i]; // now the verify loop will check against what you've entered + pinNums[side][i] = -1; // erase them and retype them + } + } + } + } + isDone[side] = false; + break; + case LOGIN_PIN_VERIFY: + if ( isDone[side] ) + { + if ( sm.isPinCorrect((pinNums[side][0]*1000)+(pinNums[side][1]*100)+(pinNums[side][2]*10)+(pinNums[side][3]), side) ) + { + sm.player[side].isLoggedIn = true; // hooray! create a new save file + *pstatus = LOGIN_PIN_CORRECT; + em.playSample(SFX_CROWD_CHEERING); + em.announcerQuip(GUY_EVERYBODY_WAITING); + } + else + { + *pstatus = LOGIN_PIN_INCORRECT; + isDone[side] = false; + em.playSample(SFX_FAILURE_ANIMATION); + } + messageTimer[side] = LOGIN_MESSAGE_TIME; + } + break; + case LOGIN_PIN_CORRECT: + SUBTRACT_TO_ZERO(messageTimer[side], dt); + if ( messageTimer[side] <= 0 ) + { + *pstatus = LOGIN_WAITING; + } + break; + case LOGIN_PIN_INCORRECT: + SUBTRACT_TO_ZERO(messageTimer[side], dt); + if ( messageTimer[side] <= 0 ) + { + *pstatus = LOGIN_PIN_ENTRY; + for ( int i = 0; i < 4; i++ ) + { + pinNums[side][i] = -1; + } + } + break; + case LOGIN_WAITING: + // intentionally do nothing + break; + } + } + + // are we done with the login mode entirely? + if ( (!isUse[0] || currentStatusP1 == LOGIN_WAITING) && (!isUse[1] || currentStatusP2 == LOGIN_WAITING) ) + { + endLoginMode(); + } + } + + // ran out of time while entering the name or pin + if ( timeRemaining <= 0 && currentStatusP1 >= LOGIN_NAME_ENTRY ) // this is safe even when P1 isn't using the login feature + { + if ( (isUse[0] && currentStatusP1 < LOGIN_PIN_CORRECT) || (isUse[1] && currentStatusP2 < LOGIN_PIN_CORRECT) ) + { + gs.g_currentGameMode = ATTRACT; // I'll be nice and give you another shot + gs.g_gameModeTransition = 1; + } + } + + renderLoginLoop(); +} + +void renderLoginLoop() +{ + int color = 0, sx = 0, i = 0; + + blit(m_menuBG, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + draw_trans_sprite(rm.m_backbuf, m_loginSelect, 287, 45); + + rectfill(rm.m_backbuf, 0, 83, 640, 83+33, makeacol(0, 0, 0, 255)); + rectfill(rm.m_backbuf, 0, UNFOLDED_Y, 640, UNFOLDED_Y+44, makeacol(208, 89, 160, 255)); + rectfill(rm.m_backbuf, 0, 118, 640, UNFOLDED_Y-1, makeacol(255, 170, 200, 200)); + + // render SINGLE DOUBLE VERSUS + for ( i = 0; i < 3; i++ ) + { + color = 2; + if ( (i == 1 && gs.isDoubles) || (i == 2 && gs.isVersus) || (i == 0 && !gs.isVersus && !gs.isDoubles) ) + { + color = 1; + } + sx = color * 114; + masked_blit(m_mainPlayers, rm.m_backbuf, sx, i*32, i*114 + (i+1)*74, 84, 114, 32); + } + + // render GAME MODE + if ( gs.currentGameType == 2 ) + { + masked_blit(m_mainModes, rm.m_backbuf, 210, 2*32, 215, UNFOLDED_Y-1, 210, 32); + renderArtistString("6 challenge tokens", 222, UNFOLDED_Y+25, 200, 32); + } + else + { + char numStagesDesc[] = "3 stages + ext"; + numStagesDesc[0] = gs.numSongsPerSet + '0'; + sx = 420; + //if ( gs.currentGameType == 0 ) // login BEFORE mode selection now + //{ + sx = 210; + //} + masked_blit(m_mainModes, rm.m_backbuf, sx, 0*32, 40, UNFOLDED_Y-1, 210, 32); + renderArtistString(numStagesDesc, 74, UNFOLDED_Y+25, 200, 32); + + sx = 420; + //if ( gs.currentGameType == 1 ) // login BEFORE mode selection now + //{ + sx = 210; + //} + masked_blit(m_mainModes, rm.m_backbuf, sx, 1*32, 390, UNFOLDED_Y-1, 210, 32); + renderArtistString(numStagesDesc, 424, UNFOLDED_Y+25, 200, 32); + } + + // RENDER LOWER LOGIN AREA + if ( currentStatusP1 == LOGIN_CHOOSE_LOGIN ) + { + renderBoldString("Press start to enter your name.", 140, 180, 400, false); + renderArtistString("Entering your name allows you", 160, 215, 360, 20); + renderArtistString("to save high scores.", 160, 235, 360, 20); + + if ( gs.isVersus ) + { + renderPrompt(118, isUse[0], isSkip[0]); + renderPrompt(380, isUse[1], isSkip[1]); + } + else + { + renderPrompt(248, isUse[0], isSkip[0]); + } + masked_blit(m_triangles, rm.m_backbuf, 32, 0, 246, 370, 32, 32); + renderArtistString("to skip", 318, 375, 200, 32); + } + // render the alphabet - enter your name (10/20 - no longer displays an alphabet) + else if ( currentStatusP1 == LOGIN_NAME_ENTRY ) + { + int xcoord[2] = { 136, 388 }; + if ( !gs.isVersus ) + { + xcoord[0] = 263; // center the menu for center and double play + } + for ( int side = 0; side < 2; side++ ) + { + if ( isUse[side] ) + { + renderNamePrompt(xcoord[side], side); + } + } + + draw_trans_sprite(rm.m_backbuf, m_nameHelp, 0, 384); + + renderNameWithWhitespace(tempNames[0], 32, 128-(nameBounceP1/10), 1); + if ( gs.isVersus ) + { + renderNameWithWhitespace(tempNames[1], 352, 128-(nameBounceP2/10), 2); + } + + // render the last 5 people who have logged in + rectfill(rm.m_backbuf, 4, 190, 4+100, 190+150, LOGIN_SHADE_COLOR); + renderBoldString("recent", 10, 230-37, 80, false); + renderBoldString("visitors", 10, 260-37, 80, false); + for ( i = 0; i < 4; i++ ) + { + renderArtistString(prevNames[i], 10, 290-37 + 20*i, 128, 32); + } + } + // render each player's modes separately from this point on + else + { + int xcoord[2] = { 136, 388 }; + if ( !gs.isVersus ) + { + xcoord[0] = 263; // center the menu for center and double play + } + + draw_trans_sprite(rm.m_backbuf, m_pinHelp, 0, 384); + + // render the names up top + renderNameWithWhitespace(tempNames[0], 32, 128-(nameBounceP1/10), 1); + if ( gs.isVersus ) + { + renderNameWithWhitespace(tempNames[1], 352, 128-(nameBounceP2/10), 2); + } + + for ( int side = 0; side < 2; side++ ) + { + char* pstatus = side == 0 ? ¤tStatusP1 : ¤tStatusP2; + if ( isUse[side] ) + { + switch ( *pstatus ) + { + case LOGIN_PIN_ENTRY: + case LOGIN_PIN_VERIFY: + renderPinPrompt(xcoord[side], side, *pstatus == LOGIN_PIN_VERIFY); + break; + case LOGIN_PIN_CORRECT: + renderLoginMessage(xcoord[side], "LOGIN ACCEPTED"); + break; + case LOGIN_PIN_INCORRECT: + if ( pinNums[side][0] == pinNums[side][1] && pinNums[side][0] == pinNums[side][2] && pinNums[side][0] == pinNums[side][3] ) + { + renderLoginMessage(xcoord[side], "PIN# DISALLOWED"); + } + else + { + renderLoginMessage(xcoord[side], "INCORRECT LOGIN"); + } + break; + case LOGIN_SYSTEM_ERROR: + // intentional no break + case LOGIN_WAITING: + renderLoginMessage(xcoord[side], "WAIT..."); + break; + } + } + } + } + + renderTimeRemaining(); + rm.flip(); +} + +void endLoginMode() +{ + gs.g_currentGameMode = MAINMENU; + gs.g_gameModeTransition = 1; + + // count the number of credits played by either player + for ( int side = 0; side < 2; side++ ) + { + sm.player[side].isLoggedIn = false; + if ( isUse[side] ) + { + sm.player[side].isLoggedIn = true; + } + } + + // update and save the most recent player names + for ( int player = 0; player < 2; player++ ) + { + if ( isUse[player] ) + { + for ( int i = getIndexOfPrevName(tempNames[player]); i > 0; i-- ) + { + memcpy_s(prevNames[i], 9, prevNames[i-1], 9); + } + memcpy_s(prevNames[0], 9, tempNames[player], 9); + } + } + saveRecentNames(); +} + +void renderPrompt(int x, bool isUse, bool isPass) +{ + int yoff = blinkTimer < 500 ? blinkTimer / 50 : 10 - ((blinkTimer-500) / 50); + + if ( isUse ) + { + renderBoldString(" LOG IN! ", x, 280+5, 400, false); + } + else if ( isPass ) + { + renderBoldString(" pass... ", x, 280+5, 400, false); + } + else + { + renderBoldString("PRESS START", x, 280+yoff, 400, false); + masked_blit(m_startButton, rm.m_backbuf, 0, 0, x, 310+yoff, 45, 32); + renderTimeRemaining(x+70, 310+yoff); + } +} + +void renderNamePrompt(int x, char side) +{ + int y = 190; + int frame = (blinkTimer/150) % 2; + + rectfill(rm.m_backbuf, x-10, y, x-10+220, y+150, LOGIN_SHADE_COLOR); + + renderBoldString("ENTER YOUR NAME", x, y+10, 400, false); + if ( tempNames[side][0] == 0 ) + { + renderBoldString("(or END to cancel)", x, y+40, 400, false); + } + else if ( sm.doesPlayerNameExist(tempNames[side]) ) + { + renderBoldString("RETURNING PLAYER", x, y+40, 400, false, frame == 0 ? 1 : 2); + } + else + { + renderBoldString("NEW PLAYER", x, y+40, 400, false, 1); + } + + bool isLeftMenuPressed = side == 0 ? im.isKeyDown(MENU_LEFT_1P) : im.isKeyDown(MENU_LEFT_2P); + bool isRightMenuPressed = side == 0 ? im.isKeyDown(MENU_RIGHT_1P) : im.isKeyDown(MENU_RIGHT_2P); + masked_blit(m_triangles, rm.m_backbuf, 0, (char)isLeftMenuPressed * 32, x, y+80, 32, 32); + masked_blit(m_triangles, rm.m_backbuf, 32, (char)isRightMenuPressed * 32, x+98, y+80, 32, 32); + + // render current pin digit + renderNameLetter(nameLetters[cursorPos[side]], x + 48, y+80, 0); + + // render whatever the player entered for a name + //renderNameWithWhitespace(tempNames[side], x-64+1, 180, side+1); +} + +void renderPinPrompt(int x, char side, bool isVerify) +{ + int y = 190; + + rectfill(rm.m_backbuf, x-10, y, x-10+220, y+150, LOGIN_SHADE_COLOR); + + if ( sm.doesPlayerNameExist(tempNames[side]) ) + { + renderBoldString("RETURNING PLAYER", x, y+10, 400, false); + renderBoldString("PIN ENTRY", x, y+40, 400, false); + } + else + { + if ( isVerify ) + { + //renderBoldString("NEW PLAYER", x, y+10, 400, false); + renderBoldString("VERIFY PIN", x+4, y+40, 400, false); + } + else + { + renderBoldString("NEW PLAYER", x, y+10, 400, false); + renderBoldString("CREATE PIN", x+4, y+40, 400, false); + } + } + + bool isLeftMenuPressed = side == 0 ? im.isKeyDown(MENU_LEFT_1P) : im.isKeyDown(MENU_LEFT_2P); + bool isRightMenuPressed = side == 0 ? im.isKeyDown(MENU_RIGHT_1P) : im.isKeyDown(MENU_RIGHT_2P); + masked_blit(m_triangles, rm.m_backbuf, 0, (char)isLeftMenuPressed * 32, x, y+80, 32, 32); + masked_blit(m_triangles, rm.m_backbuf, 32, (char)isRightMenuPressed * 32, x+98, y+80, 32, 32); + + // render current pin digit + renderNameLetter((side == 0 ? currentDigitP1 : currentDigitP2) + '0', x + 48, y+80, 0); + + // render an asterisk for every entered pin digit + for ( int i = 0; i < 4; i++ ) + { + char num = pinNums[side][i] + '0'; + num = '*'; + if ( pinNums[side][i] != -1 ) + { + renderNameLetter(num, x+1+(i*32), y+120, side+1); + } + else + { + renderNameLetter('_', x+1+(i*32), y+120, side+1); + } + } + + // render whatever the player entered for a name + //renderNameWithWhitespace(tempNames[side], x-64+1, 180, side+1); +} + +void renderLoginMessage(int xcoord, char* string) +{ + renderBoldString(string, xcoord, 240, 400, false); +} + +void enterLetter(int player) +{ + int i = 0; + for ( i = 0; i < 7; i++ ) + { + if ( tempNames[player][i] == 0 ) + { + break; + } + } + + char letter = nameLetters[cursorPos[player]]; + if ( letter == '~' ) + { + if ( i == 0 || (i== 7 && tempNames[player][i] != 0) ) + { + tempNames[player][i] = 0; // backspace works differently on the 1st and last letters + } + else + { + tempNames[player][i-1] = 0; + } + em.playSample(SFX_NAME_ENTRY_BACKSPACE); + } + else + { + tempNames[player][i] = letter; // the check for END is done before enterLetter() is called + em.playSample(SFX_MENU_PICK2); + } +} + +bool enterPinDigit(int player) +{ + int i = 0; + for ( i = 0; i < 4; i++ ) + { + if ( pinNums[player][i] == -1 ) + { + pinNums[player][i] = player == 0 ? currentDigitP1 : currentDigitP2; + break; + } + } + em.playSample(SFX_PIN_DIGIT); + return i >= 3; +} + +void renderNameWithWhitespace(char string[9], int x, int y, int color) +{ + for ( int i = 0; i < 8; i++ ) + { + if ( string[i] == 0 ) + { + renderNameLetter('_', x, y, color); + } + else + { + renderNameLetter(string[i], x, y, color); + } + x += 32; + } +} + +void saveRecentNames() +{ + FILE* fp = NULL; + if ( fopen_s(&fp, "conf/recent_players.bin", "wb") != 0 ) + { + return; + } + + for ( int i = 0; i < 4; i++ ) + { + fwrite(&prevNames[i], sizeof(char), 9, fp); + } + fclose(fp); +} + +void resetPrevNames() +{ + prevNames[0][0] = 0; + prevNames[1][0] = 0; + prevNames[2][0] = 0; + prevNames[3][0] = 0; + saveRecentNames(); +} + +void loadRecentNames() +{ + FILE* fp = NULL; + if ( fopen_s(&fp, "conf/recent_players.bin", "rb") != 0 ) + { + return; + } + + for ( int i = 0; i < 4; i++ ) + { + if ( fread_s(&prevNames[i], 9, sizeof(char), 9, fp) < 9 ) + { + // doesn't matter + } + } + fclose(fp); +} + +int getIndexOfPrevName(char* name) +{ + int i = 0; + for ( i = 0; i < 3; i++ ) + { + if ( _stricmp(prevNames[i], name) == 0 ) + { + return i; + } + } + return i; +} \ No newline at end of file diff --git a/src/source/main.cpp b/src/source/main.cpp new file mode 100644 index 0000000..88c86e8 --- /dev/null +++ b/src/source/main.cpp @@ -0,0 +1,1473 @@ +// main.cpp defines the main entry point for DMX +// file created by Allen Seitz on 7/18/2009 +// April 26, 2013: cleaned up many source files and moved into an svn repo + +#include +#include +#include + +// none of these old libraries are built for 64 bit +#pragma warning(disable : 4312) +#include "allegro.h" // allegro library +//#include "apeg.h" // an add on for mpeg and ogg support +#include "loadpng.h" // extra functions for PNG support + +/* +#ifdef __cplusplus +extern "C" { +#endif +#include "logg.h" // an addon for ogg support +#ifdef __cplusplus +} +#endif +//*/ +#pragma warning(default : 4312) + +#include "fmod.h" // an audio library used for playing keysounds + +#include "winalleg.h" +#include "mmsystem.h" // high resolution Windows specific timers + +#include "common.h" +#include "bookManager.h" +#include "inputManager.h" +#include "gameStateManager.h" +#include "scoreManager.h" +#include "videoManager.h" + + +////////////////////////////////////////////////////////////////////////////// +// Song List +////////////////////////////////////////////////////////////////////////////// +SongEntry* songs; // used globally +int NUM_SONGS = 0; +int* songIDs; +std::string* songTitles; +std::string* songArtists; +std::string* movieScripts; + +#define HITLIST_FILENAME "conf/hitlist.dat" +#define SONGDB_FILENAME "DATA/song_db.csv" + +int initializeSonglist(); +int loadSongDB(); + +void savePlayersHitList(); +void loadPlayersHitList(); + + +////////////////////////////////////////////////////////////////////////////// +// Game Logic +////////////////////////////////////////////////////////////////////////////// +volatile UTIME last_utime = 0; // the last time a frame ran +unsigned long int frameCounter = 0; +unsigned long int totalGameTime = 0; +int fpsLastFrame = 0; +int fpsHappyThreshold = 50; +int testMenuMainIndex = 0; +int testMenuSubIndex = 0; +bool allsongsDebug = false; + +BITMAP** m_banners; // used globally +BITMAP* m_caution; +BITMAP* m_failure; +UTIME cautionTimer = 0; +UTIME failureTimer = 0; +UTIME hideCreditsTimer = 0; + +BookManager bm; +RenderingManager rm; +InputManager im; +GameStateManager gs; +ScoreManager sm; +VideoManager vm; +EffectsManager em; + +void firstSplashLoop(); +void mainSplashLoop(UTIME dt); + +void firstWarningLoop(); +void mainWarningLoop(UTIME dt); + +void firstFailureLoop(); +void mainFailureLoop(UTIME dt); + +extern void firstAttractLoop(); +extern void mainAttractLoop(UTIME dt); + +void firstErrorLoop(); +void mainErrorLoop(UTIME dt); + +void firstOperatorLoop(); +void mainOperatorLoop(UTIME dt); + +extern void firstSongwheelLoop(); +extern void mainSongwheelLoop(UTIME dt); +extern void killPreviewClip(); + +extern void firstGameplayLoop(); +extern void mainGameplayLoop(UTIME dt); +extern void loadGameplayGraphics(); + +extern void firstMenuLoop(); +extern void mainMenuLoop(UTIME dt); + +extern void firstLoginLoop(); +extern void mainLoginLoop(UTIME dt); +extern void resetPrevNames(); + +extern void firstNonstopLoop(); +extern void mainNonstopLoop(UTIME dt); + +extern void firstResultsLoop(); +extern void mainResultsLoop(UTIME dt); + +extern void firstGameoverLoop(); +extern void mainGameoverLoop(UTIME dt); + +void firstVideoTestLoop(); +void mainVideoTestLoop(UTIME dt); + +void firstCautionLoop(); +void mainCautionLoop(UTIME dt); + +void renderCreditsDisplay(); + +// operator menus +void renderInputTest(); +void renderLampTest(); +void renderScreenTest(); +void renderColorTest(); +void renderCoinOptions(); +void renderGameOptions(); +void renderBookkeeping(int temp); +void renderSoundOptions(); +void renderDataOptions(); + + +////////////////////////////////////////////////////////////////////////////// +// Main Program +////////////////////////////////////////////////////////////////////////////// +int main() +{ + // setup the Allegro library + allegro_init(); + srand(time(0)); + + // keyboard initialization + if ( install_keyboard() != 0 ) + { + allegro_message("Keyboard Initialization Failed!"); + return EXIT_FAILURE; + } + key_led_flag = 0; + + // timer initalization + if ( timeBeginPeriod(1) != TIMERR_NOERROR ) + { + allegro_message("Unable to initialize timer."); + return EXIT_FAILURE; + } + last_utime = timeGetTime(); + + //* initialize the sound playback + int digienabled = detect_digi_driver(DIGI_AUTODETECT); // check sample software + int midienabled = detect_midi_driver(MIDI_NONE); // not needed + digienabled = digienabled > 8 ? 8 : digienabled; // using more voices lowers quality + midienabled = midienabled > 8 ? 8 : midienabled; // using more voices lowers quality + if ( digienabled == 0 ) + { + allegro_message("Digital Initalization Failed!"); + return EXIT_FAILURE; + } + reserve_voices(digienabled, midienabled); + if ( install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) == -1 ) + { + allegro_message("Audio Initalization Failed!"); + return EXIT_FAILURE; + } + //*/ + + //* initialize... yet more sound playback! + if (!FSOUND_Init(44100, 64, 0)) + { + allegro_message("FMOD failed to initialize: %d", FSOUND_GetError()); + return EXIT_FAILURE; + } + //*/ + + // initialize graphics resources + set_color_depth(32); + int windowOrFullscreen = GFX_AUTODETECT_WINDOWED; + if ( fileExists("fullscreen") ) + { + windowOrFullscreen = GFX_AUTODETECT_FULLSCREEN; + } + if ( set_gfx_mode(windowOrFullscreen, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0) != 0 ) + { + allegro_message("Video Initalization Failed!"); + return EXIT_FAILURE; + } + + set_color_conversion(COLORCONV_MOST|COLORCONV_KEEP_TRANS); + set_display_switch_mode(SWITCH_BACKGROUND); //SWITCH_PAUSE + text_mode(-1); + set_alpha_blender(); // the game assumes the graphics are left in this mode + + if ( fileExists("allsongs") ) + { + allsongsDebug = true; + } + rm.Initialize(); + im.updateKeyStates(1); + em.initialize(); + + loadGameplayGraphics(); // these stay loaded the ENTIRE program + + if ( initializeSonglist() == -1 ) + { + allegro_message("Error loading song database."); + return 0; + } + sm.resetData(); + + // booting while holding service down? delete (overwrite) machine settings + if ( im.isKeyDown(MENU_SERVICE) ) // doesn't seem to work in visual studio + { + globalError(CLEARED_MACHINE_SETTINGS, ""); + } + else + { + gs.loadOperatorSettings(); + if ( !gs.isInitialized ) + { + globalError(UNSET_MACHINE_SETTINGS, "PLEASE REBOOT WHILE HOLDING SERVICE"); + } + } + + // main game loop + while ( !(key[KEY_ESC] /*&& key[KEY_SPACE]*/) ) + { + UTIME time = timeGetTime(); + + if ( time > last_utime ) + { + UTIME dt = time - last_utime; + last_utime = time; + totalGameTime += dt; + + // calculate the framerate + if ( totalGameTime >= 1000 ) + { + fpsLastFrame = frameCounter / (totalGameTime/1000); + //al_trace("FPS: %d\r\n", fpsLastFrame); + } + + // update the core classes and check for lag + im.updateKeyStates(dt); + bm.logTime(dt, gs.g_currentGameMode); + vm.update(dt, fpsLastFrame < fpsHappyThreshold); // if we're not getting enoguh fps, then pause the movie + + if ( gs.g_gameModeTransition == 2 ) + { + gs.g_gameModeTransition = 0; + al_trace("%ld msec were eaten by load times.\r\n", dt); + continue; + } + + // check for the three menu buttons which work in all modes + if ( im.getKeyState(MENU_TEST) == JUST_DOWN && gs.g_currentGameMode != TESTMODE ) + { + gs.g_gameModeTransition = 1; + gs.g_currentGameMode = TESTMODE; + gs.killSong(); + } + if ( im.getKeyState(MENU_SERVICE) == JUST_DOWN || im.getKeyState(MENU_COIN) == JUST_DOWN ) + { + if ( gs.g_currentGameMode != TESTMODE ) + { + gs.numCoins++; + bm.logCoin(im.getKeyState(MENU_SERVICE) == JUST_DOWN); + } + em.playSample(SFX_CREDIT); + } + + // render the credits display + if ( gs.g_currentGameMode != TESTMODE && hideCreditsTimer == 0 ) + { + renderCreditsDisplay(); + } + else if ( gs.g_currentGameMode != TESTMODE ) + { + if ( gs.g_currentGameMode != GAMEPLAY ) + { + rectfill(rm.m_backbuf, 0, 460, 640, 480, 0); // burn-in protection + } + blit(rm.m_backbuf, screen, 0, 460, 0, 460, 640, 20); + } + SUBTRACT_TO_ZERO(hideCreditsTimer, dt); + + // switch between modes + if ( gs.g_gameModeTransition == 1 ) + { + gs.g_gameModeTransition = 2; + frameCounter = 0; + totalGameTime = 0; + killPreviewClip(); // mainly for pressing TEST during the songwheel + hideCreditsTimer = 2000; + + // do the first frame different from the rest + switch (gs.g_currentGameMode) + { + case SPLASH: + firstSplashLoop(); + break; + case WARNING: + firstWarningLoop(); + break; + case SONGWHEEL: + firstSongwheelLoop(); + break; + case GAMEPLAY: + firstGameplayLoop(); + break; + case RECORDING: + globalError(0, "Invalid game mode?"); + //firstRecordingLoop(); + break; + case PLAYERSELECT: + case MAINMENU: + firstMenuLoop(); + break; + case RESULTS: + firstResultsLoop(); + break; + case TESTMODE: + firstOperatorLoop(); + break; + case LOGIN: + firstLoginLoop(); + break; + case GAMEOVER: + firstGameoverLoop(); + break; + case ATTRACT: + savePlayersHitList(); + firstAttractLoop(); + break; + case ERRORMODE: + firstErrorLoop(); + break; + case VIDEOTEST: + firstVideoTestLoop(); + break; + case CAUTIONMODE: + firstCautionLoop(); + break; + case NONSTOP: + firstNonstopLoop(); + break; + case FAILURE: + firstFailureLoop(); + break; + default: + break; + } + } + else + { + // process one frame + switch (gs.g_currentGameMode) + { + case SPLASH: + mainSplashLoop(dt); + break; + case WARNING: + mainWarningLoop(dt); + break; + case SONGWHEEL: + mainSongwheelLoop(dt); + break; + case GAMEPLAY: + mainGameplayLoop(dt); + break; + case RECORDING: + //mainRecordingLoop(dt); + break; + case PLAYERSELECT: + case MAINMENU: + mainMenuLoop(dt); + break; + case RESULTS: + mainResultsLoop(dt); + break; + case TESTMODE: + mainOperatorLoop(dt); + break; + case LOGIN: + mainLoginLoop(dt); + break; + case GAMEOVER: + mainGameoverLoop(dt); + break; + case ATTRACT: + mainAttractLoop(dt); + break; + case ERRORMODE: + mainErrorLoop(dt); + break; + case VIDEOTEST: + mainVideoTestLoop(dt); + break; + case CAUTIONMODE: + mainCautionLoop(dt); + break; + case NONSTOP: + mainNonstopLoop(dt); + break; + case FAILURE: + mainFailureLoop(dt); + break; + default: + break; + } + ++frameCounter; + } + } + + // share the processor + //rest(0); + } + + // clean up + gs.killSong(); + + return EXIT_SUCCESS; +} +END_OF_MAIN(); + +void firstSplashLoop() +{ +} + +void mainSplashLoop(UTIME dt) +{ + UNUSED(dt); +} + +void firstWarningLoop() +{ +} + +void mainWarningLoop(UTIME dt) +{ + UNUSED(dt); +} + +void firstErrorLoop() +{ +} + +void mainErrorLoop(UTIME dt) +{ + static UTIME accumulate = 0; + accumulate += dt; + + int redTimer = accumulate % 2000; + int bordercolor = makecol(getValueFromRange(111,222, redTimer*100/2000), 0, 0); + + solid_mode(); + rectfill(rm.m_backbuf, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0); + for ( int i = 0; i < 10; i++ ) + { + rect(rm.m_backbuf, 20+i, 20+i, SCREEN_WIDTH-20-i, SCREEN_HEIGHT-20-i, bordercolor); + } + set_alpha_blender(); // the game assumes that the graphics are left in this mode + + textprintf_centre(rm.m_backbuf, font, 320, 70, makecol(255,255,255), "ERROR %d", gs.g_errorCode); + textprintf_centre(rm.m_backbuf, font, 320, 120, makecol(255,255,255), gs.getErrorString()); + textprintf_centre(rm.m_backbuf, font, 320, 170, makecol(255,255,255), gs.g_errorInfo); + + textprintf_centre(rm.m_backbuf, font, 320, 300, makecol(255,255,255), "PLEASE PRESS TEST BUTTON"); + textprintf_centre(rm.m_backbuf, font, 320, 410, makecol(255,255,255), "time = %d", accumulate/1000); + + rm.flip(); +} + +void firstFailureLoop() +{ + failureTimer = 0; + if ( m_failure == NULL ) + { + m_failure = loadImage("DATA/attract/failure.png"); + } +} + +void mainFailureLoop(UTIME dt) +{ + // play this sound effect once right as the timer reaches this threshold + if ( failureTimer < SCREEN_HEIGHT && failureTimer+dt >= SCREEN_HEIGHT ) + { + em.playSample(SFX_FAILURE_ANIMATION); + } + + failureTimer += dt; + + // implement the black "wipe down" + if ( failureTimer < SCREEN_HEIGHT ) // typically 480? and 480ms? + { + rectfill(rm.m_backbuf, 0, 0, SCREEN_WIDTH, failureTimer, 0); + } + else + { + clear_to_color(rm.m_backbuf, 0); + } + + // render the digital "FAILED_" + int frame = 7; + if ( failureTimer < 1000+SCREEN_HEIGHT ) + { + frame = MIN(7, getValueFromRange(0, 7, (failureTimer-SCREEN_HEIGHT)*100/(1000-SCREEN_HEIGHT))); + } + if ( failureTimer > SCREEN_HEIGHT ) + { + blit(m_failure, rm.m_backbuf, 0, frame*30, (SCREEN_WIDTH-148)/2, (SCREEN_HEIGHT-30)/2, 176, 30); + } + + // done forever? + if ( failureTimer > 4000 ) + { + gs.g_currentGameMode = RESULTS; + gs.g_gameModeTransition = 1; + } + + rm.flip(); +} + +// this function ultimately renders the bottom twenty pixels +void renderCreditsDisplay() +{ + if ( gs.g_currentGameMode != GAMEPLAY ) + { + rectfill(rm.m_backbuf, 0, 460, 640, 480, makecol(0,0,0)); + } + + // for burn-in protection, move this around (nevermind, done another way) + int x = 375; + int y = 464; // default position + + if ( gs.isFreeplay ) + { + renderWhiteString(" FREE PLAY ", x-110, y); + } + else + { + renderWhiteString("CREDIT(S): ", x-110, y); + + int numGames = gs.numCoins / gs.numCoinsPerCredit; + int numFraction = gs.numCoins % gs.numCoinsPerCredit; + renderWhiteNumber(numGames, x, y); + x = x + 24 + (numGames >= 10 ? 12 : 0); + if ( numFraction > 0 ) + { + renderWhiteNumber(numFraction, x, y); + x = x + 12 + (numFraction >= 10 ? 12 : 0); + renderWhiteString("/", x, y); + renderWhiteNumber(gs.numCoinsPerCredit, x+12, y); + } + } + blit(rm.m_backbuf, screen, 0, 460, 0, (y-4), 640, 480); +} + +void firstOperatorLoop() +{ + bm.forceBookkeepingSave(); + testMenuMainIndex = 0; + testMenuSubIndex = -1; + gs.killSong(); + gs.numCoins = 0; // might as well, just in case this needs to be done + im.setCooldownTime(0); +} + +#define NUM_OP_MENU_CHOICES 11 + +void mainOperatorLoop(UTIME dt) +{ + static int tempSelection = 0; + UNUSED(dt); + clear_to_color(rm.m_backbuf, 0); + + if ( testMenuSubIndex == -1 ) // in the main menu + { + textprintf_centre(rm.m_backbuf, font, 320, 50, WHITE, "TEST MENU"); + textprintf(rm.m_backbuf, font, 50, 100, testMenuMainIndex == 0 ? RED : WHITE, "INPUT TEST"); + textprintf(rm.m_backbuf, font, 50, 120, testMenuMainIndex == 1 ? RED : WHITE, "LAMP TEST"); + textprintf(rm.m_backbuf, font, 50, 140, testMenuMainIndex == 2 ? RED : WHITE, "SCREEN TEST"); + textprintf(rm.m_backbuf, font, 50, 160, testMenuMainIndex == 3 ? RED : WHITE, "COLOR TEST"); + textprintf(rm.m_backbuf, font, 50, 180, testMenuMainIndex == 4 ? RED : WHITE, "COIN OPTIONS"); + textprintf(rm.m_backbuf, font, 50, 200, testMenuMainIndex == 5 ? RED : WHITE, "GAME OPTIONS"); + textprintf(rm.m_backbuf, font, 50, 220, testMenuMainIndex == 6 ? RED : WHITE, "SOUND OPTIONS"); + textprintf(rm.m_backbuf, font, 50, 240, testMenuMainIndex == 7 ? RED : WHITE, "BOOKKEEPING"); + textprintf(rm.m_backbuf, font, 50, 260, testMenuMainIndex == 8 ? RED : WHITE, "DATA OPTIONS"); + textprintf(rm.m_backbuf, font, 50, 300, testMenuMainIndex == 9 ? RED : WHITE, "ALL FACTORY DEFAULTS"); + textprintf(rm.m_backbuf, font, 50, 320, testMenuMainIndex == 10 ? RED : WHITE, "GAME MODE"); + + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_TEST) == JUST_DOWN ) + { + testMenuSubIndex = 0; // enter that submenu + tempSelection = 0; + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_SERVICE) == JUST_DOWN ) + { + testMenuMainIndex = (testMenuMainIndex + 1) % NUM_OP_MENU_CHOICES; + } + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN ) + { + testMenuMainIndex = (testMenuMainIndex - 1 + NUM_OP_MENU_CHOICES) % NUM_OP_MENU_CHOICES; + } + } + else + { + switch (testMenuMainIndex) + { + case 0: // input test + renderInputTest(); + if ( im.isKeyDown(MENU_START_1P) && im.isKeyDown(MENU_START_2P) ) + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + break; + case 1: // lamp test + renderLampTest(); + if ( im.isKeyDown(MENU_START_1P) && im.isKeyDown(MENU_START_2P) ) + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_SERVICE) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex + 1) % 20; + } + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex - 1 + 20) % 20; + } + if ( im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN ) + { + tempSelection = (tempSelection + 4) % 4; // use temp selection to set lamp states + } + if ( im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + tempSelection = (tempSelection - 1 + 4) % 4; + } + break; + case 2: // screen test + renderScreenTest(); + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN ) + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + break; + case 3: // color test + renderColorTest(); + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN ) + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + break; + case 4: // coin options + renderCoinOptions(); + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN ) + { + if ( testMenuSubIndex == 4 ) + { + gs.isFreeplay = false; + gs.numCoinsPerCredit = DEFAULT_COINS_PER_CREDIT; + gs.isVersusPremium = false; + gs.isDoublePremium = false; + } + if ( testMenuSubIndex == 5 ) + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_SERVICE) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex + 1) % 6; + } + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex - 1 + 6) % 6; + } + if ( im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN || im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + switch (testMenuSubIndex) + { + case 0: + gs.isFreeplay = !gs.isFreeplay; + break; + case 1: + if ( im.getKeyState(MENU_LEFT_2P) == JUST_DOWN && gs.numCoinsPerCredit > 1 ) + { + gs.numCoinsPerCredit -= 1; + } + if ( im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN && gs.numCoinsPerCredit < 16 ) + { + gs.numCoinsPerCredit += 1; + } + break; + case 2: + gs.isVersusPremium = !gs.isVersusPremium; + break; + case 3: + gs.isDoublePremium = !gs.isDoublePremium; + break; + } + } + break; + case 5: // game options + renderGameOptions(); + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN ) + { + if ( testMenuSubIndex == 2 ) + { + gs.numSongsPerSet = DEFAULT_SONGS_PER_SET; + } + if ( testMenuSubIndex == 3 ) + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_SERVICE) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex + 1) % 4; + } + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex - 1 + 4) % 4; + } + if ( im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN || im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + switch (testMenuSubIndex) + { + case 0: + if ( im.getKeyState(MENU_LEFT_2P) == JUST_DOWN && gs.numSongsPerSet > 2 ) + { + gs.numSongsPerSet -= 1; + } + if ( im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN && gs.numSongsPerSet < 5 ) + { + gs.numSongsPerSet += 1; + } + break; + case 1: + gs.isEventMode = !gs.isEventMode; + break; + } + } + break; + case 6: // sound options + renderSoundOptions(); + if ( im.isKeyDown(MENU_START_1P) ) + { + if ( testMenuSubIndex == 3 ) + { + // TODO: set sound in attract mode to default + } + if ( testMenuSubIndex == 4 ) + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_SERVICE) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex + 1) % 5; + } + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex - 1 + 5) % 5; + } + if ( im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN ) + { + if ( testMenuSubIndex == 0 ) + { + // TODO: cycle through sound in attract options + } + } + if ( im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + if ( testMenuSubIndex == 0 ) + { + // TODO: cycle through sound in attract options + } + } + + break; + case 7: // bookkeeping + renderBookkeeping(tempSelection); + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN ) + { + if ( testMenuSubIndex == 3 ) + { + testMenuSubIndex = 0; + if ( tempSelection == 1 ) + { + bm.nukeBookkeeping(); + } + } + else + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + } + if ( im.getKeyState(MENU_START_2P) == JUST_DOWN && testMenuSubIndex != 3 ) + { + testMenuSubIndex = 3; + tempSelection = 0; + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN && testMenuSubIndex != 3 ) + { + testMenuSubIndex = (testMenuSubIndex + 1) % 3; // use testMenuSubIndex for each page (4th page is delete confirmation page) + } + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN && testMenuSubIndex != 3 ) + { + testMenuSubIndex = (testMenuSubIndex - 1 + 3) % 3; + } + if ( im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN && testMenuSubIndex == 3 ) + { + tempSelection = 1; // use tempSelection for the yes/no prompt + } + if ( im.getKeyState(MENU_LEFT_2P) == JUST_DOWN && testMenuSubIndex == 3 ) + { + tempSelection = 0; + } + break; + case 8: // data options + renderDataOptions(); + if ( im.isKeyDown(MENU_START_1P) ) + { + if ( testMenuSubIndex == 0 ) // reset player's hits chart + { + for ( int i = 0; i < NUM_SONGS; i++ ) + { + songs[i].numPlays = 0; + } + } + if ( testMenuSubIndex == 1 ) // reset last logins + { + resetPrevNames(); + } + if ( testMenuSubIndex == 2 ) // delete player + { + } + if ( testMenuSubIndex == 3 ) // change player pin + { + } + if ( testMenuSubIndex == 4 ) + { + testMenuMainIndex = 0; + testMenuSubIndex = -1; + } + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_SERVICE) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex + 1) % 5; + } + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN ) + { + testMenuSubIndex = (testMenuSubIndex - 1 + 5) % 5; + } + + break; + case 9: // factory defaults + testMenuMainIndex = 0; + testMenuSubIndex = -1; + break; + case 10: // quit to game mode + gs.g_gameModeTransition = 1; + gs.g_currentGameMode = ATTRACT; + gs.saveOperatorSettings(); + im.updateKeyStates(1); // so that 1P start is not "just down" in the attract loop + break; + } + } + + if ( testMenuMainIndex != 2 || testMenuSubIndex == -1 ) // the screen test needs the whole screen + { + rm.flip(); + rectfill(screen, 0, 460, 640, 480, makeacol(0,0,0,255)); // burn-in protection + } +} + +void firstVideoTestLoop() +{ + vm.reset(); + vm.loadScript(movieScripts[0].c_str()); + vm.play(); +} + +void mainVideoTestLoop(UTIME dt) +{ + static int videoIndex = 0; + + UNUSED(dt); + clear_to_color(rm.m_backbuf, 0); + vm.renderToSurface(rm.m_backbuf, 100, 100); + renderWhiteString("MOVIE TEST", 10, 10); + renderWhiteString(movieScripts[videoIndex].c_str(), 10, 30); + rm.flip(); + + if ( im.getKeyState(MENU_START_2P) == JUST_DOWN ) + { + vm.reset(); + vm.play(); + } + if ( videoIndex > 0 && im.getKeyState(MENU_LEFT_1P) == JUST_DOWN ) + { + videoIndex--; + vm.loadScript(movieScripts[videoIndex].c_str()); + vm.play(); + } + if ( videoIndex < NUM_SONGS-1 && im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN ) + { + videoIndex++; + vm.loadScript(movieScripts[videoIndex].c_str()); + vm.play(); + } +} + +void firstCautionLoop() +{ + if ( m_caution == NULL ) + { + m_caution = loadImage("DATA/menus/caution.png"); + } + cautionTimer = 0; +} + +void mainCautionLoop(UTIME dt) +{ + blit(m_caution, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + cautionTimer += dt; + if ( cautionTimer < 500 ) + { + rm.dimScreen(getValueFromRange(100, 0, cautionTimer*100/500)); + } + if ( cautionTimer >= 2500 ) + { + rm.dimScreen(getValueFromRange(0, 100, (cautionTimer-2500)*100/500)); + } + if ( cautionTimer >= 3000 ) + { + gs.g_gameModeTransition = 1; + gs.g_currentGameMode = PLAYERSELECT; + } + rm.flip(); +} + +int initializeSonglist() +{ + if ( loadSongDB() == -1 ) + { + return -1; // aw crap + } + + // load banners + m_banners = (BITMAP **)malloc( sizeof(BITMAP) * NUM_SONGS); + char bfilename[] = "DATA/banners/0000.png"; + for ( int i = 0; i < NUM_SONGS; i++ ) + { + int c = songs[i].songID; + bfilename[13] = (c/1000)%10 + '0'; + bfilename[14] = (c/100)%10 + '0'; + bfilename[15] = (c/10)%10 + '0'; + bfilename[16] = c%10 + '0'; + m_banners[i] = load_bitmap(bfilename, NULL); + if ( m_banners[i] == NULL ) + { + m_banners[i] = create_bitmap(256,256); + clear_to_color(m_banners[i], 0); + textprintf_centre(m_banners[i], font, 128, 128, 0xFFFFFF, "BANNER %d", c); + } + } + + loadPlayersHitList(); + return 0; +} + +int loadSongDB() +{ + FILE* fp = NULL; + + if ( fopen_s(&fp, SONGDB_FILENAME, "rt") != 0 ) + { + allegro_message("Unable to find DATA/song_db.csv"); + return -1; + } + + // the first line of the file is: DMXDB,1,103,April 6th 2013 + char sanityCheck[32] = ""; + int verNum = 0; + char date[32] = ""; + fscanf_s(fp, "%[^,],%[^,],%d,%d ", &sanityCheck, 8, &date, 32, &NUM_SONGS, &verNum); + if ( _stricmp(sanityCheck, "DMXDB") != 0 ) + { + allegro_message("Unexpected file contents in song_db.csv"); + return -1; + } + if ( verNum != 1 ) + { + allegro_message("Unexpected version number in song_db.csv: found %d expected 1", verNum); + return -1; + } + + fscanf_s(fp, "%[,] ", &sanityCheck, 32); // get rid of those commas + + songIDs = (int *)malloc(sizeof(int) * NUM_SONGS); + songTitles = new std::string[NUM_SONGS]; + songArtists = new std::string[NUM_SONGS]; + movieScripts = new std::string[NUM_SONGS]; + songs = (SongEntry *)malloc(sizeof(SongEntry) * NUM_SONGS); + + // now read a bunch of lines that look like: + // -> 101,BROKEN MY HEART,NAOKI feat.PAULA TERRY,brok.seq,4,0,7,0,6,0,6,0,1,0,0 + for ( int i = 0; i < NUM_SONGS; i++ ) + { + int id = 0; + char name[64] = ""; + char artist[64] = ""; + int minbpm = 0, maxbpm = 0; + char movie[64] = ""; + int sm = 0, smnotes = 0; + int sw = 0, swnotes = 0; + int dm = 0, dmnotes = 0; + int dw = 0, dwnotes = 0; + int version = 0; + int flag = 0; + int isNew = 0; + + fscanf_s(fp, "%d,%[^,],%[^,],%d,%d,%[^,],%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", &id, &name, 64, &artist, 64, &minbpm, &maxbpm, &movie, 64, &sm, &smnotes, &sw, &swnotes, &dm, &dmnotes, &dw, &dwnotes, &version, &flag, &isNew); + + songIDs[i] = id; + songTitles[i].assign(name, strlen(name)); + songArtists[i].assign(artist, strlen(artist)); + movieScripts[i].assign(movie, strlen(movie)); + songs[i].initialize(id, minbpm, maxbpm, sm, sw, dm, dw, version); // BROKEN MY HEART + songs[i].unlockFlag = flag; + songs[i].isNew = isNew == 1; + } + + return 0; +} + +void savePlayersHitList() +{ + FILE* fp = NULL; + + if ( fopen_s(&fp, HITLIST_FILENAME, "wb") != 0 ) + { + TRACE("UNABLE TO SAVE PLAYERS BEST LIST"); + return; + } + + // write the version + fprintf(fp, "DMXH"); + int vnum = CURRENT_VERSION_NUMBER; + fwrite(&vnum, sizeof(long), 1, fp); + + // write everything out + for ( int i = 0; i < NUM_SONGS; i++ ) + { + fwrite(&songs[i].songID, sizeof(int), 1, fp); + fwrite(&songs[i].numPlays, sizeof(int), 1, fp); + } + safeCloseFile(fp, HITLIST_FILENAME); +} + +void loadPlayersHitList() +{ + FILE* fp = NULL; + int n = 0; + + // does file exist? + if ( (fp = safeLoadFile(HITLIST_FILENAME)) == NULL ) + { + return; // no big deal + } + + // check the version + int vnum = checkFileVersion(fp, "DMXH"); + if ( vnum != CURRENT_VERSION_NUMBER ) + { + TRACE("Wrong hitlist version number."); + return; // later when multiple versions exist, ideas for converting them + } + + // read a bunch of (songid, playcount) pairs until there are none left + while ( fread(&n, sizeof(int), 1, fp) > 0 ) + { + int listindex = songID_to_listID(n); + fread(&n, sizeof(int), 1, fp); + if ( listindex >= 0 ) + { + songs[listindex].numPlays = n; + } + } + fclose(fp); +} + +void renderInputTest() +{ + textprintf_centre(rm.m_backbuf, font, 320, 50, WHITE, "INPUT TEST"); + textprintf(rm.m_backbuf, font, 50, 100, GREEN, "1P LEFT SIDE"); + textprintf(rm.m_backbuf, font, 50, 120, WHITE, "TOP L: "); + textprintf(rm.m_backbuf, font, 50, 140, WHITE, "TOP R: "); + textprintf(rm.m_backbuf, font, 50, 160, WHITE, "LOW L: "); + textprintf(rm.m_backbuf, font, 50, 180, WHITE, "LOW R: "); + textprintf(rm.m_backbuf, font, 50, 200, WHITE, "MENU LEFT : "); + textprintf(rm.m_backbuf, font, 50, 220, WHITE, "MENU RIGHT: "); + textprintf(rm.m_backbuf, font, 50, 240, WHITE, "MENU START: "); + textprintf(rm.m_backbuf, font, 106, 120, GET_ON_COLOR(im.isKeyDown(UL_1P)), GET_ON_OFF(im.isKeyDown(UL_1P))); + textprintf(rm.m_backbuf, font, 106, 140, GET_ON_COLOR(im.isKeyDown(UR_1P)), GET_ON_OFF(im.isKeyDown(UR_1P))); + textprintf(rm.m_backbuf, font, 106, 160, GET_ON_COLOR(im.isKeyDown(BLUE_SENSOR_1PL0)), GET_ON_OFF(im.isKeyDown(BLUE_SENSOR_1PL0))); + textprintf(rm.m_backbuf, font, 106, 180, GET_ON_COLOR(im.isKeyDown(BLUE_SENSOR_1PR0)), GET_ON_OFF(im.isKeyDown(BLUE_SENSOR_1PR0))); + textprintf(rm.m_backbuf, font, 138, 160, GET_ON_COLOR(im.isKeyDown(BLUE_SENSOR_1PL1)), GET_ON_OFF(im.isKeyDown(BLUE_SENSOR_1PL1))); + textprintf(rm.m_backbuf, font, 138, 180, GET_ON_COLOR(im.isKeyDown(BLUE_SENSOR_1PR1)), GET_ON_OFF(im.isKeyDown(BLUE_SENSOR_1PR1))); + textprintf(rm.m_backbuf, font, 144, 200, GET_ON_COLOR(im.isKeyDown(MENU_LEFT_1P)), GET_ON_OFF(im.isKeyDown(MENU_LEFT_1P))); + textprintf(rm.m_backbuf, font, 144, 220, GET_ON_COLOR(im.isKeyDown(MENU_RIGHT_1P)), GET_ON_OFF(im.isKeyDown(MENU_RIGHT_1P))); + textprintf(rm.m_backbuf, font, 144, 240, GET_ON_COLOR(im.isKeyDown(MENU_START_1P)), GET_ON_OFF(im.isKeyDown(MENU_START_1P))); + + textprintf(rm.m_backbuf, font, 400, 100, GREEN, "2P RIGHT SIDE"); + textprintf(rm.m_backbuf, font, 400, 120, WHITE, "TOP L: "); + textprintf(rm.m_backbuf, font, 400, 140, WHITE, "TOP R: "); + textprintf(rm.m_backbuf, font, 400, 160, WHITE, "LOW L: "); + textprintf(rm.m_backbuf, font, 400, 180, WHITE, "LOW R: "); + textprintf(rm.m_backbuf, font, 400, 200, WHITE, "MENU LEFT : "); + textprintf(rm.m_backbuf, font, 400, 220, WHITE, "MENU RIGHT: "); + textprintf(rm.m_backbuf, font, 400, 240, WHITE, "MENU START: "); + textprintf(rm.m_backbuf, font, 456, 120, GET_ON_COLOR(im.isKeyDown(UL_2P)), GET_ON_OFF(im.isKeyDown(UL_2P))); + textprintf(rm.m_backbuf, font, 456, 140, GET_ON_COLOR(im.isKeyDown(UR_2P)), GET_ON_OFF(im.isKeyDown(UR_2P))); + textprintf(rm.m_backbuf, font, 456, 160, GET_ON_COLOR(im.isKeyDown(BLUE_SENSOR_2PL0)), GET_ON_OFF(im.isKeyDown(BLUE_SENSOR_2PL0))); + textprintf(rm.m_backbuf, font, 456, 180, GET_ON_COLOR(im.isKeyDown(BLUE_SENSOR_2PR0)), GET_ON_OFF(im.isKeyDown(BLUE_SENSOR_2PR0))); + textprintf(rm.m_backbuf, font, 488, 160, GET_ON_COLOR(im.isKeyDown(BLUE_SENSOR_2PL1)), GET_ON_OFF(im.isKeyDown(BLUE_SENSOR_2PL1))); + textprintf(rm.m_backbuf, font, 488, 180, GET_ON_COLOR(im.isKeyDown(BLUE_SENSOR_2PR1)), GET_ON_OFF(im.isKeyDown(BLUE_SENSOR_2PR1))); + textprintf(rm.m_backbuf, font, 494, 200, GET_ON_COLOR(im.isKeyDown(MENU_LEFT_2P)), GET_ON_OFF(im.isKeyDown(MENU_LEFT_2P))); + textprintf(rm.m_backbuf, font, 494, 220, GET_ON_COLOR(im.isKeyDown(MENU_RIGHT_2P)), GET_ON_OFF(im.isKeyDown(MENU_RIGHT_2P))); + textprintf(rm.m_backbuf, font, 494, 240, GET_ON_COLOR(im.isKeyDown(MENU_START_2P)), GET_ON_OFF(im.isKeyDown(MENU_START_2P))); + + textprintf(rm.m_backbuf, font, 250, 300, WHITE, " TEST: "); + textprintf(rm.m_backbuf, font, 250, 320, WHITE, "SERVICE: "); + textprintf(rm.m_backbuf, font, 250, 340, WHITE, " COIN: "); + textprintf(rm.m_backbuf, font, 330, 300, GET_ON_COLOR(im.isKeyDown(MENU_TEST)), GET_ON_OFF(im.isKeyDown(MENU_TEST))); + textprintf(rm.m_backbuf, font, 330, 320, GET_ON_COLOR(im.isKeyDown(MENU_SERVICE)), GET_ON_OFF(im.isKeyDown(MENU_SERVICE))); + textprintf(rm.m_backbuf, font, 330, 340, GET_ON_COLOR(im.isKeyDown(MENU_COIN)), GET_ON_OFF(im.isKeyDown(MENU_COIN))); + + textprintf(rm.m_backbuf, font, 50, 440, WHITE, "1P START + 2P START = exit input test"); +} + +void renderLampTest() +{ + textprintf_centre(rm.m_backbuf, font, 320, 50, WHITE, "LAMP TEST"); + textprintf_centre(rm.m_backbuf, font, 320, 70, testMenuSubIndex == 0 ? RED : WHITE, "LIGHT ALL LAMPS"); + textprintf(rm.m_backbuf, font, 50, 100, GREEN, "1P LEFT SIDE"); + textprintf(rm.m_backbuf, font, 50, 120, testMenuSubIndex == 1 ? RED : WHITE, "TOP L: "); + textprintf(rm.m_backbuf, font, 50, 140, testMenuSubIndex == 2 ? RED : WHITE, "TOP R: "); + textprintf(rm.m_backbuf, font, 50, 160, testMenuSubIndex == 3 ? RED : WHITE, "LOW L: "); + textprintf(rm.m_backbuf, font, 50, 180, testMenuSubIndex == 4 ? RED : WHITE, "LOW R: "); + textprintf(rm.m_backbuf, font, 50, 200, testMenuSubIndex == 5 ? RED : WHITE, "MENU LEFT : "); + textprintf(rm.m_backbuf, font, 50, 220, testMenuSubIndex == 6 ? RED : WHITE, "MENU RIGHT: "); + textprintf(rm.m_backbuf, font, 50, 240, testMenuSubIndex == 7 ? RED : WHITE, "MENU START: "); + textprintf(rm.m_backbuf, font, 106, 120, GET_LAMP_COLOR(0), GET_LAMP_STRING(0)); + textprintf(rm.m_backbuf, font, 106, 140, GET_LAMP_COLOR(0), GET_LAMP_STRING(0)); + textprintf(rm.m_backbuf, font, 106, 160, GET_LAMP_COLOR(0), GET_LAMP_STRING(0)); + textprintf(rm.m_backbuf, font, 106, 180, GET_LAMP_COLOR(0), GET_LAMP_STRING(0)); + textprintf(rm.m_backbuf, font, 144, 200, GET_ON_COLOR(0), GET_ON_OFF(0)); + textprintf(rm.m_backbuf, font, 144, 220, GET_ON_COLOR(0), GET_ON_OFF(0)); + textprintf(rm.m_backbuf, font, 144, 240, GET_ON_COLOR(0), GET_ON_OFF(0)); + + textprintf(rm.m_backbuf, font, 400, 100, GREEN, "2P RIGHT SIDE"); + textprintf(rm.m_backbuf, font, 400, 120, testMenuSubIndex == 8 ? RED : WHITE, "TOP L: "); + textprintf(rm.m_backbuf, font, 400, 140, testMenuSubIndex == 9 ? RED : WHITE, "TOP R: "); + textprintf(rm.m_backbuf, font, 400, 160, testMenuSubIndex == 10 ? RED : WHITE, "LOW L: "); + textprintf(rm.m_backbuf, font, 400, 180, testMenuSubIndex == 11 ? RED : WHITE, "LOW R: "); + textprintf(rm.m_backbuf, font, 400, 200, testMenuSubIndex == 12 ? RED : WHITE, "MENU LEFT : "); + textprintf(rm.m_backbuf, font, 400, 220, testMenuSubIndex == 13 ? RED : WHITE, "MENU RIGHT: "); + textprintf(rm.m_backbuf, font, 400, 240, testMenuSubIndex == 14 ? RED : WHITE, "MENU START: "); + textprintf(rm.m_backbuf, font, 456, 120, GET_LAMP_COLOR(0), GET_LAMP_STRING(0)); + textprintf(rm.m_backbuf, font, 456, 140, GET_LAMP_COLOR(0), GET_LAMP_STRING(0)); + textprintf(rm.m_backbuf, font, 456, 160, GET_LAMP_COLOR(0), GET_LAMP_STRING(0)); + textprintf(rm.m_backbuf, font, 456, 180, GET_LAMP_COLOR(0), GET_LAMP_STRING(0)); + textprintf(rm.m_backbuf, font, 494, 200, GET_ON_COLOR(0), GET_ON_OFF(0)); + textprintf(rm.m_backbuf, font, 494, 220, GET_ON_COLOR(0), GET_ON_OFF(0)); + textprintf(rm.m_backbuf, font, 494, 240, GET_ON_COLOR(0), GET_ON_OFF(0)); + + textprintf(rm.m_backbuf, font, 250, 300, testMenuSubIndex == 15 ? RED : WHITE, " SPOT 1: "); + textprintf(rm.m_backbuf, font, 250, 320, testMenuSubIndex == 16 ? RED : WHITE, " SPOT 2: "); + textprintf(rm.m_backbuf, font, 250, 340, testMenuSubIndex == 17 ? RED : WHITE, " SPOT 3: "); + textprintf(rm.m_backbuf, font, 250, 360, testMenuSubIndex == 18 ? RED : WHITE, " SPOT 4: "); + textprintf(rm.m_backbuf, font, 250, 380, testMenuSubIndex == 19 ? RED : WHITE, " SPOT 5: "); + textprintf(rm.m_backbuf, font, 330, 300, GET_ON_COLOR(0), GET_ON_OFF(0)); + textprintf(rm.m_backbuf, font, 330, 320, GET_ON_COLOR(0), GET_ON_OFF(0)); + textprintf(rm.m_backbuf, font, 330, 340, GET_ON_COLOR(0), GET_ON_OFF(0)); + textprintf(rm.m_backbuf, font, 330, 360, GET_ON_COLOR(0), GET_ON_OFF(0)); + textprintf(rm.m_backbuf, font, 330, 380, GET_ON_COLOR(0), GET_ON_OFF(0)); + + textprintf(rm.m_backbuf, font, 50, 420, WHITE, "PRESS 1P LEFT/RIGHT = change target lamp"); + textprintf(rm.m_backbuf, font, 50, 440, WHITE, "PRESS 2P LEFT/RIGHT = change lamp color"); + textprintf(rm.m_backbuf, font, 50, 460, WHITE, "1P START + 2P START = exit lamp test"); +} + +void renderScreenTest() +{ + // every 20 pixels, gridlines + solid_mode(); + for ( int x = 0; x < SCREEN_WIDTH; x += 20 ) + { + line(rm.m_backbuf, x, 0, x, SCREEN_HEIGHT, x == SCREEN_WIDTH/2 ? RED : WHITE); + line(rm.m_backbuf, x+1, 0, x+1, SCREEN_HEIGHT, x == SCREEN_WIDTH/2 ? RED : WHITE); + } + for ( int y = 0; y < SCREEN_HEIGHT; y += 20 ) + { + line(rm.m_backbuf, 0, y, SCREEN_WIDTH, y, y == SCREEN_HEIGHT/2 ? RED : WHITE); + line(rm.m_backbuf, 0, y+1, SCREEN_WIDTH, y+1, y == SCREEN_HEIGHT/2 ? RED : WHITE); + } + + rect(rm.m_backbuf, 0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, makecol(255, 0, 0)); + rect(rm.m_backbuf, 1, 1, SCREEN_WIDTH-2, SCREEN_HEIGHT-2, makecol(255, 0, 0)); + rect(rm.m_backbuf, 2, 2, SCREEN_WIDTH-3, SCREEN_HEIGHT-3, makecol(255, 0, 0)); + rect(rm.m_backbuf, 3, 3, SCREEN_WIDTH-4, SCREEN_HEIGHT-4, makecol(255, 0, 0)); + set_alpha_blender(); // the game assumes the graphics are left in this mode + + textprintf(rm.m_backbuf, font, 44, 448, makecol(196, 255, 255), "1P START = exit screen test"); + blit(rm.m_backbuf, screen, 0, 0, 0, 0, 640, 480); +} + +void renderColorTest() +{ + textprintf_centre(rm.m_backbuf, font, 320, 50, WHITE, "COLOR TEST"); + + for ( int i = 0; i < 20; i++ ) + { + int p = 255 * i / 20; + rectfill(rm.m_backbuf, i*32, 100, (i+1)*32, 200, makecol(p, p, p)); + } + textprintf_centre(rm.m_backbuf, font, 320, 220, WHITE, "YOU SHOULD SEE 20 DISTINCT SHADES OF GREY"); + + solid_mode(); + for ( int c = 0; c < 512; c++ ) + { + line(rm.m_backbuf, 64+c, 270, 64+c, 290, makecol(c/2, 0, 0)); + line(rm.m_backbuf, 64+c, 290, 64+c, 310, makecol(0, c/2, 0)); + line(rm.m_backbuf, 64+c, 310, 64+c, 330, makecol(0, 0, c/2)); + line(rm.m_backbuf, 64+c, 330, 64+c, 350, makecol(c/2, 0, c/2)); + line(rm.m_backbuf, 64+c, 350, 64+c, 370, makecol(c/2, c/2, 0)); + line(rm.m_backbuf, 64+c, 370, 64+c, 390, makecol(0, c/2, c/2)); + } + line(rm.m_backbuf, 64, 250, 64, 410, WHITE); + line(rm.m_backbuf, 576, 250, 576, 410, WHITE); + textprintf(rm.m_backbuf, font, 582, 276, WHITE, "RED"); + textprintf(rm.m_backbuf, font, 582, 296, WHITE, "GREEN"); + textprintf(rm.m_backbuf, font, 582, 316, WHITE, "BLUE"); + textprintf(rm.m_backbuf, font, 582, 336, WHITE, "PINK"); + textprintf(rm.m_backbuf, font, 582, 356, WHITE, "YELLOW"); + textprintf(rm.m_backbuf, font, 582, 376, WHITE, "CYAN"); + set_alpha_blender(); // the game assumes the graphics are left in this mode + + textprintf(rm.m_backbuf, font, 50, 440, makecol(196, 255, 255), "1P START = exit color test"); +} + +void renderCoinOptions() +{ + textprintf_centre(rm.m_backbuf, font, 320, 50, WHITE, "COIN OPTIONS"); + + textprintf(rm.m_backbuf, font, 50, 100, testMenuSubIndex == 0 ? RED : WHITE, "FREE PLAY"); + textprintf(rm.m_backbuf, font, 50, 130, testMenuSubIndex == 1 ? RED : WHITE, "COINS PER CREDIT"); + textprintf(rm.m_backbuf, font, 50, 160, testMenuSubIndex == 2 ? RED : WHITE, "VERSUS PREMIUM"); + textprintf(rm.m_backbuf, font, 50, 190, testMenuSubIndex == 3 ? RED : WHITE, "DOUBLE PREMIUM"); + textprintf(rm.m_backbuf, font, 50, 310, testMenuSubIndex == 4 ? RED : WHITE, "FACTORY SETTINGS"); + textprintf(rm.m_backbuf, font, 50, 340, testMenuSubIndex == 5 ? RED : WHITE, "SAVE AND EXIT"); + + textprintf(rm.m_backbuf, font, 236, 100, gs.isFreeplay ? RED : GREEN, GET_ON_OFF(gs.isFreeplay)); + textprintf(rm.m_backbuf, font, 236, 130, gs.numCoinsPerCredit == DEFAULT_COINS_PER_CREDIT ? GREEN : RED, "%d", gs.numCoinsPerCredit ); + textprintf(rm.m_backbuf, font, 236, 160, gs.isVersusPremium ? RED : GREEN, GET_ON_OFF(gs.isVersusPremium)); + textprintf(rm.m_backbuf, font, 236, 190, gs.isDoublePremium ? RED : GREEN, GET_ON_OFF(gs.isDoublePremium)); + + textprintf(rm.m_backbuf, font, 50, 400, makecol(196, 255, 255), "PRESS 1P LEFT / RIGHT = select item"); + textprintf(rm.m_backbuf, font, 50, 420, makecol(196, 255, 255), "PRESS 2P LEFT / RIGHT = modify setting"); + textprintf(rm.m_backbuf, font, 50, 440, makecol(196, 255, 255), "PRESS 1P START BUTTON = confirm selection"); +} + +void renderGameOptions() +{ + textprintf_centre(rm.m_backbuf, font, 320, 50, WHITE, "GAME OPTIONS"); + + textprintf(rm.m_backbuf, font, 50, 100, testMenuSubIndex == 0 ? RED : WHITE, "SONGS PER CREDIT"); + textprintf(rm.m_backbuf, font, 50, 130, testMenuSubIndex == 1 ? RED : WHITE, "EVENT MODE"); + textprintf(rm.m_backbuf, font, 50, 310, testMenuSubIndex == 2 ? RED : WHITE, "FACTORY SETTINGS"); + textprintf(rm.m_backbuf, font, 50, 340, testMenuSubIndex == 3 ? RED : WHITE, "SAVE AND EXIT"); + + textprintf(rm.m_backbuf, font, 236, 100, gs.numSongsPerSet == DEFAULT_SONGS_PER_SET ? GREEN : RED, "%d", gs.numSongsPerSet ); + textprintf(rm.m_backbuf, font, 236, 130, GREEN, GET_ON_OFF(gs.isEventMode)); + + textprintf(rm.m_backbuf, font, 50, 400, makecol(196, 255, 255), "PRESS 1P LEFT / RIGHT = select item"); + textprintf(rm.m_backbuf, font, 50, 420, makecol(196, 255, 255), "PRESS 2P LEFT / RIGHT = modify setting"); + textprintf(rm.m_backbuf, font, 50, 440, makecol(196, 255, 255), "PRESS 1P START BUTTON = confirm selection"); +} + +void renderBookkeeping(int tempSelection) +{ + static char days[7][4] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }; + int i = 0; + DAILY_BOOKKEEP grand_total, week_total; + + // first, calculate the totals (used on every page) + for ( i = 0; i < 7; i++ ) + { + DAILY_BOOKKEEP temp = bm.getAllTime(i); + grand_total.uptime += temp.uptime; + grand_total.playtime += temp.playtime; + grand_total.logins += temp.logins; + grand_total.nonLogins += temp.nonLogins; + grand_total.coins += temp.coins; + grand_total.services += temp.services; + grand_total.spGames += temp.spGames; + grand_total.dpGames += temp.dpGames; + grand_total.mpGames += temp.mpGames; + grand_total.vpGames += temp.vpGames; + + temp = bm.getThisWeek(i); + week_total.uptime += temp.uptime; + week_total.playtime += temp.playtime; + week_total.logins += temp.logins; + week_total.nonLogins += temp.nonLogins; + week_total.coins += temp.coins; + week_total.services += temp.services; + week_total.spGames += temp.spGames; + week_total.dpGames += temp.dpGames; + week_total.mpGames += temp.mpGames; + week_total.vpGames += temp.vpGames; + } + + textprintf_centre(rm.m_backbuf, font, 320, 10, WHITE, "VIEW BOOKKEEPING INFORMATION"); + + // now render each page + switch ( testMenuSubIndex ) + { + case 0: + textprintf_centre(rm.m_backbuf, font, 320, 35, GREEN, "LIFETIME STATS"); + + textprintf(rm.m_backbuf, font, 50, 100, WHITE, "TOTAL ACTIVE TIME: %d", grand_total.uptime); + textprintf(rm.m_backbuf, font, 50, 120, WHITE, "TOTAL PLAY TIME : %d", grand_total.playtime); + textprintf(rm.m_backbuf, font, 50, 160, WHITE, "TOTAL LOGINS : %d", grand_total.logins); + textprintf(rm.m_backbuf, font, 50, 180, WHITE, "TOTAL NO LOGIN: %d", grand_total.nonLogins); + textprintf(rm.m_backbuf, font, 50, 220, WHITE, "TOTAL COINS : %d", grand_total.coins); + textprintf(rm.m_backbuf, font, 50, 240, WHITE, "TOTAL SERVICES: %d", grand_total.services); + textprintf(rm.m_backbuf, font, 50, 280, WHITE, "SINGLES GAMES PLAYED: %d", grand_total.spGames); + textprintf(rm.m_backbuf, font, 50, 300, WHITE, "DOUBLES GAMES PLAYED: %d", grand_total.dpGames); + textprintf(rm.m_backbuf, font, 50, 320, WHITE, "VERSUS GAMES PLAYED: %d", grand_total.vpGames); + //textprintf(rm.m_backbuf, font, 50, 340, WHITE, "MISSION GAMES PLAYED: %d", grand_total.mpGames); + break; + case 1: + textprintf_centre(rm.m_backbuf, font, 320, 35, GREEN, "COIN DATA OF LAST 7 DAYS"); + textprintf_centre(rm.m_backbuf, font, 320, 235, GREEN, "LIFETIME COIN DATA PER DAY"); + textprintf(rm.m_backbuf, font, 50, 50, WHITE, " | COINS | SERVC | 1PLAY | DOUBL | 2PLAY | OTHER |"); + textprintf(rm.m_backbuf, font, 50, 250, WHITE, " | COINS | SERVC | 1PLAY | DOUBL | 2PLAY | OTHER |"); + for ( i = 0; i < 7; i++ ) + { + DAILY_BOOKKEEP temp = bm.getThisWeek(i); + textprintf(rm.m_backbuf, font, 50, 70 + 20*i, WHITE, "%s | %5d | %5d | %5d | %5d | %5d | %5d |", + days[i], temp.coins, temp.services, temp.spGames, temp.dpGames, temp.vpGames, temp.mpGames); + temp = bm.getAllTime(i); + textprintf(rm.m_backbuf, font, 50, 270 + 20*i, WHITE, "%s | %5d | %5d | %5d | %5d | %5d | %5d |", + days[i], temp.coins, temp.services, temp.spGames, temp.dpGames, temp.vpGames, temp.mpGames); + } + textprintf(rm.m_backbuf, font, 34, 70 + 140, GREEN, "TOTAL | %5d | %5d | %5d | %5d | %5d | %5d |", + week_total.coins, week_total.services, week_total.spGames, week_total.dpGames, week_total.vpGames, week_total.mpGames); + textprintf(rm.m_backbuf, font, 34, 270 + 140, GREEN, "TOTAL | %5d | %5d | %5d | %5d | %5d | %5d |", + grand_total.coins, grand_total.services, grand_total.spGames, grand_total.dpGames, grand_total.vpGames, grand_total.mpGames); + break; + case 2: + textprintf_centre(rm.m_backbuf, font, 320, 35, GREEN, "ACTIVITY OF LAST 7 DAYS"); + textprintf_centre(rm.m_backbuf, font, 320, 235, GREEN, "LIFETIME ACTIVITY PER DAY"); + textprintf(rm.m_backbuf, font, 50, 50, WHITE, " | PWR TIME | PLAYTIME | LOGIN | NOLOG |"); + textprintf(rm.m_backbuf, font, 50, 250, WHITE, " | PWR TIME | PLAYTIME | LOGIN | NOLOG |"); + for ( i = 0; i < 7; i++ ) + { + DAILY_BOOKKEEP temp = bm.getThisWeek(i); + textprintf(rm.m_backbuf, font, 50, 70 + 20*i, WHITE, "%s | %8d | %8d | %5d | %5d |", + days[i], temp.uptime, temp.playtime, temp.logins, temp.nonLogins); + temp = bm.getAllTime(i); + textprintf(rm.m_backbuf, font, 50, 270 + 20*i, WHITE, "%s | %8d | %8d | %5d | %5d |", + days[i], temp.uptime, temp.playtime, temp.logins, temp.nonLogins); + } + textprintf(rm.m_backbuf, font, 34, 70 + 140, GREEN, "TOTAL | %8d | %8d | %5d | %5d |", + week_total.uptime, week_total.playtime, week_total.logins, week_total.nonLogins); + textprintf(rm.m_backbuf, font, 34, 270 + 140, GREEN, "TOTAL | %8d | %8d | %5d | %5d |", + grand_total.uptime, grand_total.playtime, grand_total.logins, grand_total.nonLogins); + break; + case 3: + textprintf_centre(rm.m_backbuf, font, 320, 75, WHITE, "CLEAR ALL BOOKKEEPING?"); + textprintf(rm.m_backbuf, font, 320, 200, WHITE, "ARE YOU SURE?"); + textprintf(rm.m_backbuf, font, 320, 250, WHITE, "NO / YES"); + if ( tempSelection == 0 ) + { + textprintf(rm.m_backbuf, font, 320, 250, RED, "NO "); + } + else + { + textprintf(rm.m_backbuf, font, 320, 250, RED, " YES"); + } + break; + } + + if ( testMenuSubIndex != 3 ) + { + textprintf(rm.m_backbuf, font, 50, 450, makecol(196, 255, 255), "PRESS 1P LEFT / RIGHT = PREV / NEXT DATA"); + textprintf(rm.m_backbuf, font, 50, 470, makecol(196, 255, 255), "PRESS 1P START BUTTON = EXIT BOOKKEEPING"); + //textprintf(rm.m_backbuf, font, 50, 470, makecol(196, 255, 255), "PRESS 2P START BUTTON = DATA CLEAR"); + } + else if ( testMenuSubIndex == 3 ) + { + textprintf(rm.m_backbuf, font, 50, 430, makecol(196, 255, 255), "PRESS 2P LEFT / RIGHT = CHANGE SELECTION"); + textprintf(rm.m_backbuf, font, 50, 450, makecol(196, 255, 255), "PRESS 1P START BUTTON = CONFIRM SELECTION"); + } +} + +void renderSoundOptions() +{ + textprintf_centre(rm.m_backbuf, font, 320, 50, WHITE, "SOUND OPTIONS"); + + textprintf(rm.m_backbuf, font, 50, 100, testMenuSubIndex == 0 ? RED : WHITE, "SOUND IN ATTRACT"); + textprintf(rm.m_backbuf, font, 50, 130, testMenuSubIndex == 1 ? RED : WHITE, "SCALE CHECK 1"); + textprintf(rm.m_backbuf, font, 50, 160, testMenuSubIndex == 2 ? RED : WHITE, "SCALE CHECK 2"); + textprintf(rm.m_backbuf, font, 50, 310, testMenuSubIndex == 3 ? RED : WHITE, "FACTORY SETTINGS"); + textprintf(rm.m_backbuf, font, 50, 340, testMenuSubIndex == 4 ? RED : WHITE, "SAVE AND EXIT"); + + textprintf(rm.m_backbuf, font, 236, 100, GREEN, "NOT YET IMPLEMENTED"); + + textprintf(rm.m_backbuf, font, 50, 400, makecol(196, 255, 255), "PRESS 1P LEFT / RIGHT = select item"); + textprintf(rm.m_backbuf, font, 50, 420, makecol(196, 255, 255), "PRESS 2P LEFT / RIGHT = modify setting"); + textprintf(rm.m_backbuf, font, 50, 440, makecol(196, 255, 255), "PRESS 1P START BUTTON = confirm selection"); +} + +void renderDataOptions() +{ + textprintf_centre(rm.m_backbuf, font, 320, 50, WHITE, "DATA OPTIONS"); + + textprintf(rm.m_backbuf, font, 50, 100, testMenuSubIndex == 0 ? RED : WHITE, "RESET PLAYERS HITS CHART"); + textprintf(rm.m_backbuf, font, 50, 130, testMenuSubIndex == 1 ? RED : WHITE, "RESET PREVIOUS LOGIN LIST"); + textprintf(rm.m_backbuf, font, 50, 160, testMenuSubIndex == 2 ? RED : WHITE, "DELETE PLAYER"); + textprintf(rm.m_backbuf, font, 50, 190, testMenuSubIndex == 3 ? RED : WHITE, "MODIFY PLAYER PIN"); + textprintf(rm.m_backbuf, font, 50, 340, testMenuSubIndex == 4 ? RED : WHITE, "EXIT"); + + textprintf(rm.m_backbuf, font, 50, 400, makecol(196, 255, 255), "PRESS 1P LEFT / RIGHT = select item"); + //textprintf(rm.m_backbuf, font, 50, 420, makecol(196, 255, 255), "PRESS 2P LEFT / RIGHT = modify setting"); + textprintf(rm.m_backbuf, font, 50, 440, makecol(196, 255, 255), "PRESS 1P START BUTTON = confirm selection"); +} \ No newline at end of file diff --git a/src/source/menuMode.cpp b/src/source/menuMode.cpp new file mode 100644 index 0000000..1226427 --- /dev/null +++ b/src/source/menuMode.cpp @@ -0,0 +1,644 @@ +// menuMode.cpp implements the mode select screen +// source file created by Allen Seitz 2/8/2012 + +#include "common.h" +#include "GameStateManager.h" +#include "inputManager.h" +#include "bookManager.h" +#include "scoreManager.h" +#include "songwheelMode.h" + +extern GameStateManager gs; +extern RenderingManager rm; +extern InputManager im; +extern EffectsManager em; +extern ScoreManager sm; +extern BookManager bm; + +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; + +extern UTIME timeRemaining; +extern void renderTimeRemaining(int xc, int yc); +extern void playTimeLowSFX(UTIME dt); + + +////////////////////////////////////////////////////////////////////////////// +// Assets +////////////////////////////////////////////////////////////////////////////// +BITMAP* m_menuBG = NULL; +BITMAP* m_displayMachine[3]; +BITMAP* m_modeSelect; +BITMAP* m_mainModes; +BITMAP* m_mainPlayers; +BITMAP* m_modRect; +BITMAP* m_modHeadings; +BITMAP* m_mods[4]; + +BITMAP* m_startButton; +BITMAP* m_triangles; + + +////////////////////////////////////////////////////////////////////////////// +// Variables +////////////////////////////////////////////////////////////////////////////// +int currentRow = 0; // 0 = players, 1 = mode, 2-5 = modifiers, 6 = done/wait +int p1row = 0; +int p2row = 0; // they can separate in versus play as long as each is > 1 +int playersChoice = 0; // 0 = singles, 1 = doubles, 2 = versus +int modeChoice = 1; // 0 = course select, 1 = music select, 2 = special +int mods[2][4]; + +UTIME blinkTimer = 0; +UTIME introTimer = 0; +UTIME modeMovingTimer = 0; +int modesY = 118; +int modesDirection = 0; // -1 = up, 1 = down, 0 = stationary + +const int MOD_LIMITS[4] = { 6, 2, 2, 3 }; // how many options are in each row +const int SPEED_MOD_EFFECTS[10] = { 10, 15, 20, 25, 30, 50, 80, 5, 3 }; + +const int MODE_Y_TOP = 118; +const int MODE_Y_LOW = 416; +const int MODE_UNFOLD_TIME = 500; + +// these are used to render the blinking words - they reference x-coordinates in each asset +const int MOD_BREAKS[4][8] = +{ + { 0, 40, 80, 122, 164, 206, 248, 290 }, + { 0, 80, 215, 290 }, + { 0, 51, 145, 290 }, + { 0, 41, 120, 201, 290 } +}; + +////////////////////////////////////////////////////////////////////////////// +// Functions +////////////////////////////////////////////////////////////////////////////// +void renderMenuLoop(); +// precondition: called only once per frame after the logic is complete +// postcondition: rm.m_backbuf contains an image of the current game state + +void renderMods(int x, int y, int which, int selection, int currentRow); +// precondition: which and currentRow are 0-3, selection is within range for this mod +// postcondition: renders a bunch of stuff to the lower area + +void endMenuMode(); +// postcondition: calls for bookkeeping updates and sets up the next game mode + +void firstMenuLoop() +{ + // load assets + if ( m_menuBG == NULL ) + { + m_menuBG = loadImage("DATA/menus/bg_mode.tga"); + m_displayMachine[0] = loadImage("DATA/menus/disp_singles.tga"); + m_displayMachine[1] = loadImage("DATA/menus/disp_doubles.tga"); + m_displayMachine[2] = loadImage("DATA/menus/disp_versus.tga"); + m_modeSelect = loadImage("DATA/menus/main_mode_select.tga"); + m_mainModes = loadImage("DATA/menus/main_modes.tga"); + m_mainPlayers = loadImage("DATA/menus/main_players.tga"); + m_modRect = loadImage("DATA/menus/main_rect.tga"); + m_modHeadings = loadImage("DATA/menus/mods_types.tga"); + m_mods[0] = loadImage("DATA/menus/mods_speed.tga"); + m_mods[1] = loadImage("DATA/menus/mods_reverse.tga"); + m_mods[2] = loadImage("DATA/menus/mods_mirror.tga"); + m_mods[3] = loadImage("DATA/menus/mods_appear.tga"); + } + if ( m_startButton == NULL ) + { + m_startButton = loadImage("DATA/menus/start.tga"); + m_triangles = loadImage("DATA/menus/triangles.tga"); + } + + if ( gs.g_currentGameMode == PLAYERSELECT ) + { + blinkTimer = introTimer = 0; + timeRemaining = 15999; + currentRow = 0; + playersChoice = 0; + + modesY = MODE_Y_TOP; + modesDirection = 0; + + gs.loadSong(BGM_MODE); + gs.playSong(); + + gs.player[0].resetAll(); + gs.player[1].resetAll(); + } + else // MAINMENU + { + playersChoice = 0; + if ( gs.isDoubles ) + { + playersChoice = 1; + } + if ( gs.isVersus ) + { + playersChoice = 2; + } + currentRow = 1; + timeRemaining = 30999; + + modesY = MODE_Y_LOW; + modesDirection = -1; + } + + modeChoice = 1; + p1row = 0; + p2row = 0; + mods[0][0] = mods[0][1] = mods[0][2] = mods[0][3] = 0; + mods[1][0] = mods[1][1] = mods[1][2] = mods[1][3] = 0; + modeMovingTimer = 0; + + im.setCooldownTime(0); +} + +void mainMenuLoop(UTIME dt) +{ + blinkTimer = (blinkTimer + dt) % 250; + introTimer += dt; + if ( !gs.isEventMode ) + { + SUBTRACT_TO_ZERO(timeRemaining, dt); + } + playTimeLowSFX(dt); + + // proces the unfolding animation + if ( modesDirection != 0 ) + { + modeMovingTimer += dt; + + if ( modesDirection > 0 ) + { + modesY = getValueFromRange(MODE_Y_TOP, MODE_Y_LOW, modeMovingTimer*100/MODE_UNFOLD_TIME); + if ( modeMovingTimer >= MODE_UNFOLD_TIME ) + { + modesY = MODE_Y_LOW; + modesDirection = 0; + gs.g_currentGameMode = LOGIN; + gs.g_gameModeTransition = 1; + return; + } + } + else + { + modesY = getValueFromRange(MODE_Y_LOW, MODE_Y_TOP, modeMovingTimer*100/MODE_UNFOLD_TIME); + if ( modeMovingTimer >= MODE_UNFOLD_TIME ) + { + modesY = MODE_Y_TOP; + modesDirection = 0; + } + } + } + + // debug testing + if ( key[KEY_SPACE] ) + { + timeRemaining = 5000; + } + + bool noDouble = !gs.isFreeplay && !gs.isDoublePremium && gs.numCoins < gs.numCoinsPerCredit*2; + bool noVersus = !gs.isFreeplay && !gs.isVersusPremium && gs.numCoins < gs.numCoinsPerCredit*2; + + // check input + if ( currentRow == 0 && modesDirection == 0 ) + { + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN || im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + int originalSelection = playersChoice; + playersChoice = playersChoice == 0 ? 0 : playersChoice - 1; + if ( playersChoice == 1 && noDouble ) + { + playersChoice = 0; // singles + } + + em.playSample(originalSelection == playersChoice ? SFX_MENU_STUCK : SFX_MENU_MOVE); + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN ) + { + int originalSelection = playersChoice; + playersChoice = playersChoice == 2 ? 2 : playersChoice + 1; + if ( playersChoice == 2 && noVersus ) + { + playersChoice = 1; // doubles + } + if ( playersChoice == 1 && noDouble ) + { + playersChoice = noVersus ? 0 : 2; // single or versus + } + + em.playSample(originalSelection == playersChoice ? SFX_MENU_STUCK : SFX_MENU_MOVE); + } + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN ) + { + if ( (playersChoice == 1 && noDouble) || (playersChoice == 2 && noVersus) ) + { + em.playSample(SFX_MENU_STUCK); + playersChoice = 0; // should be imposssible + } + else + { + // set the player type + gs.isDoubles = gs.isSolo = gs.isVersus = false; + if ( playersChoice == 1 ) gs.isDoubles = true; + if ( playersChoice == 2 ) gs.isVersus = true; + + em.playSample(SFX_START_BUTTON); + if ( playersChoice == 1 ) + { + em.announcerQuipChance(71, 33); + } + + modesDirection = 1; // automatically starts the unfolding animation + return; + } + } + } + else if ( currentRow == 1 && modesDirection == 0 ) + { + int originalSelection = modeChoice; + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN || im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + modeChoice = modeChoice == 0 ? 0 : modeChoice - 1; + em.playSample(modeChoice == originalSelection ? SFX_MENU_STUCK : SFX_MENU_MOVE); + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN ) + { + modeChoice = modeChoice == 2 ? 2 : modeChoice + 1; + em.playSample(modeChoice == originalSelection ? SFX_MENU_STUCK : SFX_MENU_MOVE); + } + + if ( modeChoice == 2 ) // HACK: remove mission mode, TODO: implement new mode + { + em.playSample(SFX_DIFF); + modeChoice = 1; + } + + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN ) + { + // now that Mode Select is separate from Player Select (and with Login Mode in between) do not allow reversal back to Player Select + //if ( im.isKeyDown(MENU_LEFT_1P) && im.isKeyDown(MENU_RIGHT_1P) && im.isKeyDown(MENU_START_1P) ) + //{ + // currentRow = 0; // backup a row + // em.playSample(SFX_MENU_SORT); + //} + //else if ( im.isKeyDown(MENU_LEFT_2P) && im.isKeyDown(MENU_RIGHT_2P) && im.isKeyDown(MENU_START_2P) ) + //{ + // currentRow = 0; // backup a row + // em.playSample(SFX_MENU_SORT); + //} + //else + //{ + currentRow = 2; // this variable advances no further. time to do per-player modifiers! + em.playSample(SFX_START_BUTTON); + //} + } + } + else if ( currentRow == 2 ) + { + if ( playersChoice < 2 ) // one player playing alone + { + if ( p1row < 4 ) + { + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN || im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + mods[0][p1row] = mods[0][p1row] == 0 ? 0 : mods[0][p1row] - 1; + em.playSample(SFX_MOD_MOVE); + } + if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN ) + { + mods[0][p1row] = mods[0][p1row] == MOD_LIMITS[p1row] ? MOD_LIMITS[p1row] : mods[0][p1row] + 1; + em.playSample(SFX_MOD_MOVE); + } + } + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN ) + { + if ( (im.isKeyDown(MENU_LEFT_1P) && im.isKeyDown(MENU_RIGHT_1P) && im.isKeyDown(MENU_START_1P)) || + im.isKeyDown(MENU_LEFT_2P) && im.isKeyDown(MENU_RIGHT_2P) && im.isKeyDown(MENU_START_2P) ) + { + if ( p1row == 0 ) + { + currentRow = 1; // back up to the mode select + } + else + { + p1row--; // back up one row + } + em.playSample(SFX_MENU_SORT); + } + else + { + if ( p1row < 4 ) + { + em.playSample(SFX_START_BUTTON); + } + p1row = p1row == 4 ? 4 : p1row + 1; // done modifiers! advance to login + } + } + } + else // versus modifers! each player splits up and chooses mods separate + { + int keys[2][3] = { {MENU_LEFT_1P, MENU_RIGHT_1P, MENU_START_1P}, {MENU_LEFT_2P, MENU_RIGHT_2P, MENU_START_2P} }; + + for ( int i = 0; i < 2; i++ ) + { + int *prow = (i == 0 ? &p1row : &p2row); + + if ( *prow < 4 ) + { + if ( im.getKeyState(keys[i][0]) == JUST_DOWN ) // left // MAJOR ERROR HERE // TODO: remember what it was and fix it + { + mods[i][*prow] = mods[i][*prow] == 0 ? 0 : mods[i][*prow] - 1; + em.playSample(SFX_MOD_MOVE); + } + if ( im.getKeyState(keys[i][1]) == JUST_DOWN ) // right // MAJOR ERROR HERE + { + mods[i][*prow] = mods[i][*prow] == MOD_LIMITS[*prow] ? MOD_LIMITS[*prow] : mods[i][*prow] + 1; + em.playSample(SFX_MOD_MOVE); + } + } + if ( im.getKeyState(keys[i][2]) == JUST_DOWN ) // start + { + if ( im.isKeyDown(keys[i][0]) && im.isKeyDown(keys[i][1]) && im.isKeyDown(keys[i][2]) ) + { + if ( *prow == 0 ) + { + currentRow = 1; // back up to the mode select + } + else + { + *prow = *prow - 1; // back up one row + } + em.playSample(SFX_MENU_SORT); + } + else + { + if ( *prow < 4 ) + { + em.playSample(SFX_START_BUTTON); + } + *prow = *prow == 4 ? 4 : *prow + 1; // done modifiers! wait for other player + } + } + } + } + } + + // ran out of time while choosing? + if ( timeRemaining <= 0 ) + { + if ( currentRow < 2 ) // nevermind, they left the game unattended + { + gs.g_currentGameMode = ATTRACT; + gs.g_gameModeTransition = 1; + } + else // skip the mods - move on to next mode + { + p1row = p2row = 4; + } + } + + // are we done with the main menu? + if ( (playersChoice < 2 && p1row > 3) || (playersChoice == 2 && p1row > 3 && p2row > 3) ) + { + // set mode + gs.currentGameType = modeChoice; + + // set modifiers + for ( int side = 0; side < 2; side++ ) + { + gs.player[side].speedMod = SPEED_MOD_EFFECTS[mods[side][0]]; + if ( mods[side][1] > 0 ) + { + gs.player[side].reverseModifier = 0xFF; + if ( mods[side][1] == 2 ) + { + gs.player[side].reverseModifier = 0x99; // binary 10011001 for the blue columns + } + } + gs.player[side].arrangeModifier = mods[side][2]; + if ( mods[side][3] == 1 ) + { + gs.player[side].hiddenModifier = 0xFF; + } + if ( mods[side][3] == 2 ) + { + gs.player[side].suddenModifier = 0xFF; + } + if ( mods[side][3] == 3 ) + { + gs.player[side].stealthModifier = true; + } + } + + // update bookkeeping, stats, progress to next determined screen + endMenuMode(); + } + + renderMenuLoop(); +} + +void renderMenuLoop() +{ + int sx = 0, i = 0, color = 0; + + blit(m_menuBG, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + draw_trans_sprite(rm.m_backbuf, m_modeSelect, 287, 45); + + // render the sample machine + if ( currentRow < 2 ) + { + draw_trans_sprite(rm.m_backbuf, m_displayMachine[playersChoice], 20, 200); + } + + // render the "body" of the unfolded login area + rectfill(rm.m_backbuf, 0, MODE_Y_TOP, 640, modesY, makeacol(255, 170, 200, modesDirection == -1 ? 200 : 255 )); + + // render the blcak and pink stripes + rectfill(rm.m_backbuf, 0, 83, 640, 83+33, makeacol(0, 0, 0, 255)); + rectfill(rm.m_backbuf, 0, modesY, 640, modesY+44, makeacol(208, 89, 160, 255)); + + // see if whatever should blink, should blink + char shouldBlink = blinkTimer >= 180 ? 1 : 0; + + // render SINGLE DOUBLE VERSUS + for ( i = 0; i < 3; i++ ) + { + if ( currentRow == 0 ) + { + color = i == playersChoice && shouldBlink ? 0 : 1; + } + else + { + color = i == playersChoice ? 1 : 2; + } + + // if there aren't enough credits for doubles or versus, disable those selections + if ( i == 1 && !gs.isFreeplay && !gs.isDoublePremium && gs.numCoins < gs.numCoinsPerCredit*2 ) + { + color = 2; + } + if ( i == 2 && !gs.isFreeplay && !gs.isVersusPremium && gs.numCoins < gs.numCoinsPerCredit*2 ) + { + color = 2; + } + + sx = color * 114; + masked_blit(m_mainPlayers, rm.m_backbuf, sx, i*32, i*114 + (i+1)*74, 84, 114, 32); + } + + // render GAME MODE + if ( modeChoice == 2 ) + { + sx = currentRow != 1 ? 210 : shouldBlink ? 0 : 210; + int extraY = currentRow == 1 ? (blinkTimer/75) : 0; + masked_blit(m_mainModes, rm.m_backbuf, sx, 2*32, 215, (modesY-1) + extraY, 210, 32); + renderArtistString("6 challenge tokens", 222, modesY+25, 200, 32); + } + else + { + char numStagesDesc[] = "3 stages + ext"; + numStagesDesc[0] = gs.numSongsPerSet + '0'; + + sx = currentRow > 1 ? 420 : 210; + if ( modeChoice == 0 ) + { + sx = currentRow == 1 && shouldBlink ? 0 : 210; + } + masked_blit(m_mainModes, rm.m_backbuf, sx, 0*32, 40, modesY-1, 210, 32); + renderArtistString(numStagesDesc, 74, modesY+25, 200, 32); + + sx = currentRow > 1 ? 420 : 210; + if ( modeChoice == 1 ) + { + sx = currentRow == 1 && shouldBlink ? 0 : 210; + } + masked_blit(m_mainModes, rm.m_backbuf, sx, 1*32, 390, modesY-1, 210, 32); + renderArtistString(numStagesDesc, 424, modesY+25, 200, 32); + } + + // render the modifers + if ( currentRow == 2 ) + { + if ( playersChoice < 2 ) // render single player mods + { + renderMods(172, 200, 0, mods[0][0], p1row); + renderMods(172, 260, 1, mods[0][1], p1row); + renderMods(172, 320, 2, mods[0][2], p1row); + renderMods(172, 380, 3, mods[0][3], p1row); + } + else // render one set of mods for each player + { + renderMods(12, 200, 0, mods[0][0], p1row); + renderMods(12, 260, 1, mods[0][1], p1row); + renderMods(12, 320, 2, mods[0][2], p1row); + renderMods(12, 380, 3, mods[0][3], p1row); + renderMods(332, 200, 0, mods[1][0], p2row); + renderMods(332, 260, 1, mods[1][1], p2row); + renderMods(332, 320, 2, mods[1][2], p2row); + renderMods(332, 380, 3, mods[1][3], p2row); + } + } + + // render any potential "wait for other player" during versus mode + if ( playersChoice == 2 ) + { + int xoff = (timeRemaining%2000) < 1000 ? (timeRemaining%2000) / 50 : 20 - ((timeRemaining%2000 - 1000) / 50); + if ( p1row > 3 ) + { + renderArtistString("Wait...", 12+xoff, 410, 180, 32); + } + if ( p2row > 3 ) + { + renderArtistString("Wait...", 332+xoff, 410, 180, 32); + } + } + + renderTimeRemaining(); + + if ( introTimer < 250 ) + { + rectfill(rm.m_backbuf, 0, 0, getValueFromRange(640, 0, introTimer*100/250), 480, makeacol(0,0,0,255)); + rm.dimScreen(getValueFromRange(100, 0, introTimer*100/250)); + } + + rm.flip(); +} + +void renderMods(int x, int y, int which, int selection, int currentRow) +{ + char shouldBlink = blinkTimer >= 180 ? 1 : 0; + + masked_blit(m_modHeadings, rm.m_backbuf, (which == currentRow ? 0 : 0), which*20, x, y-25, 80, 20); + masked_blit(m_modRect, rm.m_backbuf, 0, (which == currentRow ? 25 : 0), x, y, 296, 25); + + for ( int i = 0; i <= MOD_LIMITS[which]; i++ ) + { + int color = currentRow > which ? 2 : 0; + if ( selection == i ) + { + color = which == currentRow && shouldBlink ? 1 : 0; + } + + masked_blit(m_mods[which], rm.m_backbuf, MOD_BREAKS[which][i], color*30, (x+2 + MOD_BREAKS[which][i]), y-3, MOD_BREAKS[which][i+1]-MOD_BREAKS[which][i], 30); + } +} + +void endMenuMode() +{ + if ( gs.currentGameType == MODE_NONSTOP ) + { + gs.g_currentGameMode = NONSTOP; + } + else + { + gs.g_currentGameMode = SONGWHEEL; + em.announcerQuipChance(GUY_SONGWHEEL, 100); + } + gs.g_gameModeTransition = 1; + + // update bookkeeping + bm.logLogin(sm.player[0].isLoggedIn); + if ( gs.isVersus ) + { + bm.logLogin(sm.player[1].isLoggedIn); + bm.logMode(VERSUS_PLAY); + } + else + { + bm.logMode(gs.isDoubles ? DOUBLES_PLAY : SINGLES_PLAY); + } + + // update play counts + if ( sm.player[0].isLoggedIn ) + { + if ( gs.isDoubles ) + { + sm.player[0].numPlaysDP++; + } + else + { + sm.player[0].numPlaysSP++; + } + } + if ( sm.player[1].isLoggedIn ) + { + sm.player[1].numPlaysSP++; + } + + // subtract the credits used + gs.numCoins -= gs.numCoinsPerCredit; + if ( gs.isDoubles && !gs.isDoublePremium ) + { + gs.numCoins -= gs.numCoinsPerCredit; + } + if ( gs.isVersus && !gs.isVersusPremium ) + { + gs.numCoins -= gs.numCoinsPerCredit; + } + if ( gs.numCoins < 0 ) + { + gs.numCoins = 0; // happens in debug mode + } +} diff --git a/src/source/nonstopMode.cpp b/src/source/nonstopMode.cpp new file mode 100644 index 0000000..c52c7c4 --- /dev/null +++ b/src/source/nonstopMode.cpp @@ -0,0 +1,244 @@ +// nonstopMode.cpp implements the old, traditional course selection menu +// source file created by Allen Seitz 8/11/2012 + +#include "common.h" +#include "GameStateManager.h" +#include "inputManager.h" +#include "scoreManager.h" +#include "videoManager.h" + +extern GameStateManager gs; +extern RenderingManager rm; +extern InputManager im; +extern ScoreManager sm; +extern VideoManager vm; +extern EffectsManager em; + +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; +extern SongEntry* songs[]; +extern BITMAP** m_banners[]; + +extern int* songIDs; +extern std::string* songTitles; +extern std::string* songArtists; + +extern UTIME timeRemaining; +extern void renderTimeRemaining(int xc, int yc); +extern void playTimeLowSFX(UTIME dt); + +int currentCourseIndex = 0; +int scrollAnimationTimer = 0; +int bannerAnimationTimer = 0; +char currentlyMovingDirection = 0; // -1 = left, 1 = right, 0 = motionless +int fadeAnimTimer = 0; +int difficulty = 0; // SINGLE_MILD or SINGLE_WILD + +UTIME waggleTimer = 0; // wave the blue sensors to change difficulty +const int WAGGLE_TIME = 2750; // how long a waggle input takes (before it is considered not an accidental input) +const int WAGGLE_STEP = 500; + +BITMAP* m_background = NULL; +BITMAP* m_courseSelect = NULL; +BITMAP* m_tracks = NULL; +BITMAP* m_courseHelp = NULL; +BITMAP* m_orbs[20]; +BITMAP* m_rings; +BITMAP* m_cbanners[8]; + +// taken directly from the original game +const int courseDefinitions[8][5] = +{ + { 121, 124, 123, 103, 111 }, // world groove.....................................indi.....mobo.....bail.....gorg.....afro..... + { 102, 108, 117, 114, 111 }, // from DDR...............ÿ.........................puty.....keep.....butt.....dyna.....afro..... + { 101, 119, 110, 122, 109 }, // dance party............ÿ.........................brok.....itsa.....heav.....horn.....disc..... + { 105, 106, 104, 112, 107 }, // club mix...............ÿ.........................alln.....body.....aint.....mean.....drlo..... + { 124, 110, 114, 111, 125 }, // over 170.........................................mobo.....heav.....dyna.....afro.....punk..... + { 109, 122, 114, 111, 125 }, // challenge..............ÿ.........................disc.....horn.....dyna.....afro.....punk..... + { 115, 120, 113, 118, 116 }, // major songs......................................loco.....toge.....inmy.....lets.....mysh..... + { 101, 109, 103, 110, 111 }, // .......................ÿ.........................brok.....disc.....gorg.....heav.....afro..... +}; + +const int INTRO_ANIM_LENGTH = 750; +const int BANNER_ANIM_LENGTH = 500; +const int SCROLL_ANIM_LENGTH = 250; + +void pickCourse() +{ + gs.g_currentGameMode = GAMEPLAY; + gs.g_gameModeTransition = 1; + gs.currentStage = 0; + gs.killSong(); + + for ( int i = 0; i < gs.numSongsPerSet; i++ ) + { + gs.player[0].stagesPlayed[i] = courseDefinitions[currentCourseIndex][i]; + gs.player[0].stagesLevels[i] = difficulty + (gs.isDoubles ? 10 : 0); + if ( gs.isVersus ) + { + gs.player[1].stagesPlayed[i] = courseDefinitions[currentCourseIndex][i]; + gs.player[1].stagesLevels[i] = difficulty; + } + } +} + +void firstNonstopLoop() +{ + currentCourseIndex = 0; + scrollAnimationTimer = SCROLL_ANIM_LENGTH; + bannerAnimationTimer = BANNER_ANIM_LENGTH; + fadeAnimTimer = INTRO_ANIM_LENGTH; + currentlyMovingDirection = 1; + difficulty = SINGLE_MILD; + waggleTimer = 0; + + if ( m_background == NULL ) + { + m_background = loadImage("DATA/menus/bg_course.png"); + m_courseSelect = loadImage("DATA/menus/course_select.png"); + m_tracks = loadImage("DATA/menus/track.png"); + m_courseHelp = loadImage("DATA/menus/course_help.tga"); + for ( int i = 0; i < 20; i++ ) + { + char filename[] = "DATA/menus/orb00.png"; + filename[14] = (i/10)%10 + '0'; + filename[15] = i%10 + '0'; + m_orbs[i] = loadImage(filename); + } + m_rings = loadImage("DATA/menus/rings.tga"); + for ( int i = 0; i < 8; i++ ) + { + char filename[] = "DATA/menus/banner00.png"; + filename[17] = (i/10)%10 + '0'; + filename[18] = i%10 + '0'; + m_cbanners[i] = loadImage(filename); + } + } + + timeRemaining = 15999; + + em.playSample(SFX_COURSE_APPEAR); + gs.loadSong(BGM_DEMO); + gs.playSong(); +} + +void mainNonstopLoop(UTIME dt) +{ + // update animation timers + SUBTRACT_TO_ZERO(fadeAnimTimer, (int)dt); + SUBTRACT_TO_ZERO(scrollAnimationTimer, (int)dt); + SUBTRACT_TO_ZERO(waggleTimer, (int)dt); + if ( scrollAnimationTimer == 0 ) + { + currentlyMovingDirection = 0; + SUBTRACT_TO_ZERO(bannerAnimationTimer, (int)dt); + } + SUBTRACT_TO_ZERO(timeRemaining, dt); + playTimeLowSFX(dt); + + if ( fadeAnimTimer == 0 ) + { + // pick this course + if ( ((im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN) && currentlyMovingDirection == 0) || timeRemaining == 0 ) + { + pickCourse(); + em.playSample(SFX_FORCEFUL_SELECTION); + em.announcerQuip(GUY_NONSTOP_BEGIN); + } + + // scroll left or right? + if ( (im.isKeyDown(MENU_LEFT_1P) || im.isKeyDown(MENU_LEFT_2P)) && currentlyMovingDirection == 0 ) + { + currentlyMovingDirection = -1; + scrollAnimationTimer = SCROLL_ANIM_LENGTH; + bannerAnimationTimer = BANNER_ANIM_LENGTH; + currentCourseIndex = currentCourseIndex <= 0 ? 6 : currentCourseIndex - 1; + em.playSample(SFX_COURSE_PREVIEW_LOAD); + } + if ( (im.isKeyDown(MENU_RIGHT_1P) || im.isKeyDown(MENU_RIGHT_2P)) && currentlyMovingDirection == 0 ) + { + currentlyMovingDirection = 1; + scrollAnimationTimer = SCROLL_ANIM_LENGTH; + bannerAnimationTimer = BANNER_ANIM_LENGTH; + currentCourseIndex = currentCourseIndex > 5 ? 0 : currentCourseIndex + 1; + em.playSample(SFX_COURSE_PREVIEW_LOAD); + + // special way to select hidden "course 8" + if ( timeRemaining >= 3000 && timeRemaining <= 4250 && currentCourseIndex == 0 ) + { + currentCourseIndex = 7; + } + } + + // waggle the blues for difficulty + // P1 waggle controls + bool hitAnyBlueSensor = im.getKeyState(LL_1P) == JUST_DOWN || im.getKeyState(LR_1P) == JUST_DOWN || im.getKeyState(LL_2P) == JUST_DOWN || im.getKeyState(LR_2P) == JUST_DOWN; + if ( hitAnyBlueSensor && currentlyMovingDirection == 0 ) + { + waggleTimer += WAGGLE_STEP; + if ( waggleTimer > WAGGLE_TIME ) + { + waggleTimer = 0; + em.playSample(SFX_DIFFICULTY_MOVE); + difficulty = difficulty == SINGLE_MILD ? SINGLE_WILD : SINGLE_MILD; + } + else + { + em.playSample(SFX_NAME_CURSOR_WAGGLE); + } + } + } + + // render the background + blit(m_background, rm.m_backbuf, 0, 0, 0, 0, 640, 460); + masked_blit(m_courseSelect, rm.m_backbuf, 0, 0, 250+(fadeAnimTimer/3), 110, 384, 34); + masked_blit(m_tracks, rm.m_backbuf, 0, 0, 215, 240, 72, 24*gs.numSongsPerSet); + if ( currentlyMovingDirection == 0 && fadeAnimTimer == 0 ) + { + for ( int i = 0; i < gs.numSongsPerSet; i++ ) + { + renderBoldString(songTitles[songID_to_listID(courseDefinitions[currentCourseIndex][i])].c_str(), 293, 236+(i*24), 400, false, difficulty%10 + 1); + } + } + + // render the banner + int percent = bannerAnimationTimer*100 / BANNER_ANIM_LENGTH; + masked_stretch_blit(m_cbanners[currentCourseIndex], rm.m_backbuf, 0, 0, 160, 24, 215, 166, getValueFromRange(320,1,percent), getValueFromRange(48,1,percent)); + + // render the orbs + percent = scrollAnimationTimer*100 / SCROLL_ANIM_LENGTH; + if ( scrollAnimationTimer == 0 ) + { + masked_blit(m_orbs[currentCourseIndex], rm.m_backbuf, 0, 0, 45, 153, 72, 72); + } + else + { + if ( currentlyMovingDirection == -1 ) // orbs also move left + { + int prevCourse = currentCourseIndex == 6 ? 0 : currentCourseIndex + 1; + masked_blit(m_orbs[currentCourseIndex], rm.m_backbuf, 0, 0, getValueFromRange(45, 640, percent), 153, 72, 72); + if ( fadeAnimTimer == 0 ) + { + masked_blit(m_orbs[prevCourse], rm.m_backbuf, 0, 0, getValueFromRange(-72, 45, percent), 153, 72, 72); + } + } + else // orbs move right + { + int prevCourse = currentCourseIndex == 0 ? 6 : currentCourseIndex - 1; + masked_blit(m_orbs[currentCourseIndex], rm.m_backbuf, 0, 0, getValueFromRange(45, -72, percent), 153, 72, 72); + if ( fadeAnimTimer == 0 ) + { + masked_blit(m_orbs[prevCourse], rm.m_backbuf, 0, 0, getValueFromRange(640, 45, percent), 153, 72, 72); + } + } + } + + renderTimeRemaining(5, 42); + draw_trans_sprite(rm.m_backbuf, m_courseHelp, 0, 460-64); + + if ( fadeAnimTimer > 0 ) + { + rm.dimScreen(getValueFromRange(0, 100, fadeAnimTimer*100/INTRO_ANIM_LENGTH)); + } + rm.flip(); +} \ No newline at end of file diff --git a/src/source/recordingMode.cpp b/src/source/recordingMode.cpp new file mode 100644 index 0000000..2c45df8 --- /dev/null +++ b/src/source/recordingMode.cpp @@ -0,0 +1,217 @@ +// recordingMode.cpp is a temporary hack designed to quickly allow me to outline charts +// source file created by Allen Seitz 1/5/10 + +#include "common.h" + +#include "gameStateManager.h" +#include "inputManager.h" + +extern GameStateManager gs; +extern InputManager im; +extern RenderingManager rm; + +int previousKey = 6; +int superPreviousKey = 9; + +std::vector timings; +std::vector placements; +std::vector types; // has to be tap, jump, shock, hold start, or NOTE + +// hardcoded for simplicity - used to quantize the input +int bpms[10] = {4901, 19600, 36000, 4901, 19600, 22500, 26000, 4901, 15000 }; +int bpmTimes[10] = { 0, 16280, 84000, 106100, 112000, 131800, 167000, 226400, 999999 }; +int bpmIndex = 0; +UTIME lastBPMChange = 0; +// 84400 = tempo stop for 475 ms + +UTIME calculateQuantizedTime(UTIME ct) +{ + int bpm = bpms[bpmIndex]; + int halfbeat = (6000000 / bpm) / 2; // how many milliseconds are in 1/8 beat + + // calculate the timing of the last half-beat before the current note + UTIME prevBeat = ((ct - lastBPMChange) / halfbeat) * halfbeat + lastBPMChange; + UTIME nextBeat = prevBeat + halfbeat; + + // which is closer to the current time? prevBeat or nextBeat? + if ( ct - prevBeat < nextBeat - ct ) + { + return prevBeat; + } + return nextBeat; +} + +int beginTime; + +void firstRecordingLoop() +{ + timings.clear(); + placements.clear(); + types.clear(); + + gs.player[0].resetAll(); + //gs.loadSong(101); + bpmIndex = 0; +} + +void mainRecordingLoop(UTIME dt) +{ + gs.player[0].timeElapsed += dt; + im.updateKeyStates(dt); + + // render a little something + clear_to_color(rm.m_backbuf, 0); + renderWhiteNumber(gs.player[0].timeElapsed, 100, 100); + renderWhiteString("NOTES: ", 400, 100); + renderWhiteNumber((int)timings.size(), 480, 100); + renderWhiteString("BPM: ", 400, 150); + renderWhiteNumber(bpms[bpmIndex]/100, 450, 150); + renderWhiteString("1/8th = ", 400, 170); + renderWhiteNumber((6000000 / bpms[bpmIndex]) / 2, 490, 170); + rm.flip(); + + // update the current BPM + while ( bpmTimes[bpmIndex+1] < (int)gs.player[0].timeElapsed && bpmTimes[bpmIndex+1] != 999999 ) + { + bpmIndex++; + + timings.push_back(bpmTimes[bpmIndex]); + placements.push_back(bpms[bpmIndex]/100); + types.push_back(BPM_CHANGE); + } + + // check input + for ( int i = 6; i < 10; i++ ) + { + if ( im.getKeyState(i) == JUST_DOWN ) + { + int lastIndex = (int)timings.size() - 1; + + // wait! was the previous note a tap, and was it within the jump window? + if ( lastIndex != -1 && types[lastIndex] == TAP && gs.player[0].timeElapsed - timings[lastIndex] < 50 ) + { + // change that previous tap into a jump! + types[lastIndex] = JUMP; + } + else + { + // decide between SAME, NEXT, RETURN, and XOVER/ACROSS + int pattern = NEXT; + if ( i == previousKey ) + { + pattern = SAME; + } + else if ( i == superPreviousKey ) + { + pattern = RETURN; + } + else if ( (i==6 && previousKey==9) || (i==7 && previousKey==8) || (i==8 && previousKey==7) || (i==9 && previousKey==6) ) + { + pattern = rand()%2 == 0 ? ACROSS : XOVER; // can't tell, but it makes a difference - tweak it manually + } + + // create a tap + timings.push_back(calculateQuantizedTime(gs.player[0].timeElapsed)); + placements.push_back(pattern); + types.push_back(TAP); + } + + // remember where our feet are + superPreviousKey = previousKey; + previousKey = i; + } + } + + while (keypressed() == TRUE) + { + int k = readkey() >> 8; + + if ( k == KEY_END ) + { + // create a shock + timings.push_back(calculateQuantizedTime(gs.player[0].timeElapsed)); + placements.push_back(-1); + types.push_back(SHOCK); + } + if ( k == KEY_SPACE ) + { + // create a ??? event (I use these to note where I want to put tempo changes, etc) + timings.push_back(calculateQuantizedTime(gs.player[0].timeElapsed)); + placements.push_back(-1); + types.push_back(-1); + } + if ( k == KEY_ENTER ) + { + // print everything in a format that I can copy/paste into a hardcoded array -_(>_<)_- + for ( unsigned int i = 0; i < timings.size(); i++ ) + { + if ( i != 0 && timings[i] == timings[i-1] ) + { + continue; + } + + al_trace(" "); + if ( timings[i] >= 100000 ) + { + al_trace(" %d, ", timings[i]); + } + else if ( timings[i] >= 10000 ) + { + al_trace(" %d, ", timings[i]); + } + else + { + al_trace(" %d, ", timings[i]); + } + + if ( placements[i] == SAME ) + { + al_trace("SAME, "); + } + else if ( placements[i] == OVER ) + { + al_trace("OVER, "); + } + else if ( placements[i] == RETURN ) + { + al_trace("RETURN, "); + } + else if ( placements[i] == XOVER ) + { + al_trace("XOVER, "); + } + else if ( placements[i] == NEXT ) + { + al_trace("NEXT, "); + } + else if ( types[i] != BPM_CHANGE ) + { + al_trace("-1, "); + } + + if ( types[i] == TAP ) + { + al_trace("TAP, "); + } + else if ( types[i] == JUMP ) + { + al_trace("JUMP, "); + } + else if ( types[i] == SHOCK ) + { + al_trace("SHOCK, "); + } + else if ( types[i] == BPM_CHANGE ) + { + al_trace("%d, BPM_CHANGE,", placements[i]); + } + else + { + al_trace("WWWWWWWWWW, "); + } + + al_trace("\n"); + } + } + } +} \ No newline at end of file diff --git a/src/source/render_ddr.cpp b/src/source/render_ddr.cpp new file mode 100644 index 0000000..5667dda --- /dev/null +++ b/src/source/render_ddr.cpp @@ -0,0 +1,634 @@ +// render_ddr.cpp holds refactored code for "DDR mode" +// source file created by Allen Seitz 12/26/2011 + +#include "gameStateManager.h" +#include "gameplayRendering.h" +#include "specialEffects.h" + +extern RenderingManager rm; +extern GameStateManager gs; +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; + + +////////////////////////////////////////////////////////////////////////////// +// BITMAPs +////////////////////////////////////////////////////////////////////////////// +extern BITMAP* m_arrowSource[6][4][9]; +extern BITMAP* m_stepZoneSource[6][2]; +extern BITMAP* m_judgements[8][3]; // the second dimension is only used for M/P/G +extern BITMAP* m_combo[5]; +extern BITMAP* m_comboNums; +extern BITMAP* m_flashes[4][2]; // 4 frames x 6 colors, played on top of the step zone for marvellouses and OKs +extern BITMAP* m_flares[6][4][3]; // 6 arrows x 4 animations frames x 3 colors, for when a note is hit + +#define DDR_STEP_ZONE_Y 64 +#define DDR_STEP_ZONE_REV_Y 380 +#define DDR_COMBO_Y 250 + +////////////////////////////////////////////////////////////////////////////// +// Functions +////////////////////////////////////////////////////////////////////////////// +int getStepZonePos_DDR(char player) +{ + // pick a starting x coordinate + if ( gs.isDoubles ) + { + return 64; + } + else if ( gs.isVersus ) + { + return player == 0 ? 32 : 320 + 32; + } + return 192; // one player is always centered +} + +int getColumnOffsetX_DDR(int column) +{ + int x = 0; + + // center the columns in different positions for each game mode + if ( gs.isDoubles ) + { + x = 64 + column*64; // center the 8 arrows + } + else if ( gs.isVersus ) + { + if ( column < 4 ) + { + x = 32 + column*64; // 1P + } + else + { + x = 320 + 32 + (column-4)*64; // 2P + } + } + else + { + x = 192 + column*64; // singles center play + } + + // uh-oh! was a shock arrow hit? + if ( gs.player[0].shockAnimTimer > 0 && (gs.isDoubles || column < 4) ) + { + int percent = gs.player[0].shockAnimTimer * 100 / SHOCK_ANIM_TIME; + + // immediately reverse all columns, then slowly unreverse them + int shockx = 192 - column*64 + 192; + if ( gs.isDoubles ) + { + shockx = 64 - column*64 + 448; + } + if ( gs.isVersus ) + { + shockx = 32 - column*64 + 192; + } + + return WEIGHTED_AVERAGE(shockx, x, percent, 100); + } + if ( gs.player[1].shockAnimTimer > 0 && column >= 4 ) + { + int percent = gs.player[1].shockAnimTimer * 100 / SHOCK_ANIM_TIME; + + // immediately reverse all columns, then slowly unreverse them + int shockx = 320 + 32 - (column-4)*64 + 192; + return WEIGHTED_AVERAGE(shockx, x, percent, 100); + } + + + return x; +} + +void renderStepZone_DDR(int player) +{ + static int columnSource[10] = { 0, 1, 2, 3, 4, 5, 0, 2, 3, 5 }; + int x = getStepZonePos_DDR(player); + int blink = gs.player[player].stepZoneBlinkTimer > 0 ? 1 : 0; // pick the state of the step zone + + for ( int i = 0; i < 10; i++ ) + { + int arrow = columnSource[i]; + if ( (i == 1 || i == 4) && !gs.isSolo ) + { + continue; + } + if ( (i == 0 || i == 2 || i == 3 || i == 5) && !gs.isDoubles && !gs.isSolo ) + { + continue; + } + if ( i >= 6 && gs.isSolo && !gs.isDoubles ) + { + continue; + } + + // render the actual step zone + if ( !gs.player[player].darkModifier && gs.player[player].shockAnimTimer == 0 ) + { + renderStepZonePiece_DDR(m_stepZoneSource[arrow][blink], x, DDR_STEP_ZONE_Y, GET_RESIZE(gs.player[player].stepZoneResizeTimers[i])); + } + + x += 64; + } +} + +void renderFlaresAndFlashes_DDR(int player) +{ + static int columnSource[10] = { 0, 1, 2, 3, 4, 5, 0, 2, 3, 5 }; + int x = getStepZonePos_DDR(player); + + for ( int i = 0; i < 10; i++ ) + { + int arrow = columnSource[i]; + int frame = 3 - (gs.player[player].laneFlareTimers[i] / (HIT_FLASH_DISPLAY_TIME / 4)) % 4; + if ( (i == 1 || i == 4) && !gs.isSolo ) + { + continue; + } + if ( (i == 0 || i == 2 || i == 3 || i == 5) && !gs.isDoubles && !gs.isSolo ) + { + continue; + } + if ( i >= 6 && gs.isSolo && !gs.isDoubles ) + { + continue; + } + + if ( gs.player[player].laneFlareTimers[i] > 0 ) + { + // also draw a bright white flash on the spot for a marvelous + if ( gs.player[player].laneFlareColors[i] == 0 || gs.player[player].laneFlareColors[i] == 3 ) + { + draw_trans_sprite(rm.m_backbuf, m_flashes[frame][0], x-5, DDR_STEP_ZONE_Y-5); + } + + // render a yellow flash for O.K.! + if ( gs.player[player].laneFlareColors[i] == 4 ) + { + draw_trans_sprite(rm.m_backbuf, m_flashes[frame][1], x-5, DDR_STEP_ZONE_Y-5); + } + + // TODO: while holding a note ( == 2 ) + } + + // render the fading arrow outline last + if ( gs.player[player].laneFlareTimers[i] > 0 && gs.player[player].laneFlareColors[i] < 3 ) + { + draw_trans_sprite(rm.m_backbuf, m_flares[arrow][frame][gs.player[player].laneFlareColors[i]], x, DDR_STEP_ZONE_Y); + } + x += 64; + } +} + +void renderStepZonePiece_DDR(BITMAP* src, int x, int y, int scale) +{ + // copy to a temporary space, scale there, then do a transparent blit + clear_to_color(rm.m_temp64, 0x00000000); // argb format for the color + int s = (64 * scale) / 100; + int d = (64 - s) / 2; + stretch_blit(src, rm.m_temp64, 0, 0, 64, 64, d, d, s, s); + draw_trans_sprite(rm.m_backbuf, rm.m_temp64, x, y); +} + +void renderDDRChart(int player) +{ + int n = gs.player[player].currentNote; + int x = getStepZonePos_DDR(player); + int pps = gs.player[player].scrollRate * gs.player[player].speedMod / 10; // pixels per second + + // where to start rendering the chart? + // TODO: implement sudden + //unsigned long startTime = gs.player[player].currentChart[gs.player[player].currentNote].timing; + + // where to stop rendering the chart? + // TODO: implement hidden + //unsigned long endTime = currentChart[currentNote].timing + (CHART_HEIGHT * 1000 / pps); + + // implement tempo stops - calculate the moment that this chart should render + UTIME time = gs.player[player].timeElapsed; + int pausedTime = 0; + if ( gs.player[player].stopLength > 0 ) + { + time = gs.player[player].stopTime; + pausedTime += gs.player[player].timeElapsed + gs.player[player].stopLength - gs.player[player].stopTime; + } + + int y = (gs.player[player].currentChart[n].timing - time) * pps / 1000; + while ( y - (pausedTime * pps / 1000) < SCREEN_HEIGHT ) + { + y = ((gs.player[player].currentChart[n].timing - time - pausedTime) * pps / 1000); + renderDDRNote(player, gs.player[player].currentChart[n], x, y + DDR_STEP_ZONE_Y); + + // implement the correct calculation of the distance between notes due to tempo stops + if ( gs.player[player].currentChart[n].type == SCROLL_STOP ) + { + pausedTime += gs.player[player].currentChart[n].color; + } + + // next item in the list + n++; + if ( n == (int)gs.player[player].currentChart.size() ) + { + break; + } + } + + // render the late notes + y = DDR_STEP_ZONE_Y; + n = gs.player[player].currentNote - 1; + while ( y > -64 && n >= 0 ) + { + if ( gs.player[player].currentChart[n].color != 5 && gs.player[player].currentChart[n].type != SCROLL_STOP ) + { + y = DDR_STEP_ZONE_Y - ((gs.player[player].timeElapsed - gs.player[player].currentChart[n].timing) * pps / 1000); + renderDDRNote(player, gs.player[player].currentChart[n], x, y); + } + --n; + } + + // render the hold notes + int holdIndex = gs.player[player].currentFreeze; + pausedTime = gs.player[player].stopLength > 0 ? gs.player[player].timeElapsed + gs.player[player].stopLength - gs.player[player].stopTime : 0; + while ( holdIndex < (int)gs.player[player].freezeArrows.size() ) + { + int retval = renderDDRHoldNote(player, gs.player[player].freezeArrows[holdIndex], time, pausedTime); + if ( retval == HOLD_PASSED_BY ) + { + //break; + } + else if ( retval == HOLD_TOO_EARLY ) + { + break; + } + holdIndex++; + } +} + +void renderDDRNote(int player, struct ARROW n, int x, int y) +{ + int numColumns = getNumColumns(); + + // implement reverse - the stepzone will take care of itself, this is just the notes + int originalY = y; + if ( gs.player[player].reverseModifier != 0 ) + { + y = DDR_STEP_ZONE_REV_Y - y + 64; // the +64 is to account for the height of the note + } + + switch ( n.type ) + { + case TAP: + renderDDRArrow(player, n.columns[0], n.color, n.judgement, getColumnOffsetX_DDR(n.columns[0]), gs.player[player].isColumnReversed(n.columns[0]) ? y : originalY); + break; + case JUMP: + renderDDRArrow(player, n.columns[0], n.color, n.judgement, getColumnOffsetX_DDR(n.columns[0]), gs.player[player].isColumnReversed(n.columns[0]) ? y : originalY); + renderDDRArrow(player, n.columns[1], n.color, n.judgement, getColumnOffsetX_DDR(n.columns[1]), gs.player[player].isColumnReversed(n.columns[1]) ? y : originalY); + break; + //case HOLD_START: + //case HOLD_END: + // intentionally do nothing + break; + case SHOCK: + if ( gs.isSolo ) + { + for ( int i = 0; i < numColumns; i++ ) + { + renderDDRArrow(player, i, 7, n.judgement, x, y); + } + } + else + { + if ( gs.isDoubles ) + { + renderDDRArrow(player, 0, 7, n.judgement, x, y); + renderDDRArrow(player, 2, 7, n.judgement, x, y); + renderDDRArrow(player, 3, 7, n.judgement, x, y); + renderDDRArrow(player, 5, 7, n.judgement, x, y); + } + renderDDRArrow(player, 6, 7, n.judgement, x, y); + renderDDRArrow(player, 7, 7, n.judgement, x, y); + renderDDRArrow(player, 8, 7, n.judgement, x, y); + renderDDRArrow(player, 9, 7, n.judgement, x, y); + } + + for ( int i = 0; i < 6; i++ ) + { + int width = numColumns * 64; + //int seed = ((timeElapsed/32)%1024); // TODO: revert this change + int seed = ((totalGameTime/32)%1024); + renderLightningBeamHorizontal(x, width, y, y+64, (seed+170*i)%1024, LIGHTNING_END_START); + } + break; + case NEW_SECTION: + break; + case END_SONG: + line(rm.m_backbuf, x, y+0, x+64*numColumns, y+0, END_SECTION_COLOR1); + line(rm.m_backbuf, x, y+1, x+64*numColumns, y+1, END_SECTION_COLOR2); + line(rm.m_backbuf, x, y+2, x+64*numColumns, y+2, END_SECTION_COLOR1); + line(rm.m_backbuf, x, y+3, x+64*numColumns, y+3, COLOR_WHITE); + break; + case BPM_CHANGE: + line(rm.m_backbuf, x, y+0, x+64*numColumns, y+0, BPM_CHANGE_COLOR1); + line(rm.m_backbuf, x, y+1, x+64*numColumns, y+1, BPM_CHANGE_COLOR2); + line(rm.m_backbuf, x, y+2, x+64*numColumns, y+2, BPM_CHANGE_COLOR1); + line(rm.m_backbuf, x, y+3, x+64*numColumns, y+3, COLOR_WHITE); + renderWhiteNumber(n.color, x, y-10); + break; + case SCROLL_STOP: + line(rm.m_backbuf, x, y+0, x+64*numColumns, y+0, SCROLL_STOP_COLOR1); + line(rm.m_backbuf, x, y+1, x+64*numColumns, y+1, SCROLL_STOP_COLOR2); + line(rm.m_backbuf, x, y+2, x+64*numColumns, y+2, SCROLL_STOP_COLOR1); + line(rm.m_backbuf, x, y+3, x+64*numColumns, y+3, COLOR_WHITE); + renderWhiteNumber(n.color, x, y-10); + break; + } +} + +void renderDDRArrow(int player, int column, int color, int judgement, int x, int y) +{ + static int columnSource[10] = { 0, 2, 3, 5, 0, 2, 3, 5, 1, 4 }; + BITMAP* source = m_arrowSource[0][0][0]; + + if ( (judgement >= MARVELLOUS && judgement <= GREAT) || judgement == IGNORED ) + { + return; // these arrows disappear once they reach the top or are hit + } + + // freeze arrows (color 5, or melted = 8) are a little different than other arrows + int frame = 0; + if ( color == 5 || color == 8 ) + { + frame = 0; + source = m_arrowSource[columnSource[column]][frame][color]; + } + // shock arrows (color 7) are mostly like other arrows + else if ( color == 7 ) + { + frame = (gs.player[player].stepZoneBeatTimer / 100) % 4; + source = m_arrowSource[columnSource[column]][frame][7]; + } + else + { + // calculate the length of a quarter beat, then set frame to a number 0-3 + frame = (gs.player[player].stepZoneBeatTimer / 100) % 4; + source = m_arrowSource[columnSource[column]][frame][(color + gs.player[player].colorCycle)%4]; + } + masked_blit(source, rm.m_backbuf, 0, 0, x, y, 64, 64); +} + +char renderDDRHoldNote(int player, struct FREEZE f, UTIME time, long pausedTime) +{ + int pps = gs.player[player].scrollRate * gs.player[player].speedMod / 10; // pixels per second + + // calculate how much time is spent inside tempo stops between the startTime and the endTime + int pauseTotal = pausedTime; + unsigned int n = gs.player[player].currentNote; + while ( n < gs.player[player].currentChart.size() ) + { + if ( gs.player[player].currentChart[n].timing >= f.endTime1 ) + { + break; + } + if ( gs.player[player].currentChart[n].type == SCROLL_STOP ) + { + if ( gs.player[player].currentChart[n].timing < f.startTime ) + { + pausedTime += gs.player[player].currentChart[n].color; + } + pauseTotal += gs.player[player].currentChart[n].color; + } + n++; + } + + // find the top and bottom of this hold note + int topy = DDR_STEP_ZONE_Y + ((f.startTime - time - pausedTime) * pps / 1000); + int bot1 = DDR_STEP_ZONE_Y + ((f.endTime1 - time - pauseTotal) * pps / 1000); + int bot2 = DDR_STEP_ZONE_Y + ((f.endTime2 - time - pauseTotal) * pps / 1000); + if ( f.startTime < time ) + { + topy = DDR_STEP_ZONE_Y - ((time - f.startTime) * pps / 1000); + } + if ( f.endTime1 < time ) + { + bot1 = DDR_STEP_ZONE_Y - ((time - f.endTime1) * pps / 1000); + } + if ( f.endTime2 < time ) + { + bot2 = DDR_STEP_ZONE_Y - ((time - f.endTime2) * pps / 1000); + } + + // check for "don't render me" conditions + if ( bot1 < -64 && (f.endTime2 == -1 || bot2 < -64) ) + { + return HOLD_PASSED_BY; + } + if ( topy > SCREEN_HEIGHT ) + { + return HOLD_TOO_EARLY; + } + if ( f.judgement == OK ) + { + return HOLD_RENDERED; + } + + // render the first hold note + int x = getColumnOffsetX_DDR(f.columns[0]); + int color = HOLD_UNTOUCHED; + if (f.isHeld == 1 && f.meltTime1 == 0) + { + color = HOLD_BRIGHT; + } + if ( f.judgement == NG || (f.isHeld == 1 && f.meltTime1 > 0) ) + { + color = HOLD_MELT; + } + int column = f.columns[0]; + topy = f.isHeld == 1 ? DDR_STEP_ZONE_Y : topy; + renderDDRHoldNoteBody(column, x, topy, bot1, color); + + // render the second hold note + if ( f.columns[1] != -1 ) + { + x = getColumnOffsetX_DDR(f.columns[1]); + color = HOLD_UNTOUCHED; + if (f.isHeld == 1 && f.meltTime2 == 0) + { + color = HOLD_BRIGHT; + } + if ( f.judgement == NG || (f.isHeld == 1 && f.meltTime2 > 0) ) + { + color = HOLD_MELT; + } + column = f.columns[1]; + renderDDRHoldNoteBody(column, x, topy, bot2, color); + } + + return HOLD_RENDERED; +} + +// this function +void renderDDRHoldNoteBody(int column, int x, int topy, int bot, int color ) +{ + static int columnSource[10] = { 0, 2, 3, 5, 0, 2, 3, 5, 1, 4 }; + + int frame = 0; + int source = 6; + int rectcolor = makeacol(arrowColors[5][0], arrowColors[5][1], arrowColors[5][2], 255); + if ( color == HOLD_BRIGHT ) + { + frame = 3; + rectcolor = 0xFFDDFFDD; + } + if ( color == HOLD_MELT ) + { + source = 8; + rectcolor = 0xFF505050; + } + + // down arrows render differently than holds in other columns + if ( column == 2 || column == 7 ) + { + rectfill(rm.m_backbuf, x+1, topy+32, x+62, bot+26, rectcolor); + int y = bot + 16; + + while ( y > topy + 16 ) + { + masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 16, x, y, 64, 48); + y -= 16; + } + + // the top of the hold is where the adjustment is made, if the length isn't % 16 + int fractionalArrowHeight = (y - topy) % 16; + masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 0, x, y, 64, fractionalArrowHeight); + + renderDDRArrow(0, column, source == 8 ? 8 : 5, 0, getColumnOffsetX_DDR(column), topy); + } + else + { + // solo arrows are technically a little narrower than other arrows + if ( column == 1 || column == 4 ) + { + rectfill(rm.m_backbuf, x+9, topy+16, x+55, bot+0, rectcolor); + } + else + { + rectfill(rm.m_backbuf, x+1, topy+32, x+62, bot+31, rectcolor); + } + int y = topy; + + // the top of the hold is where the adjustment is made, if the length isn't % 16 + int fractionalArrowHeight = (bot - y) % 16; + masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 0, x, y, 64, fractionalArrowHeight); + y += fractionalArrowHeight; + + while ( y < bot ) + { + masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 0, x, y, 64, 48); + y += 16; + } + masked_blit(m_arrowSource[columnSource[column]][frame][source], rm.m_backbuf, 0, 0, x, bot, 64, 64); + renderDDRArrow(0, column, source == 8 ? 8 : 5, 0, getColumnOffsetX_DDR(column), topy); + } +} + +void renderDDRJudgement(int judgement, int time, int x, int y) +{ + BITMAP* source = m_judgements[judgement-1][0]; + + if ( judgement >= 1 && judgement <= 8 ) + { + int percent = time * 100 / JUDGEMENT_DISPLAY_TIME; // 0-100, how much time has passed? + + // happy judgements bounce slightly + if ( judgement < GOOD && judgement >= MARVELLOUS ) + { + if ( percent < 5 ) + { + source = m_judgements[judgement-1][1]; + } + else if ( percent < 10 ) + { + source = m_judgements[judgement-1][2]; + } + } + // bads shake from side to side (goods are stationary) + /* + else if ( judgement == BAD ) + { + percent = percent % 25; + if ( percent < 13 ) + { + x -= percent / 2; + } + else + { + x += (percent-12) / 2; + } + } + */ + // misses sink slightly + else if ( judgement == MISS ) + { + y = y + percent/10 - 4; + } + + draw_trans_sprite(rm.m_backbuf, source, x-source->w/2, y-source->h/2); + } +} + +void renderDDRCombo(int combo, int time, int centerX, int color) +{ + int numDigits = 1, frame = 0; + + if ( combo < 4 ) + { + return; + } + if ( combo > 9999 ) + { + combo = 9999; + } + + // this is for the counting-up scaling animation + frame = time >= 100 ? 0 : (time / 25) + 1; + + // how many digits to render? + if ( combo >= 1000 ) + { + numDigits = 4; + } + else if ( combo >= 100 ) + { + numDigits = 3; + } + else if ( combo >= 10 ) + { + numDigits = 2; + } + + // center the split of the word "combo" and the number + int x = centerX; + draw_trans_sprite(rm.m_backbuf, m_combo[color], x, DDR_COMBO_Y-21+35); + + for ( int i = 0, tens = 1; i < numDigits; i++, tens *= 10 ) + { + int num = (combo/tens) % 10; + renderDDRComboNum(num, frame, color, x - (i+1)*32, DDR_COMBO_Y+35); + } +} + +void renderDDRComboNum(int num, int size, int color, int x, int y) +{ + static int heights[] = { 43, 40, 48, 56, 64 }; + + // copy to a temporary space, maybe scale there, then do a transparent blit + clear_to_color(rm.m_temp64, 0x00000000); // argb format for the color + if ( size == 0 ) + { + blit(m_comboNums, rm.m_temp64, num*32, color*43, 0, 0, 32, 43); + } + else + { + stretch_blit(m_comboNums, rm.m_temp64, num*32, color*43, 32, 43, 0, 0, 32, heights[size]); + } + draw_trans_sprite(rm.m_backbuf, rm.m_temp64, x, y-heights[size]); +} \ No newline at end of file diff --git a/src/source/render_dm.cpp b/src/source/render_dm.cpp new file mode 100644 index 0000000..cf13c6d --- /dev/null +++ b/src/source/render_dm.cpp @@ -0,0 +1,306 @@ +// render_dm.cpp holds refactored code for "DM mode" +// source file created by Allen Seitz 12/26/2011 + +#include "gameStateManager.h" +#include "gameplayRendering.h" +#include "specialEffects.h" + +extern RenderingManager rm; +extern GameStateManager gs; +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; + +////////////////////////////////////////////////////////////////////////////// +// BITMAPs +////////////////////////////////////////////////////////////////////////////// +extern BITMAP* m_columnJudgements[8][3]; +extern BITMAP* m_comboNumsDM; +extern BITMAP* m_comboWordDM; + +#define DM_STEP_ZONE_Y 70 + +////////////////////////////////////////////////////////////////////////////// +// functions +////////////////////////////////////////////////////////////////////////////// +int getColumnOffsetX_DM(int column) +{ + int columnWidths[] = {50, 50, 64, 50, 50, 50, 50, 64, 50, 50}; // unlike DDR, they're not all the same width + + // different game modes use different offsets for the columns + int x = 0, type = 0, i = 0; + + if ( gs.isSolo && !gs.isDoubles ) + { + type = 1; + + } + else if ( !gs.isSolo && gs.isDoubles ) + { + type = 0; + } + else if ( gs.isSolo && gs.isDoubles ) + { + type = 2; + } + else // singles play, assume 2P + { + type = 3; + } + + // increment x by 50 or 64, depending on the width of the column + for ( i = 0; i < columnX[type][column]; i++ ) + { + x += columnWidths[i]; + } + + // uh-oh! was a shock arrow hit? + if ( gs.player[0].shockAnimTimer > 0 ) + { + int percent = gs.player[0].shockAnimTimer * 100 / SHOCK_ANIM_TIME; + + // immediately reverse all columns, then slowly unreverse them + static int shockedColumns[10] = { 5, 4, 3, 2, 1, 0, 9, 8, 7, 6 }; + int shockx = 0; + for ( i = 0; i < columnX[type][shockedColumns[column]]; i++ ) + { + shockx += columnWidths[i]; + } + + return WEIGHTED_AVERAGE(shockx, x, percent, 100); + } + + return x; +} + +void renderDMChart(int player) +{ + int n = gs.player[player].currentNote; + int x = getStepZonePos_DDR(player); + int pps = gs.player[player].scrollRate * gs.player[player].speedMod / 10; // pixels per second + + // implement tempo stops - calculate the moment that this chart should render + UTIME time = gs.player[player].timeElapsed; + int pausedTime = 0; + if ( gs.player[player].stopLength > 0 ) + { + time = gs.player[player].stopTime; + pausedTime += gs.player[player].timeElapsed + gs.player[player].stopLength - gs.player[player].stopTime; + } + + int y = (gs.player[player].currentChart[n].timing - time) * pps / 1000; + while ( y - (pausedTime * pps / 1000) < SCREEN_HEIGHT ) + { + y = ((gs.player[player].currentChart[n].timing - time - pausedTime) * pps / 1000); + renderDMNote(player, gs.player[player].currentChart[n], x, y + DM_STEP_ZONE_Y); + + // implement the correct calculation of the distance between notes due to tempo stops + if ( gs.player[player].currentChart[n].type == SCROLL_STOP ) + { + pausedTime += gs.player[player].currentChart[n].color; + } + + // next item in the list + n++; + if ( n == (int)gs.player[player].currentChart.size() ) + { + break; + } + } + + // render the late notes + y = DM_STEP_ZONE_Y; + n = gs.player[player].currentNote - 1; + while ( y > -64 && n >= 0 ) + { + if ( gs.player[player].currentChart[n].color != 5 && gs.player[player].currentChart[n].type != SCROLL_STOP ) + { + y = DM_STEP_ZONE_Y - ((gs.player[player].timeElapsed - gs.player[player].currentChart[n].timing) * pps / 1000); + renderDMNote(player, gs.player[player].currentChart[n], x, y); + } + --n; + } + + // render the hold notes + int holdIndex = gs.player[player].currentFreeze; + pausedTime = gs.player[player].stopLength > 0 ? gs.player[player].timeElapsed + gs.player[player].stopLength - gs.player[player].stopTime : 0; + while ( holdIndex < (int)gs.player[player].freezeArrows.size() ) + { + int retval = renderDMHoldNote(gs.player[player].freezeArrows[holdIndex], time, pausedTime); + if ( retval == HOLD_PASSED_BY ) + { + //break; + } + else if ( retval == HOLD_TOO_EARLY ) + { + break; + } + holdIndex++; + } +} + +void renderDMNote(int player, struct ARROW n, int x, int y) +{ + int stepZoneWidth = 214 + (gs.isDoubles ? 214 : 0) + (gs.isSolo ? 100 : 0); + + switch ( n.type ) + { + case JUMP: + renderDMChip(player, n.columns[0], n.color, n.judgement, x, y); + renderDMChip(player, n.columns[1], n.color, n.judgement, x, y); + break; + case TAP: + renderDMChip(player, n.columns[0], n.color, n.judgement, x, y); + break; + case SHOCK: + for ( int i = 0; i < 4; i++ ) + { + int seed = ((totalGameTime/32)%1024); + renderLightningBeamHorizontal(x, stepZoneWidth, y, y+14, (seed+170*i)%1024, LIGHTNING_END_START); + } + renderDMChip(player, 0, 7, UNSET, x, y); + renderDMChip(player, 0, 7, UNSET, stepZoneWidth-50, y); + break; + case NEW_SECTION: + case END_SONG: + break; + case BPM_CHANGE: + line(rm.m_backbuf, x, y+0, stepZoneWidth, y+0, BPM_CHANGE_COLOR1); + line(rm.m_backbuf, x, y+1, stepZoneWidth, y+1, BPM_CHANGE_COLOR2); + line(rm.m_backbuf, x, y+2, stepZoneWidth, y+2, BPM_CHANGE_COLOR1); + line(rm.m_backbuf, x, y+3, stepZoneWidth, y+3, COLOR_WHITE); + renderWhiteNumber(n.color, x, y-10); + break; + case SCROLL_STOP: + line(rm.m_backbuf, x, y+0, stepZoneWidth, y+0, SCROLL_STOP_COLOR1); + line(rm.m_backbuf, x, y+1, stepZoneWidth, y+1, SCROLL_STOP_COLOR2); + line(rm.m_backbuf, x, y+2, stepZoneWidth, y+2, SCROLL_STOP_COLOR1); + line(rm.m_backbuf, x, y+3, stepZoneWidth, y+3, COLOR_WHITE); + renderWhiteNumber(n.color, x, y-10); + break; + } +} + +void renderDMChip(int player, int column, int color, int judgement, int x, int y) +{ + int drum = column >=6 ? column-6 : column; + //int frame = ((gs.stepZoneBeatTimer / 100) + gs.colorCycle) % 4; + x += getColumnOffsetX_DM(column); + UNUSED(y); + UNUSED(player); + + if ( (judgement >= MARVELLOUS && judgement <= GREAT) || judgement == IGNORED ) + { + return; // these arrows disappear once they reach the top or are hit + } + + // shock arrow! in Drummania! + if ( color == 7 ) + { + //blit(m_notesDM[6], rm.m_backbuf, 0, 8*0, x, y, 50, 8); + } + // render a bass pedal + else if ( drum == 2 ) + { + //blit(m_notesDM[drum], rm.m_backbuf, 51, 8*frame, x, y, 64, 8); + } + // render anything else + else + { + //blit(m_notesDM[drum], rm.m_backbuf, 0, 8*frame, x, y, 50, 8); + } +} + +char renderDMHoldNote(struct FREEZE f, UTIME time, long pausedTime) +{ + UNUSED(f); + UNUSED(time); + UNUSED(pausedTime); + return HOLD_TOO_EARLY; +} + +void renderDMCombo(int combo, int player) +{ + int numDigits = 2; + + if ( combo < 10 ) + { + return; + } + if ( combo > 9999 ) + { + combo = 9999; + } + + // how many digits to render? + if ( combo >= 1000 ) + { + numDigits = 4; + } + else if ( combo >= 100 ) + { + numDigits = 3; + } + + // center the split of the word "combo" and the number + int x = getStepZonePos_DDR(player) + getNumColumns()/2 * 64; + masked_blit(m_comboWordDM, rm.m_backbuf, 0, 0, x, JUDGEMENT_Y + 40 + 30, 72, 30); + + for ( int i = 0, tens = 1; i < numDigits; i++, tens *= 10 ) + { + int num = (combo/tens) % 10; + int y = JUDGEMENT_Y + 40 - (gs.player[player].drummaniaCombo[i]/25); + renderDMComboNum(num, x - (i+1)*36, y); + } +} + +void renderDMComboNum(int num, int x, int y) +{ + masked_blit(m_comboNumsDM, rm.m_backbuf, (num/5)*36, (num%5)*60, x, y, 36, 60); +} + +void renderColumnJudgements(int player) +{ + for ( int i = 0; i < 10; i++ ) + { + if ( gs.player[player].columnJudgement[i] >= MARVELLOUS && gs.player[player].columnJudgement[i] <= NG && gs.player[player].columnJudgeTime[i] < JUDGEMENT_DISPLAY_TIME ) + { + BITMAP* source = m_columnJudgements[gs.player[player].columnJudgement[i]-1][0]; + int percent = gs.player[player].columnJudgeTime[i] * 100 / JUDGEMENT_DISPLAY_TIME; // 0-100, how much time has passed? + + // all DM judgements pop on the screen (like marv/perfect/great) + if ( percent < 5 ) + { + source = m_columnJudgements[gs.player[player].columnJudgement[i]-1][1]; + } + else if ( percent < 10 ) + { + source = m_columnJudgements[gs.player[player].columnJudgement[i]-1][2]; + } + + // Drummania uses staggered columns, but don't stagger O.K.! or N.G. + int y = JUDGEMENT_Y - 48; + if ( gs.player[player].isColumnReversed(i) ) + { + y = REVERSE_JUDGEMENT_Y; + } + if ( i % 2 == 0 && gs.player[player].columnJudgement[i] < OK ) + { + y += 16; + } + + int jx = getColumnOffsetX_DDR(i)-source->w/2; + int colWidth = getColumnOffsetX_DDR(1) - getColumnOffsetX_DDR(0); + if ( gs.player[player].danceManiaxMode ) + { + jx = getColumnOffsetX_DMX(i)-source->w/2; + colWidth = getColumnOffsetX_DMX(1) - getColumnOffsetX_DMX(0) + 4; + } + if ( gs.player[player].drummaniaMode ) + { + jx = getColumnOffsetX_DM(i)-source->w/2; + colWidth = 40; // not true, because of the base pedal, but produces the correct result + } + draw_trans_sprite(rm.m_backbuf, source, jx + colWidth/2, y-source->h/2); + } + } +} \ No newline at end of file diff --git a/src/source/render_dmx.cpp b/src/source/render_dmx.cpp new file mode 100644 index 0000000..14d6639 --- /dev/null +++ b/src/source/render_dmx.cpp @@ -0,0 +1,638 @@ +// render_dmx.cpp holds refactored code for "DMX mode" +// source file created by Allen Seitz 12/26/2011 + +#include "gameStateManager.h" +#include "inputManager.h" +#include "gameplayRendering.h" +#include "specialEffects.h" + +extern RenderingManager rm; +extern GameStateManager gs; +extern InputManager im; // only for rendering columns 'held' down +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; + +////////////////////////////////////////////////////////////////////////////// +// constants +////////////////////////////////////////////////////////////////////////////// +#define DMX_STEP_ZONE_Y 70 +#define DMX_STEP_ZONE_REV_Y 380 +#define DMX_COMBO_Y 250 + +////////////////////////////////////////////////////////////////////////////// +// BITMAPs +////////////////////////////////////////////////////////////////////////////// +extern BITMAP* m_dmxHeader; +extern BITMAP* m_dmxFooter; +extern BITMAP* m_stepZoneSourceDMX[2]; +extern BITMAP* m_notesDMX[3]; +extern BITMAP* m_dmxCombos[8]; +extern BITMAP* m_dmxFevers[8]; +extern BITMAP* m_comboDMX; +extern BITMAP* m_leftLifeGaugeCover; +extern BITMAP* m_rightLifeGaugeCover; +extern BITMAP* m_leftSideHalo[3][2]; +extern BITMAP* m_rightSideHalo[3][2]; +extern BITMAP* m_judgementsDMX; +extern BITMAP* m_dmxFireworks[2][6][16]; + +////////////////////////////////////////////////////////////////////////////// +// functions +////////////////////////////////////////////////////////////////////////////// +int getColumnOffsetX_DMX(int column) +{ + if ( gs.isVersus ) + { + if ( column < 4 ) + { + return 96 + 32*column; + } + else + { + return 414 + 32*(column-4); // versus play columns 0-7 + } + } + else if ( gs.isDoubles ) + { + return 192 + 32*column + (column/4*2)-2; // that last term in the forumla creates the thick 'gap' in the middle + } + else // center play + { + int swapcol = column; + switch (column) + { + case 2: swapcol = 3; break; + case 3: swapcol = 2; break; + case 4: swapcol = 5; break; + case 5: swapcol = 4; break; + } + return 192 + 32*swapcol; // render one player in the center + } + + //return 256 + 32*column; // render one player in the center +} + +int getLeftmostColumnX_DMX(int player) +{ + if ( gs.isDoubles ) + { + return getColumnOffsetX_DMX(0); + } + else if ( gs.isVersus ) + { + return getColumnOffsetX_DMX(player*4); + } + return getColumnOffsetX_DMX(3); +} + +int getColorOfColumn(int column) +{ + if ( column == 0 || column == 3 || column == 4 || column == 7 ) + { + return 1; + } + return 0; +} + +void renderDMXChart(int player) +{ + int n = gs.player[player].currentNote; + + int pps = gs.player[player].scrollRate * gs.player[player].speedMod / 10; // pixels per second + + // where to start rendering the chart? + // TODO: implement sudden + //unsigned long startTime = gs.currentChart[gs.currentNote].timing; + + // where to stop rendering the chart? + // TODO: implement hidden + //unsigned long endTime = currentChart[currentNote].timing + (CHART_HEIGHT * 1000 / pps); + + // implement tempo stops - calculate the moment that this chart should render + UTIME time = gs.player[player].timeElapsed; + int pausedTime = 0; + if ( gs.player[player].stopLength > 0 ) + { + time = gs.player[player].stopTime; + pausedTime += gs.player[player].timeElapsed + gs.player[player].stopLength - gs.player[player].stopTime; + } + + // render the hold notes + int holdIndex = gs.player[player].currentFreeze; + int holdPausedTime = gs.player[player].stopLength > 0 ? gs.player[player].timeElapsed + gs.player[player].stopLength - gs.player[player].stopTime : 0; + + //int countHoldsProcessed = 0; + while ( holdIndex < (int)gs.player[player].freezeArrows.size() ) + { + //countHoldsProcessed++; + int retval = renderDMXHoldNote(player, gs.player[player].freezeArrows[holdIndex], time, holdPausedTime); + if ( retval == HOLD_PASSED_BY ) + { + //break; + } + else if ( retval == HOLD_TOO_EARLY ) + { + break; + } + holdIndex++; + } + //al_trace("Num holds processed: %d\r\n", countHoldsProcessed); + + int y = (int(gs.player[player].currentChart[n].timing) - int(time)) * pps / 1000; + while ( y - (pausedTime * pps / 1000) < SCREEN_HEIGHT ) + { + y = (int(gs.player[player].currentChart[n].timing) - int(time) - pausedTime) * pps / 1000; + renderDMXNote(player, gs.player[player].currentChart[n], y + DMX_STEP_ZONE_Y); + + // implement the correct calculation of the distance between notes due to tempo stops + if ( gs.player[player].currentChart[n].type == SCROLL_STOP ) + { + pausedTime += gs.player[player].currentChart[n].color; + } + + // next item in the list + n++; + if ( n == (int)gs.player[player].currentChart.size() ) + { + break; + } + } + + // render the late notes - TODO: fix the optimization here to work for reverse + y = DMX_STEP_ZONE_Y; + n = gs.player[player].currentNote - 1; + while ( y > -64 && n >= 0 ) + { + if ( gs.player[player].currentChart[n].color != 5 && gs.player[player].currentChart[n].type != SCROLL_STOP ) + { + y = DMX_STEP_ZONE_Y - ((gs.player[player].timeElapsed - gs.player[player].currentChart[n].timing) * pps / 1000); + renderDMXNote(player, gs.player[player].currentChart[n], y); + } + --n; + } +} + +void renderDMXNote(int player, struct ARROW n, int y) +{ + int x = getColumnOffsetX_DMX(n.columns[0]); + int leftX = getColumnOffsetX_DMX(0); + int rightX = getColumnOffsetX_DMX(3) + 34-1; + if ( gs.isDoubles || (gs.isVersus && player == 1) ) + { + rightX = getColumnOffsetX_DMX(7) + 34-1; + if ( (gs.isVersus && player == 1) ) + { + leftX = getColumnOffsetX_DMX(4); + } + } + if ( !gs.isDoubles && !gs.isVersus ) + { + leftX = getColumnOffsetX_DMX(1); + rightX = getColumnOffsetX_DMX(6) +34-1; + } + + // implement reverse - the stepzone will take care of itself, this is just the notes + int originalY = y; + if ( gs.player[player].reverseModifier != 0 ) + { + y = DMX_STEP_ZONE_REV_Y - y; + } + + switch ( n.type ) + { + case TAP: + renderDMXArrow(player, n.columns[0], 0, n.judgement, x-2, gs.player[player].isColumnReversed(n.columns[0]) ? y+40 : originalY); + //renderWhiteNumber(n.timing, getColumnOffsetX_DMX(0)-64, gs.player[player].isColumnReversed(n.columns[0]) ? y+40 : originalY); + break; + case JUMP: + for ( int i = 0; i < 4; i++ ) + { + if ( n.columns[i] != -1 ) + { + x = getColumnOffsetX_DMX(n.columns[i]); + renderDMXArrow(player, n.columns[i], 0, n.judgement, x-2, gs.player[player].isColumnReversed(n.columns[i]) ? y+40 : originalY); + } + //renderWhiteNumber(n.timing, getColumnOffsetX_DMX(0)-64, gs.player[player].isColumnReversed(n.columns[0]) ? y+40 : originalY); + } + break; + //case HOLD_START: + //case HOLD_END: + //break; // intentionally do nothing + case SHOCK: + break; // intentionally do nothing + case NEW_SECTION: + break; + case END_SONG: + //renderEndSongMarker(leftX, rightX, (gs.player[player].reverseModifier != 0 ? y+74 : y)); + break; + case BPM_CHANGE: + renderBPMMarker(leftX, rightX, (gs.player[player].reverseModifier != 0 ? y+74 : y), n.color); + break; + case SCROLL_STOP: + renderTempoStopMarker(leftX, rightX, (gs.player[player].reverseModifier != 0 ? y+74 : y), n.color); + break; + } +} + +void renderDMXArrow(int player, int column, int color, int judgement, int x, int y) +{ + if ( (judgement >= MARVELLOUS && judgement <= GREAT) || judgement == IGNORED ) + { + return; // these arrows disappear once they reach the top or are hit + } + if ( judgement == GOOD && (gs.player[player].danceManiaxMode || gs.player[player].drummaniaMode) ) + { + return; // in these modes, goods also count as hit + } + + // calculate the length of a quarter beat, then set frame to a number 0-7 + int frame = getValueFromRange(0, 7, (gs.player[player].stepZoneBeatTimer*100 / gs.player[player].stepZoneTimePerBeat)); + if ( gs.player[player].stepZoneBlinkTimer > 0 ) + { + frame += 8; + } + int colColor = getColorOfColumn(column); + if ( color == 2 ) + { + colColor = 2; // make it gold, otherwise ignore this parameter + } + + masked_blit(m_notesDMX[colColor], rm.m_backbuf, 0, frame*40, x, y, 40, 40); + set_alpha_blender(); // the game assumes the graphics are left in this mode +} + +char renderDMXHoldNote(int player, struct FREEZE f, UTIME time, long pausedTime) +{ + int pps = gs.player[player].scrollRate * gs.player[player].speedMod / 10; // pixels per second + + // calculate how much time is spent inside tempo stops between the startTime and the endTime + long pauseTotal = pausedTime; + unsigned int n = gs.player[player].currentNote; + while ( n < gs.player[player].currentChart.size() ) + { + if ( gs.player[player].currentChart[n].timing >= f.endTime1 ) + { + break; + } + if ( gs.player[player].currentChart[n].type == SCROLL_STOP ) + { + if ( gs.player[player].currentChart[n].timing < f.startTime ) + { + pausedTime += gs.player[player].currentChart[n].color; + } + pauseTotal += gs.player[player].currentChart[n].color; + } + n++; + } + + // calculate how many pixels away from the stepzone the hold note is + int headPosition = (int(f.startTime) - int(time) - pausedTime) * pps / 1000; + int tailPosition1 = (int(f.endTime1) - int(time) - pauseTotal) * pps / 1000; + int tailPosition2 = (int(f.endTime2) - int(time) - pauseTotal) * pps / 1000; + if ( f.isHeld == 1 ) + { + headPosition = 0; // it's being held + } + + // check for "don't render me" conditions + if ( tailPosition1 < -40 && (f.endTime2 == -1 || tailPosition2 < -40) ) + { + return HOLD_PASSED_BY; + } + if ( headPosition > SCREEN_HEIGHT ) + { + return HOLD_TOO_EARLY; + } + if ( f.judgement == OK ) + { + return HOLD_RENDERED; + } + + // render the hold note - TODO: why is this loop using meltTime1 and tailPosition1 on both loops? (note - holds are always separate anyways) + for ( int d = 0; d < 2; d++ ) + { + if ( f.columns[d] != -1 ) + { + // calculate the column and color of the hold note + int column = f.columns[0]; + int x = getColumnOffsetX_DMX(column); + int color = HOLD_UNTOUCHED; + if (f.isHeld == 1 && f.meltTime1 == 0) + { + color = HOLD_DMX_BRIGHT; + } + if ( f.judgement == NG || (f.isHeld == 1 && f.meltTime1 > 0) ) + { + color = HOLD_DMX_MELT; + } + + // calculate the exact y position, taking into account reverse + int topy = DMX_STEP_ZONE_Y + headPosition + 17; + int bottomy = DMX_STEP_ZONE_Y + tailPosition1 + 17; + if ( gs.player[player].isColumnReversed(column) ) + { + topy = DMX_STEP_ZONE_REV_Y - headPosition - 17; + bottomy = DMX_STEP_ZONE_REV_Y - tailPosition1 - 17; + } + + //renderWhiteNumber(f.startTime, getColumnOffsetX_DMX(3)+43, topy); + renderDMXHoldNoteBody(column, x, topy, bottomy, color, player); + } + } + + return HOLD_RENDERED; +} + +void renderDMXHoldNoteBody(int column, int x, int topy, int bot, int color, int player) +{ + static int lineColors[8][34] = { + { 0,0,0,0,0,0, 0,0, 1,1, 2,2, 3,3,3,3,3,3,3,3,3,3, 2,2, 1,1, 0,0, 0,0,0,0,0,0 }, // visually, the charge note + { 0,0,0,0,0,0, 0,0, 1,1, 2,2, 3,3,3,3,3,3,3,3,3,3, 2,2, 1,1, 0,0, 0,0,0,0,0,0 }, + + { 0,0,0,0,0,0, 0,0, 0,1, 1,2, 2,3,3,3,3,3,3,3,3,2, 2,1, 1,0, 0,0, 0,0,0,0,0,0 }, + { 0,0,0,0,0,0, 0,0, 0,1, 1,2, 2,3,3,3,3,3,3,3,3,2, 2,1, 1,0, 0,0, 0,0,0,0,0,0 }, + + { 0,0,0,0,0,0, 0,0, 0,2, 2,3, 3,3,3,2,2,2,2,3,3,3, 3,2, 2,0, 0,0, 0,0,0,0,0,0 }, + { 0,0,0,0,0,0, 0,0, 0,2, 2,3, 3,3,3,2,2,2,2,3,3,3, 3,2, 2,0, 0,0, 0,0,0,0,0,0 }, + + { 0,0,0,0,0,0, 0,0, 0,1, 1,2, 2,3,3,3,3,3,3,3,3,2, 2,1, 1,0, 0,0, 0,0,0,0,0,0 }, + { 0,0,0,0,0,0, 0,0, 0,1, 1,2, 2,3,3,3,3,3,3,3,3,2, 2,1, 1,0, 0,0, 0,0,0,0,0,0 }, + }; + + if ( color == HOLD_UNTOUCHED ) + { + color = column == 1 || column == 2 || column == 5 || column == 6 ? HOLD_DMX_RED : HOLD_DMX_BLUE; + } + + for ( int chargex = 6; chargex < 34-6; chargex++ ) + { + int frame = 0; + if ( color == HOLD_DMX_BRIGHT ) + { + frame = getValueFromRange(0, 7, (gs.player[player].stepZoneBeatTimer*100 / gs.player[player].stepZoneTimePerBeat)); + } + int col = makeacol( dmxHoldColors[color][lineColors[frame][chargex]][0], dmxHoldColors[color][lineColors[frame][chargex]][1], dmxHoldColors[color][lineColors[frame][chargex]][2], 255 ); + + int endcapMod = 0; + if ( lineColors[frame][chargex] == 0 ) + { + endcapMod = 3; // this color is a little shorter, to create a subtle 'end cap' on the hold note + } + + line(rm.m_backbuf, x+chargex, topy, x+chargex, bot-endcapMod, col); + + // for debugging + //line(rm.m_backbuf, 0, topy, 640, topy, makeacol(255,255,255,255)); + //for ( int i = 0; i < 10; i++ ) + //{ + // line(rm.m_backbuf, 0, bot+i, 640, bot+i, makeacol(255,128,128,255)); + //} + } +} + +void renderUnderFrameDMX() +{ + if ( !gs.isVersus ) + { + int blink = gs.player[0].stepZoneBlinkTimer > 0 ? 0 : 1; + int lv = blink ? gs.player[0].stagesLevels[gs.currentStage] % DOUBLE_MILD : 3; + masked_blit(m_leftSideHalo[lv][0], rm.m_backbuf, 0, 0, 0, 12, 320, 64); // for singles and doubles combine the two into one big halo + masked_blit(m_rightSideHalo[lv][0], rm.m_backbuf, 0, 0, 320, 12, 320, 64); + + masked_blit(m_leftSideHalo[lv][1], rm.m_backbuf, 0, 0, 0, 402, 320, 48); // the bottom halo + masked_blit(m_rightSideHalo[lv][1], rm.m_backbuf, 0, 0, 320, 402, 320, 48); + } + else + { + int blink = gs.player[0].stepZoneBlinkTimer > 0 ? 0 : 1; + int lvl = blink ? gs.player[0].stagesLevels[gs.currentStage] % DOUBLE_MILD : 3; + blink = gs.player[1].stepZoneBlinkTimer > 0 ? 0 : 1; // probably useless + int lvr = blink ? gs.player[1].stagesLevels[gs.currentStage] % DOUBLE_MILD : 3; + masked_blit(m_leftSideHalo[lvl][0], rm.m_backbuf, 0, 0, 0, 12, 320, 64); + masked_blit(m_rightSideHalo[lvr][0], rm.m_backbuf, 0, 0, 320, 12, 320, 64); + + masked_blit(m_leftSideHalo[lvl][1], rm.m_backbuf, 0, 0, 0, 402, 320, 48); + masked_blit(m_rightSideHalo[lvr][1], rm.m_backbuf, 0, 0, 320, 402, 320, 48); + } +} + +void renderOverFrameDMX() +{ + if ( !gs.isVersus ) + { + masked_blit(m_rightLifeGaugeCover, rm.m_backbuf, 0, 0, 404, 14, 176, 32); + } + masked_blit(m_dmxHeader, rm.m_backbuf, 0, 0, 0, 0, 640, 64); + masked_blit(m_dmxFooter, rm.m_backbuf, 0, 0, 0, 416, 640, 64); +} + +void renderStepZoneDMX(int player) +{ + int startColumn = player == 0 ? 0 : 4; + if ( !gs.isDoubles && !gs.isVersus ) + { + startColumn = 2; // center play + } + int endColumn = gs.isDoubles ? 8 : startColumn+4; + + for ( int i = startColumn; i < endColumn; i++ ) + { + int x = getColumnOffsetX_DMX(i); + int blink = gs.player[player].stepZoneBlinkTimer > 0 ? 0 : 1; // pick the state of the step zone + int hitcolor = 0x8A000000; + int outlineColor = 0xFFB4B4B4; + if ( blink == 1 ) + { + static int colors[3] = { makeacol(41, 239, 115, 255), makeacol(239, 101, 190, 255), makeacol(76, 0, 190, 255) }; + int stageColor = gs.player[player].stagesLevels[gs.currentStage] % 10; + outlineColor = colors[stageColor]; + } + + if ( gs.player[player].laneFlareColors[i] == 2 ) + { + blink = 2; // currently holding a hold note in this column + } + + int color = getColorOfColumn(i); + if ( im.isKeyDown(i) ) + { + hitcolor = color == 0 ? 0xBF600000 : 0xBF000060; + } + renderStepLaneDMX(x, hitcolor, outlineColor); + masked_blit(m_stepZoneSourceDMX[color], rm.m_backbuf, blink*34, 0, x, (gs.player[player].isColumnReversed(i) ? DMX_STEP_ZONE_REV_Y-34 : DMX_STEP_ZONE_Y), 34, 38); + } +} + +void renderStepLaneDMX(int x, int bgColor, int outlineColor) +{ + line(rm.m_backbuf, x, 40, x, 434, outlineColor); + line(rm.m_backbuf, x+1, 40, x+1, 434, outlineColor); + line(rm.m_backbuf, x+32, 40, x+32, 434, outlineColor); + line(rm.m_backbuf, x+33, 40, x+33, 434, outlineColor); + + //drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); + rectfill(rm.m_backbuf, x+2, 26, x+31, 444, bgColor); + //set_alpha_blender(); // the game assumes the graphics are left in this mode +} + +void renderDMXCombo(int combo, int time, int centerX, int color) +{ + int numDigits = 1, frame = 0, flash = 0; + + if ( combo < 5 ) // DMX starts at 5 + { + return; + } + if ( combo > 9999 ) + { + combo = 9999; + } + + // this is for the white flash animation + flash = time >= 100 ? 5 : time/25; + //color = (combo/100) % 5; + frame = flash < 5 ? 4 + flash : color; + + // how many digits to render? Note: the official game renders combos starting at 004 + if ( combo >= 1000 ) + { + numDigits = 4; + } + else if ( combo >= 100 ) + { + numDigits = 3; + } + else if ( combo >= 10 ) + { + numDigits = 2; + } + + // center the word "combo" above the number + if ( time >= JUDGEMENT_DISPLAY_TIME ) + { + masked_blit(m_comboDMX, rm.m_backbuf, 0, 0, centerX-48, DMX_COMBO_Y-26, 96, 24); + } + + // combo "FEVER" is when combo >= 1000 and it has been some time since the last judgement + if ( combo >= 1000 && time > 1000 ) + { + masked_blit(m_dmxFevers[frame], rm.m_backbuf, 0, 0, centerX-92, DMX_COMBO_Y, 184, 54); + } + else + { + int x = centerX + (64*numDigits)/2 - 64; + for ( int i = 0, tens = 1; i < numDigits; i++, tens *= 10 ) + { + int num = (combo/tens) % 10; + ASSERT(num < 10); + int sourcex = (num / 2) * 64; + int sourcey = (num % 2) * 64; + ASSERT(sourcex < 320 && sourcey < 128); + masked_blit(m_dmxCombos[frame], rm.m_backbuf, sourcex, sourcey, x - (i*64), DMX_COMBO_Y, 64, 64); + } + } +} + +void renderDMXJudgement(int judgement, int time, int x, int y) +{ + int sy = 0; + + switch(judgement) + { + case MARVELLOUS: + case PERFECT: + sy = 0; break; + case GREAT: + sy = 32; break; + case GOOD: + sy = 64; break; + //case BAD: + case MISS: + sy = 96; break; + default: + sy = 128; break; + } + + if ( judgement >= 1 && judgement <= 8 ) + { + int percent = time * 100 / JUDGEMENT_DISPLAY_TIME; // 0-100, how much time has passed? + + // happy judgements bounce slightly + if ( judgement < GOOD && judgement >= MARVELLOUS ) + { + if ( percent < 50 ) + { + y = y - percent/10 - 4; + } + else + { + percent -= 50; + y = y - 9 + percent/10; + } + } + // misses sink slightly + else if ( judgement == MISS ) + { + y = y + percent/10 - 4; + } + + masked_blit(m_judgementsDMX, rm.m_backbuf, 0, sy, x-64, y, 128, 32); + } +} + +void renderDMXFlaresAndFlashes(int player) +{ + int numColumns = gs.isDoubles || gs.isVersus ? 8 : 8; + + for ( int i = 0; i < numColumns; i++ ) + { + int frame = 15 - ((gs.player[player].laneFlareTimers[i] / (HIT_FLASH_DISPLAY_TIME / 16)) % 16); + int x = getColumnOffsetX_DMX(i); + + if ( gs.player[player].laneFlareTimers[i] > 0 ) + { + int bigSmall = gs.player[player].displayCombo >= 100 ? 1 : 0; + int color = (gs.player[player].displayCombo/100) % 5; + + // for a 'marvelous' render a flashing firework + if ( gs.player[player].laneFlareColors[i] == 0 || gs.player[player].laneFlareColors[i] == 3 ) + { + //color = ((gs.player[player].laneFlareTimers[i] / 20) % 3) + 2; + } + + // render an offcolor firework explosion for an O.K.! + if ( gs.player[player].laneFlareColors[i] == 4 ) + { + bigSmall = 1; + color = (color+1) % 5; // frame % 5; + } + + // while holding a hold note, do something entirely different than a firework + if ( gs.player[player].laneFlareColors[i] != 2 ) + { + set_add_blender(0,0,0,256); + draw_trans_sprite(rm.m_backbuf, m_dmxFireworks[bigSmall][color][frame], x-46, (gs.player[player].isColumnReversed(i) ? DMX_STEP_ZONE_REV_Y-34 : DMX_STEP_ZONE_Y)-46); + set_alpha_blender(); // the game assumes the graphics are left in this mode + } + } + } +} + +void renderBatteryLivesDMX(int player) +{ + int xpos = getLeftmostColumnX_DMX(player) - 20; + int ypos = DMX_STEP_ZONE_Y + 10; + int direction = 1; + if ( gs.player[player].isColumnReversed(0) ) + { + ypos = DMX_STEP_ZONE_REV_Y - 28; + direction = -1; + } + + for ( int i = 0; i < gs.player[player].lifebarLives; i++ ) + { + int frame = getValueFromRange(0, 7, (gs.player[player].stepZoneBeatTimer*100 / gs.player[player].stepZoneTimePerBeat)); + masked_stretch_blit(m_notesDMX[2], rm.m_backbuf, 0, frame*40, 40, 40, xpos, ypos, 20, 20); + ypos += 20*direction; + } +} \ No newline at end of file diff --git a/src/source/resultsMode.cpp b/src/source/resultsMode.cpp new file mode 100644 index 0000000..9d01c3e --- /dev/null +++ b/src/source/resultsMode.cpp @@ -0,0 +1,298 @@ +// resultsMode.cpp implements the main results loop for Dance Maniax +// source file created by Allen Seitz 2/29/2012 + +#include "common.h" + +#include "gameStateManager.h" +#include "inputManager.h" +#include "scoreManager.h" +#include "songwheelMode.h" + +extern RenderingManager rm; +extern GameStateManager gs; +extern ScoreManager sm; +extern InputManager im; +extern EffectsManager em; +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; + +extern UTIME timeRemaining; +extern void playTimeLowSFX(UTIME dt); + +////////////////////////////////////////////////////////////////////////////// +// Graphics +////////////////////////////////////////////////////////////////////////////// +BITMAP* m_resultsBG = NULL; +BITMAP* m_resultTop = NULL; +BITMAP* m_resultBottom = NULL; +BITMAP* m_clearStatus = NULL; +BITMAP* m_resultSub = NULL; +BITMAP* m_pcStar = NULL; +extern BITMAP** m_banners; + + +////////////////////////////////////////////////////////////////////////////// +// Variables +////////////////////////////////////////////////////////////////////////////// +int resultFadeTimer = 0; +int secondAnimTimer = 0; +bool doneIntroAnim = false; +int currentPlayer = 0; // will be 1 if showing results for 2P +int scrollX = 64; +int originalX = 64; +int targetScrollX = -1; +UTIME scrollTweenTime = 0; +int stageLimit = 3; + +#define INTRO_ANIM_LENGTH 1000 + + +////////////////////////////////////////////////////////////////////////////// +// Functions +////////////////////////////////////////////////////////////////////////////// +void renderResult(int which, int x); +// precondition: which is a stage number +// postcondition: renders graphics to the backbuf + +void firstResultsLoop() +{ + // load assets + if ( m_resultsBG == NULL ) + { + m_resultsBG = loadImage("DATA/results/results.tga"); + m_resultTop = loadImage("DATA/results/result_high.tga"); + m_resultBottom = loadImage("DATA/results/result_low.tga"); + m_clearStatus = loadImage("DATA/results/clear_status.tga"); + m_resultSub = loadImage("DATA/results/result_sub.tga"); + m_pcStar = loadImage("DATA/results/pc_star.tga"); + } + + resultFadeTimer = secondAnimTimer = 0; + doneIntroAnim = false; + currentPlayer = 0; + scrollX = originalX = 740; // offscreen, gotta scroll in + targetScrollX = 64; + scrollTweenTime = 0; + blit(rm.m_backbuf, rm.m_backbuf1, 0, 0, 0, 0, 640, 480); // prepare for the animation + blit(rm.m_backbuf, rm.m_backbuf2, 0, 0, 0, 0, 640, 480); + + // calculate how many stages were actually played + for ( int i = 0; i < 7; i++ ) + { + if ( sm.player[currentPlayer].currentSet[i].songID < 100 ) + { + break; + } + stageLimit = i-1; + } + + em.playSample(SFX_RESULTS_APPEAR); + timeRemaining = 20000; + + im.setCooldownTime(0); +} + +void mainResultsLoop(UTIME dt) +{ + resultFadeTimer += dt; + secondAnimTimer = (secondAnimTimer + dt) % 750; + if ( !gs.isEventMode ) + { + SUBTRACT_TO_ZERO(timeRemaining, dt); + } + playTimeLowSFX(dt); + + // intro animation? + if ( resultFadeTimer >= INTRO_ANIM_LENGTH && !doneIntroAnim ) + { + resultFadeTimer = 0; + doneIntroAnim = true; + if ( gs.currentSong != BGM_RESULT ) + { + gs.loadSong(BGM_RESULT); + gs.playSong(); + } + + // the announcer has a few words for you + int averageScore = 0; + int numStages = 0; + for ( int i = 0; i < 7; i++ ) + { + if ( sm.player[currentPlayer].currentSet[i].songID >= 100 ) + { + averageScore += sm.player[currentPlayer].currentSet[i].getScore(); + numStages++; + } + } + if ( averageScore > 0 && numStages > 0 ) + { + averageScore /= numStages; + } + + if ( averageScore >= 950000 ) + { + em.announcerQuip(GUY_RESULT_S); + } + else if ( averageScore >= 800000 ) + { + em.announcerQuip(GUY_RESULT_B); + } + else if ( averageScore >= 700000 ) + { + em.announcerQuip(GUY_RESULT_C); + } + else if ( averageScore > 0 ) + { + em.announcerQuip(GUY_RESULT_D); + } + } + if ( !doneIntroAnim && resultFadeTimer < (INTRO_ANIM_LENGTH/2) ) + { + rm.renderWipeAnim(getValueFromRange(0, 14, resultFadeTimer*100/(INTRO_ANIM_LENGTH/2))); + rm.flip(); + return; + } + + blit(m_resultsBG, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + rectfill(rm.m_backbuf, 0, 460, 640, 480, 0); + + // render the two words 'result' which fade in and out + if ( resultFadeTimer > 2000 ) + { + resultFadeTimer -= 2000; + } + int topAlpha = getValueFromRange(0, 255, resultFadeTimer * 100 / 1000); + if ( resultFadeTimer > 1000 ) + { + topAlpha = getValueFromRange(255, 0, (resultFadeTimer-1000) * 100 / 1000); + } + int bottomAlpha = 255 - topAlpha; + + set_trans_blender(0,0,0,topAlpha); + draw_trans_sprite(rm.m_backbuf, m_resultTop, 216, 2); + set_trans_blender(0,0,0,bottomAlpha); + draw_trans_sprite(rm.m_backbuf, m_resultBottom, 0, 402); + set_alpha_blender(); // the game assumes the graphics are left in this mode + + renderNameString(sm.player[currentPlayer].displayName, 107, 40, 0); + + // render the song results + scrollX = getValueFromRange(targetScrollX, originalX, scrollTweenTime*100/400 ); // quickly slide the results in from the right + SUBTRACT_TO_ZERO(scrollTweenTime, dt); + for ( int i = 0; i < 7; i++ ) + { + renderResult(i, scrollX + (192*i)); + } + + // render the rest of the intro animation + if ( !doneIntroAnim && resultFadeTimer >= (INTRO_ANIM_LENGTH/2) ) + { + int fadeTime = resultFadeTimer-(INTRO_ANIM_LENGTH/2); + rm.dimScreen(getValueFromRange(100, 0, fadeTime*100/(INTRO_ANIM_LENGTH/2))); + } + + // all done rendering + if ( doneIntroAnim ) + { + renderTimeRemaining(5, 36); + } + rm.flip(); + + // check for input + if ( (im.getKeyState(MENU_LEFT_1P) == HELD_DOWN || im.getKeyState(MENU_LEFT_2P) == HELD_DOWN) && scrollTweenTime == 0 && scrollX < 64 ) + { + scrollTweenTime = 400; + targetScrollX += 192; + originalX = scrollX; + em.playSample(SFX_SONGWHEEL_MOVE); + } + if ( (im.getKeyState(MENU_RIGHT_1P) == HELD_DOWN || im.getKeyState(MENU_RIGHT_2P) == HELD_DOWN) && scrollTweenTime == 0 && scrollX > (stageLimit-2)*(-192) ) + { + scrollTweenTime = 400; + targetScrollX -= 192; + originalX = scrollX; + em.playSample(SFX_SONGWHEEL_MOVE); + } + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN || timeRemaining <= 0 ) + { + if ( gs.isVersus && currentPlayer == 0 ) + { + firstResultsLoop(); // reboot the mode, lol + currentPlayer = 1; + } + else + { + gs.g_currentGameMode = GAMEOVER; + gs.g_gameModeTransition = 1; + } + } +} + +void renderResult(int which, int x) +{ + static int colors[3] = { makeacol(41, 239, 115, 255), makeacol(247, 41, 173, 255), makeacol(76, 0, 190, 255) }; + + if ( sm.player[currentPlayer].currentSet[which].songID < 100 ) + { + //renderWhiteString("STAGE", x + 20, 100); + //renderWhiteNumber(which, x, 100); + return; // it's fine to call this function on every stage. It just won't do anything for the non-stages. + } + + // song title + //renderBoldString(songTitles[songID_to_listID(sm.player[currentPlayer].currentSet[which].songID)], x-32, 72, 192, false); + //renderWhiteString(songTitles[songID_to_listID(sm.player[currentPlayer].currentSet[which].songID)], x-32, 72); + + // status + int frame = getValueFromRange(0, 10, secondAnimTimer * 100 / 750); + int statusy = 73; // 357 + switch( sm.player[currentPlayer].currentSet[which].status ) + { + case STATUS_PERFECT: + case STATUS_FULLCOMBO: + masked_blit(m_clearStatus, rm.m_backbuf, 0, frame*32, x-32, statusy, 192, 32); + break; + case STATUS_FAILED: + masked_blit(m_clearStatus, rm.m_backbuf, 0, 352, x-32, statusy, 192, 32); + break; + case STATUS_CLEARED: + masked_blit(m_clearStatus, rm.m_backbuf, 0, 384, x-32, statusy, 192, 32); + break; + default: + break; + } + + // draw a box around the banner to indicate difficulty + stretch_blit(m_banners[songID_to_listID(sm.player[currentPlayer].currentSet[which].songID)], rm.m_backbuf, 0, 0, 256, 256, x, 100, 128, 128); + int level = sm.player[currentPlayer].currentSet[which].chartID % 10; + rect(rm.m_backbuf, x, 100, x+128, 228, colors[level]); + rect(rm.m_backbuf, x+1, 101, x+127, 227, colors[level]); + + // counts + masked_blit(m_resultSub, rm.m_backbuf, 0, 0, x-32, 230, 192, 32); + renderScoreNumber(sm.player[currentPlayer].currentSet[which].perfects, x-32+108, 230-4, 3); + if ( sm.player[currentPlayer].currentSet[which].getScore() == 1000000 ) + { + int star = getValueFromRange(0, 11, secondAnimTimer * 100 / 750); + masked_blit(m_pcStar, rm.m_backbuf, (star/4)*64, (star%4)*64, x+32, 280, 64, 64); + } + else + { + masked_blit(m_resultSub, rm.m_backbuf, 0, 32, x-32, 260, 192, 32); + renderScoreNumber(sm.player[currentPlayer].currentSet[which].greats, x-32+108, 230+26, 3); + + if ( sm.player[currentPlayer].currentSet[which].goods > 0 || sm.player[currentPlayer].currentSet[which].misses > 0 ) + { + masked_blit(m_resultSub, rm.m_backbuf, 0, 64, x-32, 290, 192, 32); + renderScoreNumber(sm.player[currentPlayer].currentSet[which].goods, x-32+108, 230+56, 3); + } + if ( sm.player[currentPlayer].currentSet[which].misses > 0 ) + { + masked_blit(m_resultSub, rm.m_backbuf, 0, 96, x-32, 320, 192, 32); + renderScoreNumber(sm.player[currentPlayer].currentSet[which].misses, x-32+108, 230+90, 3); + } + } + + // score + renderScoreNumber(sm.player[currentPlayer].currentSet[which].getScore(), x-32+6, 357, 7); +} diff --git a/src/source/songwheelMode.cpp b/src/source/songwheelMode.cpp new file mode 100644 index 0000000..8ebdcc1 --- /dev/null +++ b/src/source/songwheelMode.cpp @@ -0,0 +1,1087 @@ +// songwheelMode.cpp implements the old "2nd Mix" style songwheel +// source file created by Allen Seitz 7/18/2009 + +#include "common.h" +#include "GameStateManager.h" +#include "inputManager.h" +#include "ScoreManager.h" +#include "songwheelMode.h" + +extern GameStateManager gs; +extern RenderingManager rm; +extern InputManager im; +extern ScoreManager sm; +extern EffectsManager em; + +extern SongEntry* songs; +SongEntry* songlist = NULL; + +extern std::string* songTitles; +extern std::string* songArtists; + +extern unsigned long int frameCounter; +extern unsigned long int totalGameTime; +extern volatile UTIME last_utime; +extern bool allsongsDebug; + +////////////////////////////////////////////////////////////////////////////// +// Constants +////////////////////////////////////////////////////////////////////////////// +#define WHEEL_STEP_TIME 300 + +#define NUM_BANNERS 12 +int shadowQuads[NUM_BANNERS][8] = +{ + { 138,58, 195,45, 171,68, 112,81 }, // top + { 80,107, 120,91, 97,141, 57,152 }, + { 133,96, 216,91, 207,148, 120,150 }, + { 45,174, 61,167, 55,227, 39,228 }, + { 72,173, 137,167, 135,237, 69,237 }, + { 163,178, 259,178, 259,250, 163,250 }, // current + { 46,250, 84,252, 100,314, 62,305 }, + { 111,269, 198,271, 206,333, 124,330 }, + { 233,280, 323,277, 316,334, 231,340 }, + { 85,332, 140,344, 166,382, 115,369 }, + { 180,354, 267,354, 265,387, 187,388 }, + { 307,352, 361,339, 342,369, 287,386 }, +}; + +// these can be calculated by firstSongwheelLoop() +int bannerQuads[NUM_BANNERS][8] = +{ + { 129,51, 186,38, 162,61, 103,74 }, // top + { 70,99, 110,83, 87,133, 47,144 }, // 1 + { 126,87, 209,82, 200,139, 113,141 }, // 2 + { 35,174, 51,167, 45,227, 29,228 }, // 3 + { 65,167, 130,161, 128,231, 62,231 }, // 4 + { 160,171, 256,171, 256,243, 160,243 }, // current + { 35,243, 73,245, 89,307, 51,298 }, // 6 + { 101,261, 188,263, 196,325, 114,322 }, // 7 + { 226,272, 316,269, 309,326, 224,332 }, // 8 + { 79,338, 134,350, 160,388, 109,375 }, // 9 + { 181,361, 268,361, 266,394, 188,395 }, // 10 + { 313,358, 367,345, 348,375, 293,392 } // 11 +}; + +// when rotating right, where does each banner go? +int targetQuadsCCW[NUM_BANNERS][8] = +{ + { 126,87, 209,82, 200,139, 113,141 }, // 2 + { 65,167, 130,161, 128,231, 62,231 }, // 4 + { 160,171, 256,171, 256,243, 160,243 }, // current + { 35,243, 73,245, 89,307, 51,298 }, // 6 + { 101,261, 188,263, 196,325, 114,322 }, // 7 + { 226,272, 316,269, 309,326, 224,332 }, // 8 + { 79,338, 134,350, 160,388, 109,375 }, // 9 + { 181,361, 268,361, 266,394, 188,395 }, // 10 + { 313,358, 367,345, 348,375, 293,392 }, // 11 + + // the bottom three fall off + { 109,375, 109,375, 160,388, 160,388 }, // below 9 + { 188,395, 188,395, 266,394, 266,394 }, // below 10 + { 293,392, 293,392, 348,375, 348,375 } // below 11 +}; + +int targetQuadsCW[NUM_BANNERS][8] = +{ + { 129,51, 129,51, 186,38, 186,38 }, // spins up and away (old top) + { 70,99, 70,99, 110,83, 110,83 }, // spins up and away (old 1) + { 129,51, 186,38, 162,61, 103,74 }, // top + { 35,174, 35,174, 51,167, 51,167 }, // spins up and away (old 3) + { 70,99, 110,83, 87,133, 47,144 }, // 1 + { 126,87, 209,82, 200,139, 113,141 }, // 2 + { 35,174, 51,167, 45,227, 29,228 }, // 3 + { 65,167, 130,161, 128,231, 62,231 }, // 4 + { 160,171, 256,171, 256,243, 160,243 }, // current + { 35,243, 73,245, 89,307, 51,298 }, // 6 + { 101,261, 188,263, 196,325, 114,322 }, // 7 + { 226,272, 316,269, 309,326, 224,332 }, // 8 +}; + +#define INTRO_ANIM_LENGTH 2000 +#define INTRO_ANIM_STEP_TIME 500 +#define TITLE_ANIM_LENGTH 1000 + +////////////////////////////////////////////////////////////////////////////// +// Variables +////////////////////////////////////////////////////////////////////////////// +bool isSphereMoving = false; +bool isMovementClockwise = false; +int rotateAnimTime = 0; +int currentQuads[NUM_BANNERS][8]; // where the banners currently are +int targetQuads[NUM_BANNERS][8]; // where each banner wants to be +int songwheelIndex = 0; +int maxSongwheelIndex = 0; +UTIME timeRemaining = 60000; +int introAnimTimer = 0; +int introAnimSteps = 5; + +int titleAnimTimer = 0; +int displayBPM = 150; // oscillates between min and max +int displayBPMTimer = 0; +char displayBPMState = 0; + +SAMPLE* currentPreview = NULL; +UTIME previewTimeStarted = 0; +UTIME previewTimeRemaining = 0; +int previewSongID = 0; + +bool isInSubmenu = false; +char currentSubmenu = 0; // only used for one player +char separateSubmenu[2] = {0,0}; // only used for versus mode +bool submenuDone[2] = {0,0}; // only used for versus mode +bool skippingSubmenu = false; + +bool isRandomSelect = false; // set to true when random select begins + + +////////////////////////////////////////////////////////////////////////////// +// Assets +////////////////////////////////////////////////////////////////////////////// +BITMAP* m_songBG = NULL; +BITMAP* m_titleArea; +BITMAP* m_stars[2][2]; +BITMAP* m_lockedIcon; +extern BITMAP* m_time; +extern BITMAP* m_timeDigits[2]; +BITMAP* m_menu[3]; +BITMAP* m_musicSelect; +BITMAP* m_miniStatus; +BITMAP* m_new; +BITMAP* m_versions; + +extern BITMAP** m_banners; +V3D* pp[4]; // allocate once, use repeatedly for renderBanner() + + +////////////////////////////////////////////////////////////////////////////// +// Functions +////////////////////////////////////////////////////////////////////////////// +void playTimeLowSFX(UTIME dt); +// +// + +void updatePreview(UTIME dt); +// +// + +void loadPreview(int songid); +// precondition: songid is [100..999] +// postcondition: changes currentPreview, should only be called from updatePreview() + +bool isSongAvailable(int index) +{ + bool earnedIt = true; + + if ( songs[index].unlockFlag != UNLOCK_METHOD_NONE ) + { + earnedIt = false; + + if ( gs.isDoubles ) // if any of the 3 charts are unlocked, then it goes on the songwheel + { + for ( int i = 3; i < 6; i++ ) + { + earnedIt = earnedIt || sm.player[0].allTime[index][i].unlockStatus > 0; + } + } + else + { + for ( int i = SINGLE_MILD; i <= SINGLE_ANOTHER; i++ ) // if either player has any of the three charts, then it goes on the songwheel + { + earnedIt = earnedIt || sm.player[0].allTime[index][i].unlockStatus > 0 || sm.player[1].allTime[index][i].unlockStatus > 0; + } + } + } + + if ( (gs.isDoubles && songs[index].mildDouble == 0 && songs[index].wildDouble == 0) || (!gs.isDoubles && songs[index].mildSingle == 0 && songs[index].mildSingle == 0) ) + { + return false; + } + + return songs[index].version != 0 && (earnedIt || allsongsDebug); +} + +void killPreviewClip() +{ + stop_sample(currentPreview); +} + +void firstSongwheelLoop() +{ + // load assets + if ( m_songBG == NULL ) + { + m_songBG = loadImage("DATA/songwheel/songwheel_background.tga"); + m_titleArea = loadImage("DATA/songwheel/title_area.tga"); + + m_stars[0][0] = loadImage("DATA/songwheel/green_star.tga"); + m_stars[0][1] = loadImage("DATA/songwheel/blank_green_star.tga"); + m_stars[1][0] = loadImage("DATA/songwheel/red_star.tga"); + m_stars[1][1] = loadImage("DATA/songwheel/blank_red_star.tga"); + m_lockedIcon = loadImage("DATA/songwheel/locked_icon.tga"); + + m_menu[0] = loadImage("DATA/songwheel/menu_mild.tga"); + m_menu[1] = loadImage("DATA/songwheel/menu_wild.tga"); + m_menu[2] = loadImage("DATA/songwheel/menu_cancel.tga"); + m_musicSelect = loadImage("DATA/songwheel/music_select.tga"); + m_miniStatus = loadImage("DATA/songwheel/mini_status.tga"); + m_new = loadImage("DATA/songwheel/new.tga"); + m_versions = loadImage("DATA/songwheel/versions.tga"); + } + + // reset state + isSphereMoving = false; + rotateAnimTime = 0; + timeRemaining = 60999; + titleAnimTimer = 0; + isInSubmenu = false; + separateSubmenu[0] = separateSubmenu[1] = currentSubmenu = 0; + introAnimTimer = INTRO_ANIM_LENGTH; + introAnimSteps = 3; + isRandomSelect = false; + + // figure out how many songs are visible on the songwheel + maxSongwheelIndex = 0; + for ( int i = 0; i < NUM_SONGS; i++ ) + { + if ( isSongAvailable(i) ) + { + maxSongwheelIndex++; + } + } + + // put only the songs which should be on t1he songwheel, on the songwheel + if ( songlist != NULL ) + { + delete songlist; + } + songlist = new SongEntry[maxSongwheelIndex]; + int nextIndex = 0; + int futureStartIndex = maxSongwheelIndex; // would start on "Broken my Heart" (or whatever is first) if it doesn't find "Wuv U" (301) + for ( int i = 0; i < NUM_SONGS; i++ ) + { + if ( isSongAvailable(i) ) + { + songlist[nextIndex] = songs[i]; + + // certain charts may be locked + if ( songs[i].unlockFlag != UNLOCK_METHOD_NONE && !allsongsDebug ) + { + if ( sm.player[0].allTime[i][3].unlockStatus == 0 ) + { + songlist[nextIndex].mildDouble = 0; + } + if ( sm.player[0].allTime[i][4].unlockStatus == 0 ) + { + songlist[nextIndex].wildDouble = 0; + } + if ( sm.player[0].allTime[i][SINGLE_MILD].unlockStatus == 0 && sm.player[1].allTime[i][SINGLE_MILD].unlockStatus == 0 ) + { + songlist[nextIndex].mildSingle = 0; + } + if ( sm.player[0].allTime[i][SINGLE_WILD].unlockStatus == 0 && sm.player[1].allTime[i][SINGLE_WILD].unlockStatus == 0 ) + { + songlist[nextIndex].wildSingle = 0; + } + } + + if ( songlist[nextIndex].version == 5 && futureStartIndex == maxSongwheelIndex ) + { + futureStartIndex = nextIndex; // start at the first custom song + } + + nextIndex++; + } + } + ASSERT(nextIndex == maxSongwheelIndex); + + // this is for the intro anim + songwheelIndex = futureStartIndex-3; + isMovementClockwise = true; + prepareForSongwheelRotation(); // must do this or call postSongwheelRotation() + + for (int c = 0; c < 4; c++) + { + pp[c] = new V3D(); + } + + /* dynamically calculate the banner quads based on their upper-left corner (easier for me) + for ( int i = 0; i < NUM_BANNERS; i++ ) + { + int xdiff = bannerQuads[i][0] - shadowQuads[i][0]; + int ydiff = bannerQuads[i][1] - shadowQuads[i][1]; + + for ( int j = 2; j < 8; j+=2 ) + { + bannerQuads[i][j] = shadowQuads[i][j] + xdiff; + bannerQuads[i][j+1] = shadowQuads[i][j+1] + ydiff; + } + al_trace("{ %d,%d %d,%d %d,%d %d,%d },\n", bannerQuads[i][0], bannerQuads[i][1], bannerQuads[i][2], bannerQuads[i][3], bannerQuads[i][4], bannerQuads[i][5], bannerQuads[i][6], bannerQuads[i][7]); + } + //*/ + + currentPreview = NULL; + previewTimeStarted = last_utime; + previewTimeRemaining = 0; + previewSongID = 0; + + gs.player[0].resetStages(); + gs.player[1].resetStages(); + gs.currentStage = 0; + gs.killSong(); + em.playSample(SFX_SONGWHEEL_APPEAR); + + im.setCooldownTime(0); +} + +void mainSongwheelLoop(UTIME dt) +{ + if ( introAnimTimer > 0 ) + { + introAnimTimer -= dt; + if ( isSphereMoving ) + { + updateSongwheelRotation(dt); + + if ( !isSphereMoving ) + { + introAnimSteps--; + if ( introAnimSteps > 0 ) + { + prepareForSongwheelRotation(); + } + } + } + renderIntroAnim( (INTRO_ANIM_LENGTH-introAnimTimer) * 100 / INTRO_ANIM_LENGTH ); + return; + } + + if ( isSphereMoving ) + { + updateSongwheelRotation(dt); + titleAnimTimer = 0; + + // holding the button down means continous motion - not a stop (and flicker) on each banner + if ( !isSphereMoving && !isRandomSelect ) + { + if ( (im.isKeyDown(MENU_LEFT_1P) || im.isKeyDown(MENU_LEFT_2P)) && !(im.isKeyDown(MENU_RIGHT_1P) || im.isKeyDown(MENU_RIGHT_2P)) ) + { + isMovementClockwise = false; + prepareForSongwheelRotation(); + em.playSample(SFX_SONGWHEEL_MOVE); + } + else if ( (im.isKeyDown(MENU_RIGHT_1P) || im.isKeyDown(MENU_RIGHT_2P)) && !(im.isKeyDown(MENU_LEFT_1P) || im.isKeyDown(MENU_LEFT_2P)) ) + { + isMovementClockwise = true; + prepareForSongwheelRotation(); + em.playSample(SFX_SONGWHEEL_MOVE); + } + } + } + else if ( isInSubmenu ) + { + isRandomSelect = false; + + // arrow keys work differently per player + if ( gs.isVersus ) + { + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN && !submenuDone[0] ) + { + separateSubmenu[0] = separateSubmenu[0] == 0 ? 0 : separateSubmenu[0] - 1; + em.playSample(SFX_DIFFICULTY_MOVE); + } + else if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN && !submenuDone[0] ) + { + separateSubmenu[0] = separateSubmenu[0] == 2 ? 2 : separateSubmenu[0] + 1; + em.playSample(SFX_DIFFICULTY_MOVE); + } + + if ( im.getKeyState(MENU_LEFT_2P) == JUST_DOWN && !submenuDone[1] ) + { + separateSubmenu[1] = separateSubmenu[1] == 0 ? 0 : separateSubmenu[1] - 1; + em.playSample(SFX_DIFFICULTY_MOVE); + } + else if ( im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN && !submenuDone[1] ) + { + separateSubmenu[1] = separateSubmenu[1] == 2 ? 2 : separateSubmenu[1] + 1; + em.playSample(SFX_DIFFICULTY_MOVE); + } + } + else + { + if ( im.getKeyState(MENU_LEFT_1P) == JUST_DOWN || im.getKeyState(MENU_LEFT_2P) == JUST_DOWN ) + { + currentSubmenu = currentSubmenu == 0 ? 0 : currentSubmenu - 1; + em.playSample(SFX_DIFFICULTY_MOVE); + } + else if ( im.getKeyState(MENU_RIGHT_1P) == JUST_DOWN || im.getKeyState(MENU_RIGHT_2P) == JUST_DOWN ) + { + currentSubmenu = currentSubmenu == 2 ? 2 : currentSubmenu + 1; + em.playSample(SFX_DIFFICULTY_MOVE); + } + } + + // the start buttons pretty much work the same regardless of versus mode + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN || skippingSubmenu ) + { + if ( !skippingSubmenu ) + { + if ( gs.isVersus ) + { + if ( im.getKeyState(MENU_START_1P) == JUST_DOWN && !submenuDone[0] ) + { + if ( separateSubmenu[0] < 2 ) + { + submenuDone[0] = true; + gs.player[0].stagesPlayed[gs.currentStage] = songlist[songwheelIndex].songID; + gs.player[0].stagesLevels[gs.currentStage] = separateSubmenu[0]; + em.playSample(submenuDone[1] ? SFX_NONE : SFX_START_BUTTON); + } + else + { + isInSubmenu = false; // partner cancelled + em.playSample(SFX_MENU_SORT); + } + } + if ( im.getKeyState(MENU_START_2P) == JUST_DOWN && !submenuDone[1] ) + { + if ( separateSubmenu[1] < 2 ) + { + submenuDone[1] = true; + gs.player[1].stagesPlayed[gs.currentStage] = songlist[songwheelIndex].songID; + gs.player[1].stagesLevels[gs.currentStage] = separateSubmenu[1]; + em.playSample(submenuDone[0] ? SFX_NONE : SFX_START_BUTTON); + } + else + { + isInSubmenu = false; // partner cancelled + em.playSample(SFX_MENU_SORT); + } + } + } + else + { + if ( currentSubmenu < 2 ) + { + gs.player[0].stagesPlayed[gs.currentStage] = gs.player[1].stagesPlayed[gs.currentStage] = songlist[songwheelIndex].songID; + gs.player[0].stagesLevels[gs.currentStage] = gs.player[1].stagesLevels[gs.currentStage] = currentSubmenu; + if ( gs.isDoubles ) + { + gs.player[0].stagesLevels[gs.currentStage] += DOUBLE_MILD; + } + } + else + { + isInSubmenu = false; + em.playSample(SFX_MENU_SORT); + } + } + } + + // done with the submenu? confirm a song? + if ( (isInSubmenu && submenuDone[0] && submenuDone[1]) || skippingSubmenu ) + { + isInSubmenu = skippingSubmenu = false; + gs.currentStage++; + int realIndex = songID_to_listID(songlist[songwheelIndex].songID); + songs[realIndex].numPlays++; + + if ( timeRemaining < 10000 ) + { + timeRemaining = 10000; + } + + if ( gs.currentStage >= gs.numSongsPerSet ) + { + gs.currentStage = 0; + gs.g_currentGameMode = GAMEPLAY; + gs.g_gameModeTransition = 1; + stop_sample(currentPreview); + em.playSample(SFX_FORCEFUL_SELECTION); + } + else + { + em.playSample(SFX_SONGWHEEL_PICK); + } + } + } + } + else + { + if ( (im.isKeyDown(MENU_LEFT_1P) || im.isKeyDown(MENU_LEFT_2P)) && !isRandomSelect && !(im.isKeyDown(MENU_RIGHT_1P) || im.isKeyDown(MENU_RIGHT_2P)) ) + { + isMovementClockwise = false; + prepareForSongwheelRotation(); + em.playSample(SFX_SONGWHEEL_MOVE); + } + else if ( (im.isKeyDown(MENU_RIGHT_1P) || im.isKeyDown(MENU_RIGHT_2P)) && !isRandomSelect && !(im.isKeyDown(MENU_LEFT_1P) || im.isKeyDown(MENU_LEFT_2P)) ) + { + isMovementClockwise = true; + prepareForSongwheelRotation(); + em.playSample(SFX_SONGWHEEL_MOVE); + } + else if ( im.getKeyState(MENU_START_1P) == JUST_DOWN || im.getKeyState(MENU_START_2P) == JUST_DOWN ) + { + isInSubmenu = true; + submenuDone[0] = submenuDone[1] = !gs.isVersus; + em.playSample(SFX_SONGWHEEL_PICK); + isRandomSelect = false; + + // check for songs with a locked chart and skip the difficulty selection submenu + if ( gs.isDoubles && songlist[songwheelIndex].wildDouble == 0 ) + { + isInSubmenu = skippingSubmenu = true; + gs.player[0].stagesPlayed[gs.currentStage] = gs.player[1].stagesPlayed[gs.currentStage] = songlist[songwheelIndex].songID; + gs.player[0].stagesLevels[gs.currentStage] = gs.player[1].stagesLevels[gs.currentStage] = DOUBLE_MILD; + } + if ( gs.isDoubles && songlist[songwheelIndex].mildDouble == 0 ) + { + isInSubmenu = skippingSubmenu = true; + gs.player[0].stagesPlayed[gs.currentStage] = gs.player[1].stagesPlayed[gs.currentStage] = songlist[songwheelIndex].songID; + gs.player[0].stagesLevels[gs.currentStage] = gs.player[1].stagesLevels[gs.currentStage] = DOUBLE_WILD; + } + if ( !gs.isDoubles && songlist[songwheelIndex].wildSingle == 0 ) + { + isInSubmenu = skippingSubmenu = true; + gs.player[0].stagesPlayed[gs.currentStage] = gs.player[1].stagesPlayed[gs.currentStage] = songlist[songwheelIndex].songID; + gs.player[0].stagesLevels[gs.currentStage] = gs.player[1].stagesLevels[gs.currentStage] = SINGLE_MILD; + } + if ( !gs.isDoubles && songlist[songwheelIndex].mildSingle == 0 ) + { + isInSubmenu = skippingSubmenu = true; + gs.player[0].stagesPlayed[gs.currentStage] = gs.player[1].stagesPlayed[gs.currentStage] = songlist[songwheelIndex].songID; + gs.player[0].stagesLevels[gs.currentStage] = gs.player[1].stagesLevels[gs.currentStage] = SINGLE_WILD; + } + } + + // check for random select + if ( !isRandomSelect && (im.getHoldLength(MENU_LEFT_1P) > 3000 || im.getHoldLength(MENU_LEFT_2P) > 3000) && (im.getHoldLength(MENU_RIGHT_1P) > 3000 || im.getHoldLength(MENU_RIGHT_2P) > 3000) ) + { + isRandomSelect = true; + } + } + + // update the display BPM + displayBPMTimer += dt; + switch (displayBPMState) + { + case 1: + displayBPM = getValueFromRange(songlist[songwheelIndex].minBPM, songlist[songwheelIndex].maxBPM, displayBPMTimer >= 1000 ? 100 : displayBPMTimer/10); + if ( displayBPMTimer >= 2000 ) + { + displayBPMTimer -= 2000; + displayBPMState = -1; // going down to the min bpm + } + break; + case -1: + displayBPM = getValueFromRange(songlist[songwheelIndex].maxBPM, songlist[songwheelIndex].minBPM, displayBPMTimer >= 1000 ? 100 : displayBPMTimer/10); + if ( displayBPMTimer >= 2000 ) + { + displayBPMTimer -= 2000; + displayBPMState = 1; // going down to the min bpm + } + break; + default: + if ( displayBPMTimer >= 1000 ) + { + displayBPMTimer -= 1000; + displayBPMState = 1; // going up to the maximum + } + break; + } + + // update random select + if ( isRandomSelect ) + { + songwheelIndex = songwheelIndex + 1 >= maxSongwheelIndex ? 0 : songwheelIndex + 1; + } + + // song preview related + if ( !isSphereMoving ) + { + updatePreview(dt); + } + + // update the time remaining + if ( !isSphereMoving ) + { + if ( !gs.isEventMode ) + { + SUBTRACT_TO_ZERO(timeRemaining, dt); + } + if ( titleAnimTimer < TITLE_ANIM_LENGTH ) + { + titleAnimTimer = MIN(titleAnimTimer + dt, TITLE_ANIM_LENGTH); + } + playTimeLowSFX(dt); + } + if ( timeRemaining <= 0 ) // ran out of time - pick randomly + { + while ( gs.currentStage < gs.numSongsPerSet ) + { + int randIndex = rand()%maxSongwheelIndex; + gs.player[0].stagesPlayed[gs.currentStage] = gs.player[1].stagesPlayed[gs.currentStage] = songlist[randIndex].songID; + if ( gs.isDoubles ) + { + gs.player[0].stagesLevels[gs.currentStage] = gs.player[1].stagesLevels[gs.currentStage] = gs.currentStage == 0 ? DOUBLE_MILD : gs.player[1].stagesLevels[gs.currentStage-1]; + if ( songlist[randIndex].mildDouble == 0 ) + { + gs.player[0].stagesLevels[gs.currentStage] = DOUBLE_WILD; + } + if ( songlist[randIndex].wildDouble == 0 ) + { + gs.player[0].stagesLevels[gs.currentStage] = DOUBLE_MILD; + } + } + else + { + gs.player[0].stagesLevels[gs.currentStage] = gs.player[1].stagesLevels[gs.currentStage] = gs.currentStage == 0 ? SINGLE_MILD : gs.player[1].stagesLevels[gs.currentStage-1]; + if ( songlist[randIndex].mildSingle == 0 ) + { + gs.player[0].stagesLevels[gs.currentStage] = SINGLE_WILD; + gs.player[1].stagesLevels[gs.currentStage] = SINGLE_WILD; + } + if ( songlist[randIndex].wildSingle == 0 ) + { + gs.player[0].stagesLevels[gs.currentStage] = SINGLE_MILD; + gs.player[1].stagesLevels[gs.currentStage] = SINGLE_MILD; + } + } + gs.currentStage++; + } + gs.currentStage = 0; + gs.g_currentGameMode = GAMEPLAY; + gs.g_gameModeTransition = 1; + stop_sample(currentPreview); + } + + renderSongwheelLoop(); +} + +void renderSongwheelLoop() +{ + blit(m_songBG, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + draw_trans_sprite(rm.m_backbuf, m_musicSelect, 260, 135); + + renderPickedSongs(100); + + // render the shadows under the banners + drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); + for ( int i = 0; i < NUM_BANNERS; i++ ) + { + polygon(rm.m_backbuf, 4, shadowQuads[i], makeacol(0, 0, 0, 95)); + } + set_alpha_blender(); // the game assumes the graphics are left in this mode + + // which banner goes where on the wheel? + static char bannerOffsetIndex[NUM_BANNERS] = { -2, -6, -1, -9, -5, 0, -8, -4, 1, -7, -3, 2}; + + for ( int i = 0; i < NUM_BANNERS; i++ ) + { + if ( i != 5 || isSphereMoving ) + { + int bannerIndex = songwheelIndex + bannerOffsetIndex[i]; + if ( bannerIndex < 0 ) + { + bannerIndex += maxSongwheelIndex; + } + if ( bannerIndex > maxSongwheelIndex-1 ) + { + bannerIndex -= maxSongwheelIndex; + } + bannerIndex = songID_to_listID(songlist[bannerIndex].songID); + renderBanner(bannerIndex, i, songs[bannerIndex].isNew); + } + } + + // render the current banner last + if ( !isSphereMoving ) + { + renderTitleArea(titleAnimTimer * 100 / TITLE_ANIM_LENGTH); + } + + renderTimeRemaining(); + renderLoginStats(0, 0); + renderLoginStats(320, 1); + + if ( isInSubmenu ) + { + rectfill(rm.m_backbuf, 250, 300, 550, 370, makeacol(146, 16, 255, 128)); + if ( !gs.isVersus ) + { + masked_blit(m_menu[currentSubmenu], rm.m_backbuf, 0, 0, 256, 305, 288, 60); + } + else + { + int p1y = separateSubmenu[0]*20 + 305; + int p2y = separateSubmenu[1]*20 + 305; + masked_blit(m_menu[separateSubmenu[0]], rm.m_backbuf, 0, 0, 256, 305, 288, 60); + masked_blit(m_menu[separateSubmenu[1]], rm.m_backbuf, 0, separateSubmenu[1]*20, 256, p2y, 288, 20); + renderWhiteString("1P", 236, p1y); + renderWhiteString("2P", 256+288, p2y); + } + } + + rm.flip(); +} + +void renderIntroAnim(int percent) +{ + blit(m_songBG, rm.m_backbuf, 0, 0, 0, 0, 640, 480); + draw_trans_sprite(rm.m_backbuf, m_musicSelect, getValueFromRange(SCREEN_WIDTH, 260, percent), 135); + + renderTimeRemaining(); + renderPickedSongs(percent); + + // render the shadows under the banners + drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); + for ( int i = 0; i < NUM_BANNERS; i++ ) + { + polygon(rm.m_backbuf, 4, shadowQuads[i], makeacol(0, 0, 0, 95)); + } + set_alpha_blender(); // the game assumes the graphics are left in this mode + + // which banner goes where on the wheel? + static char bannerOffsetIndex[NUM_BANNERS] = { -2, -6, -1, -9, -5, 0, -8, -4, 1, -7, -3, 2}; + + for ( int i = 0; i < NUM_BANNERS; i++ ) + { + int bannerIndex = songwheelIndex + bannerOffsetIndex[i]; + if ( bannerIndex < 0 ) + { + bannerIndex += maxSongwheelIndex; + } + if ( bannerIndex > maxSongwheelIndex-1 ) + { + bannerIndex -= maxSongwheelIndex; + } + bannerIndex = songID_to_listID(songlist[bannerIndex].songID); + renderBanner(bannerIndex, i, songs[bannerIndex].isNew); + } + + rm.flip(); +} + +void prepareForSongwheelRotation() +{ + // copy either [targetQuadsCW] or [targetQuadsCCW] to targetQuads + if ( !isMovementClockwise ) + { + for ( int i = 0; i < NUM_BANNERS; i++ ) + for ( int j = 0; j < 8; j++ ) + { + targetQuads[i][j] = targetQuadsCW[i][j]; + } + songwheelIndex = songwheelIndex <= 0 ? maxSongwheelIndex - 1 : songwheelIndex - 1; + } + else + { + for ( int i = 0; i < NUM_BANNERS; i++ ) + for ( int j = 0; j < 8; j++ ) + { + targetQuads[i][j] = targetQuadsCCW[i][j]; + } + songwheelIndex = songwheelIndex + 1 >= maxSongwheelIndex ? 0 : songwheelIndex + 1; + } + + isSphereMoving = true; + rotateAnimTime = introAnimTimer > 0 ? INTRO_ANIM_STEP_TIME : WHEEL_STEP_TIME; + updateSongwheelRotation(0); + stop_sample(currentPreview); +} + +void postSongwheelRotation() +{ + // set the current positions of all the banners + for ( int i = 0; i < NUM_BANNERS; i++ ) + { + for ( int j = 0; j < 8; j++ ) + { + currentQuads[i][j] = bannerQuads[i][j]; + } + } + isSphereMoving = false; + + displayBPM = songlist[songwheelIndex].minBPM; + displayBPMTimer = 0; + displayBPMState = 0; +} + +void updateSongwheelRotation(UTIME dt) +{ + rotateAnimTime -= dt; + if ( rotateAnimTime <= 0 ) + { + postSongwheelRotation(); + return; + } + + int percent = rotateAnimTime * 100 / (introAnimTimer > 0 ? INTRO_ANIM_STEP_TIME : WHEEL_STEP_TIME); + + // 'tween' each quad to where it wants to be + for ( int i = 0; i < NUM_BANNERS; i++ ) + { + for ( int j = 0; j < 8; j++ ) + { + currentQuads[i][j] = getValueFromRange(bannerQuads[i][j], targetQuads[i][j], percent); + } + } +} + +void renderBanner(int textureID, int coordsIndex, bool isNew) +{ + for ( int i = 0; i < 4; i++ ) + { + pp[i]->x = itofix(currentQuads[coordsIndex][i*2]); + pp[i]->y = itofix(currentQuads[coordsIndex][i*2 +1]); + pp[i]->z = 0; + pp[i]->c = 0;//makeacol(255,255,255,255); + pp[i]->u = pp[i]->v = 0; + } + + pp[3]->u = itofix(0); // use hi-res 256x256 square banners + pp[3]->v = itofix(255); + + pp[0]->u = itofix(0); + pp[0]->v = itofix(0); + + pp[1]->u = itofix(255); + pp[1]->v = itofix(0); + + pp[2]->u = itofix(255); + pp[2]->v = itofix(255); + + + //polygon3d(rm.m_backbuf, POLYTYPE_FLAT, m_banners[textureID], 4, pp); + if ( m_banners[textureID] != NULL ) + { + quad3d(rm.m_backbuf, POLYTYPE_ATEX, m_banners[textureID], pp[0], pp[1], pp[2], pp[3]); + } + if ( isNew ) + { + draw_trans_sprite(rm.m_backbuf, m_new, fixtoi(pp[0]->x), fixtoi(pp[0]->y) - 10); + } +} + +void renderTitleArea(int percent) +{ + unsigned char bpm[] = "000"; + int globalIndex = songID_to_listID(songlist[songwheelIndex].songID); + + if ( percent < 20 ) + { + draw_trans_sprite(rm.m_backbuf, m_titleArea, getValueFromRange(SCREEN_WIDTH, 0, percent*5), 164); + } + else + { + draw_trans_sprite(rm.m_backbuf, m_titleArea, 0, 164); + } + + renderBanner(globalIndex, 5, songlist[songwheelIndex].isNew); + + if ( percent >= 35 ) + { + renderBoldString(songTitles[globalIndex].c_str(), 293, 170, 365, false); + renderDifficultyStars(398, 243, 0, gs.isDoubles ? songlist[songwheelIndex].mildDouble : songlist[songwheelIndex].mildSingle); + renderDifficultyStars(433, 225, 1, gs.isDoubles ? songlist[songwheelIndex].wildDouble : songlist[songwheelIndex].wildSingle); + } + if ( percent >= 65 ) + { + renderArtistString(songArtists[globalIndex].c_str(), 293, 196, 365, 16); + + bpm[0] = (displayBPM / 100 % 10) + '0'; + bpm[1] = (displayBPM / 10 % 10) + '0'; + bpm[2] = (displayBPM / 1 % 10) + '0'; + renderBoldString(bpm, 583, 238, 100, false); + } + if ( percent >= 85 ) + { + masked_blit(m_versions, rm.m_backbuf, 0, songlist[songwheelIndex].version*60, 33, 178, 96, 60); + } +} + +void renderPickedSongs(int percent) +{ + int startingX = SCREEN_W - 5 - (gs.numSongsPerSet * 71); + int x = startingX; + + for ( int i = 0; i < gs.numSongsPerSet; i++ ) + { + if ( gs.player[0].stagesPlayed[i] == -1 || i >= gs.currentStage ) + { + // render an empty slot + rectfill(rm.m_backbuf, x, 5, x+64, 69, makeacol(0, 0, 0, getValueFromRange(0, 64, percent))); + if ( percent > 80 ) + { + renderWhiteNumber(i+1, x + 10, 15); + } + } + else + { + // render a real banner + stretch_blit(m_banners[songID_to_listID(gs.player[0].stagesPlayed[i])], rm.m_backbuf, 0, 0, 256, 256, x, 5, 64, 64); + } + + x += 71; + } +} + +void renderDifficultyStars(int x, int y, char type, char level) +{ + int xdiff = level <= 5 ? 23 : 13; // for 5 or less stars, do not stack them + int starLimit = level <= 5 ? 5 : 9; + + if ( type == 0 ) + { + xdiff *= -1; // mild goes left, wild goes right + } + if ( level == 0 ) + { + starLimit = 0; // for locked charts + draw_trans_sprite(rm.m_backbuf, m_lockedIcon, x, y); + } + + for ( int i = 1; i <= starLimit; i++ ) + { + draw_trans_sprite(rm.m_backbuf, m_stars[type][level <= i-1 ? 1 : 0], x, y); + x += xdiff; + } +} + +void renderTimeRemaining(int xcoord, int ycoord) +{ + if ( timeRemaining > 99000 || timeRemaining < 0 ) + { + return; + } + + int tensDigit = timeRemaining/10000 % 10; + int onesDigit = timeRemaining/1000 % 10; + char color = 0, yoff = 0; + + if ( timeRemaining < 6000 ) + { + color = (timeRemaining/50) % 2; + } + if ( timeRemaining % 1000 < 100 ) + { + yoff = (timeRemaining % 1000)/20; + } + + if ( color == 0 ) + { + draw_trans_sprite(rm.m_backbuf, m_time, 5, 15); // blink when time is low + } + + if ( onesDigit == 0 ) + { + masked_blit(m_timeDigits[color], rm.m_backbuf, 0, tensDigit*32, xcoord, ycoord+yoff, 32, 32); + } + else + { + masked_blit(m_timeDigits[color], rm.m_backbuf, 0, tensDigit*32, xcoord, ycoord, 32, 32); + } + masked_blit(m_timeDigits[color], rm.m_backbuf, 0, onesDigit*32, xcoord+32, ycoord+yoff, 32, 32); +} + +void playTimeLowSFX(UTIME dt) +{ + static UTIME beepAt[8] = { 5000, 4000, 3000, 2500, 2000, 1500, 1000, 500 }; + + for ( int i = 0; i < 8; i++ ) + { + if ( timeRemaining < beepAt[i] && (timeRemaining + dt) >= beepAt[i] ) + { + em.playSample(SFX_TIMER_LOW); + } + } +} + +// only works for a single player, and really just for debugging +void renderExtendedStats() +{ + renderWhiteString(" PERFECT:", 445, 290); + renderWhiteString(" GREAT:", 445, 305); + renderWhiteString(" GOOD:", 445, 320); + renderWhiteString(" MISS:", 445, 335); + renderWhiteString("MAX COMBO:", 445, 350); + int chartIndex = 0; + renderWhiteNumber(sm.player[0].allTime[songwheelIndex][chartIndex].perfects, 445+110, 290); + renderWhiteNumber(sm.player[0].allTime[songwheelIndex][chartIndex].greats, 445+110, 305); + renderWhiteNumber(sm.player[0].allTime[songwheelIndex][chartIndex].goods, 445+110, 320); + renderWhiteNumber(sm.player[0].allTime[songwheelIndex][chartIndex].misses, 445+110, 335); + renderWhiteNumber(sm.player[0].allTime[songwheelIndex][chartIndex].maxCombo, 445+110, 350); +} + +void renderLoginStats(int x, int side) +{ + int mildIndex = gs.isDoubles ? getChartIndexFromType(DOUBLE_MILD) : getChartIndexFromType(SINGLE_MILD); + int wildIndex = gs.isDoubles ? getChartIndexFromType(DOUBLE_WILD) : getChartIndexFromType(SINGLE_WILD); + char buffer[10] = ""; + + if ( !sm.player[side].isLoggedIn ) + { + return; + } + + int offset = 20; + for ( int i = 0; i < 8; i++ ) + { + renderNameLetter(sm.player[side].displayName[i], x+offset, 410, side+1); + offset += 32; + } + + int allTimeIndex = songID_to_listID(songlist[songwheelIndex].songID); + _itoa_s(sm.player[side].allTime[allTimeIndex][mildIndex].getScore(), buffer, 9, 10); + addLeadingZeros(buffer, 7); + renderBoldString((unsigned char *)buffer, x+20, 440, 320, false, 1); + masked_blit(m_miniStatus, rm.m_backbuf, 0, sm.player[side].allTime[allTimeIndex][mildIndex].status * 32, x+120, 433, 40, 32); + _itoa_s(sm.player[side].allTime[allTimeIndex][wildIndex].getScore(), buffer, 9, 10); + addLeadingZeros(buffer, 7); + renderBoldString((unsigned char *)buffer, x+180, 440, 320, false, 2); + masked_blit(m_miniStatus, rm.m_backbuf, 0, sm.player[side].allTime[allTimeIndex][wildIndex].status * 32, x+280, 433, 40, 32); +} + +void updatePreview(UTIME dt) +{ + SUBTRACT_TO_ZERO(previewTimeRemaining, dt); + + if ( previewSongID != songlist[songwheelIndex].songID ) + { + if ( isRandomSelect && last_utime - previewTimeStarted < 2000 ) + { + return; + } + + previewSongID = songlist[songwheelIndex].songID; + previewTimeStarted = last_utime; + loadPreview(previewSongID); + if ( isRandomSelect ) + { + play_sample(currentPreview, 255, 127, pickRandomInt(3,12,15,20)*100, 1); + } + else + { + play_sample(currentPreview, 255, 127, 1000, 1); + } + previewTimeRemaining = getSampleLength(currentPreview); + } +} + +void loadPreview(int songid) +{ + char filename[] = "DATA/sfx/pre_000.wav"; + filename[13] = (songid/100)%10 + '0'; + filename[14] = (songid/10)%10 + '0'; + filename[15] = (songid/1)%10 + '0'; + + if ( !fileExists(filename) ) + { + filename[13] = '1'; // fix this problem + filename[14] = '0'; + filename[15] = '1'; + } + + destroy_sample(currentPreview); + currentPreview = load_sample(filename); +} \ No newline at end of file diff --git a/src/source/specialEffects.cpp b/src/source/specialEffects.cpp new file mode 100644 index 0000000..32c5290 --- /dev/null +++ b/src/source/specialEffects.cpp @@ -0,0 +1,263 @@ +// specialEffects.cpp implements functions to do some special rendering tasks +// file created by Allen Seitz 12-02-09 + +#include "specialEffects.h" +#include "common.h" +#include "gameStateManager.h" + +extern RenderingManager rm; +extern GameStateManager gs; + +extern int trickBanner1; +extern int trickBanner2; +extern BITMAP* m_banner1; +extern BITMAP* m_banner2; + +void renderLightningBeamHorizontal(int x, int width, int y1, int y2, int seed, int endStyle) +{ + struct AL_POINT dots[5]; + int height = y2 - y1; + int i = 0; + + ASSERT(height <= 0); + if ( height <= 0 ) + { + return; + } + + // first initialize every point to be a straight horizontal line + dots[0].x = 0; // the 1st dot is automatically at the start + dots[2].x = seed/32 + 45; // the 3rd dot is anywhere 45-72% on the line + dots[1].x = seed%(dots[2].x-10) + 10; // the 2nd dot is anywhere 10%-3rd on the line + dots[3].x = seed%(90-dots[2].x) + dots[2].x; // the 4th dot is anywhere 3rd-90% on the line + dots[4].x = 100; // the 5th dot is automatically at the end + for ( i = 0; i < 5; i++ ) + { + dots[i].x = x + (dots[i].x * width / 100); + dots[i].y = y1 + height/2; + } + + // step 2: move dot 2 anywhere + dots[2].y = seed%(y2-y1) + y1; + + // step 3: move dot 4 as far away from dot 2 as possible, within 16% + dots[4].y = dots[2].y + (height/4); + dots[4].y += ((height/2)*(seed/64)/100); + dots[4].y = dots[4].y > y2 ? dots[4].y - height : dots[4].y; + + // step 4a: calculate where dot 4 should be on the line + dots[3].y = (dots[2].y + dots[4].y)/2; + + // step 4b: move dot 4 10% in either direction, randomly + if ( seed > 511 ) + { + dots[3].y -= height/10; + if ( dots[3].y < y1 ) + { + dots[3].y += height; + } + } + else + { + dots[3].y += height/10; + if ( dots[3].y > y2 ) + { + dots[3].y -= height; + } + } + + // step 5a: calculate where dot 1 should be on the line + dots[1].y = (dots[0].y + dots[2].y)/2; + + // step 5b: move dot 1 4-20% in either direction, randomly + if ( seed > 255 && seed < 768 ) + { + dots[1].y -= height/(seed%16 + 4); + if ( dots[1].y < y1 ) + { + dots[1].y += height; + } + } + else + { + dots[1].y += height/(seed%16 + 4); + if ( dots[1].y > y2 ) + { + dots[1].y -= height; + } + } + + // implement the different end styles + if ( endStyle == LIGHTNING_END_START ) + { + dots[4].y = dots[0].y; + } + + // finally actually render the lines! + for ( i = 0; i < 4; i++ ) + { + int neonBlue = 0x8820E0FF; + int deepBlue = 0x5520F0FF; + + if ( seed % 6 == 0 ) + { + do_line(rm.m_backbuf, dots[i].x, dots[i].y, dots[i+1].x, dots[i+1].y, neonBlue, drawLightningPixelThick); + } + else + { + do_line(rm.m_backbuf, dots[i].x, dots[i].y, dots[i+1].x, dots[i+1].y, deepBlue, drawLightningPixel); + } + } +} + +void renderLightningBeamVertical(int y, int height, int x1, int x2, int seed, int endStyle) +{ + struct AL_POINT dots[4]; + int width = x2 - x1; + int i = 0; + + ASSERT(width <= 0); + if ( width <= 0 ) + { + return; + } + + // first initialize every point to be a straight vertical line + dots[0].y = 0; // the 1st dot is automatically at the start + dots[1].y = seed/32 + 45; // the 2nd dot is anywhere 45-72% on the line + dots[2].y = seed%(90-dots[1].y) + dots[1].y; // the 3rd dot is anywhere 2nd-90% on the line + dots[3].y = 100; // the 4th dot is automatically at the end + for ( i = 0; i < 4; i++ ) + { + dots[i].x = x1 + width/2; + dots[i].y = y + (dots[i].y * height / 100); + } + + // step 2: move dot 2 anywhere + dots[1].x = seed%(x2-x1) + x1; + + // step 3: move dot 4 as far away from dot 2 as possible, within 16% + dots[3].x = dots[1].x + (width/4); + dots[3].x += ((width/2)*(seed/64)/100); + dots[3].x = dots[3].x > x2 ? dots[3].x - width : dots[3].x; + + // step 4a: calculate where dot 3 should be on the line + dots[2].x = (dots[1].x + dots[3].x)/2; + + // step 4b: move dot 3 10% in either direction, randomly + if ( seed > 511 ) + { + dots[2].x -= width/10; + if ( dots[2].x < x1 ) + { + dots[2].x += width; + } + } + else + { + dots[2].x += width/10; + if ( dots[2].x > x2 ) + { + dots[2].x -= width; + } + } + + // implement the different end styles + if ( endStyle == LIGHTNING_END_START ) + { + dots[3].x = dots[0].x; + } + + // finally actually render the lines! + for ( i = 0; i < 3; i++ ) + { + drawLightningLine(dots[i].x, dots[i].y, dots[i+1].x, dots[i+1].y, (seed+i)%8); + } +} + +void drawLightningLine(int x1, int y1, int x2, int y2, int brightness) +{ + int innerColor = 0x22FFFFFF; + int neonBlue = 0xFF20E0FF; + //int darkerBlue = 0x442080FF; + + int spread = brightness % 3; + + do_line(rm.m_backbuf, x1+spread, y1+spread, x2+spread, y2+spread, neonBlue, drawLightningPixel); + do_line(rm.m_backbuf, x1-spread, y1-spread, x2-spread, y2-spread, neonBlue, drawLightningPixel); + do_line(rm.m_backbuf, x1, y1, x2, y2, innerColor, drawLightningPixel); +} + +void drawLightningPixelThick(BITMAP *bmp, int x, int y, int color) +{ + for ( int bx = x-1; bx < x+2; bx++ ) + for ( int by = y-1; by < y+2; by++ ) + { + if ( bx < 0 || bx >= SCREEN_WIDTH || by < 0 || by >= SCREEN_HEIGHT ) + { + continue; + } + + // get the pixel at this position + unsigned long pixel = ((long *)bmp->line[by])[bx]; + int r = (pixel & 0x00FF0000) >> 16; + int g = (pixel & 0x0000FF00) >> 8; + int b = (pixel & 0x000000FF); + + // blend it with a neon blue color + int a = (color & 0xFF000000) >> 24; + r = WEIGHTED_AVERAGE(((color & 0x00FF0000) >> 16), r, a, 255); + g = WEIGHTED_AVERAGE(((color & 0x0000FF00) >> 8) , g, a, 255); + b = WEIGHTED_AVERAGE((color & 0x000000FF) , b, a, 255); + + long c = (r << 16) + (g << 8) + b; + ((long *)bmp->line[by])[bx] = c; + } +} + +void drawLightningPixel(BITMAP *bmp, int x, int y, int color) +{ + if ( x < 0 || x >= SCREEN_WIDTH || y < 0 || y >= SCREEN_HEIGHT ) + { + return; + } + + // get the pixel at this position + unsigned long pixel = ((long *)bmp->line[y])[x]; + int r = (pixel & 0x00FF0000) >> 16; + int g = (pixel & 0x0000FF00) >> 8; + int b = (pixel & 0x000000FF); + + // blend it with the given color + int a = (color & 0xFF000000) >> 24; + r = WEIGHTED_AVERAGE(((color & 0x00FF0000) >> 16), r, a, 255); + g = WEIGHTED_AVERAGE(((color & 0x0000FF00) >> 8) , g, a, 255); + b = WEIGHTED_AVERAGE((color & 0x000000FF) , b, a, 255); + + long c = (r << 16) + (g << 8) + b; + ((long *)bmp->line[y])[x] = c; +} + +void drawLightningPixelOld(BITMAP *bmp, int x, int y, int brightness) +{ + static int brightnessScale[8] = { 64, 128, 196, 255, 128, 64, 196, 128 }; + + if ( x < 0 || x >= SCREEN_WIDTH || y < 0 || y >= SCREEN_HEIGHT ) + { + return; + } + + // get the pixel at this position + unsigned long pixel = ((long *)bmp->line[y])[x]; + int r = (pixel & 0x00FF0000) >> 16; + int g = (pixel & 0x0000FF00) >> 8; + int b = (pixel & 0x000000FF); + + // blend it with a neon blue color + r = WEIGHTED_AVERAGE(32, r, brightnessScale[brightness], 256); + g = WEIGHTED_AVERAGE(235, g, brightnessScale[brightness], 256); + b = WEIGHTED_AVERAGE(255, b, brightnessScale[brightness], 256); + + long c = (r << 16) + (g << 8) + b; + ((long *)bmp->line[y])[x] = c; +} \ No newline at end of file