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 else. 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.

int allegro_init();
Initialises the Allegro library. This is the same thing as calling install_allegro(SYSTEM_AUTODETECT, &errno, atexit).

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.

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[];
Text string used by set_gfx_mode() and install_sound() 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.

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_WINNT      - Windows NT
      OSTYPE_OS2        - OS/2
      OSTYPE_WARP       - OS/2 Warp 3
      OSTYPE_DOSEMU     - Linux DOSEMU
      OSTYPE_OPENDOS    - Caldera OpenDOS
      OSTYPE_BEOS       - BeOS
      OSTYPE_LINUX      - Linux
      OSTYPE_UNIX       - Unknown Unix variant

void allegro_message(char *msg, ...);
Outputs a message, using a printf() format string. This function must only be used when you aren't in graphics mode, eg. before calling set_gfx_mode(), or after a set_gfx_mode(GFX_TEXT). On platforms that have a text mode console (DOS, Unix and BeOS) it will print the string to the console, attempting to work around codepage differences by reducing any accented characters to 7 bit ASCII approximations, or under Windows it will bring up a GUI message box.

void set_window_title(const char *name);
On platforms that are capable of it, this routine alters the window title for your Allegro program.

int desktop_color_depth();
On platforms that can run Allegro programs in a window on an existing desktop, returns the currently selected desktop color depth (your program is likely to run faster if it uses this same depth). On platforms where this information is not available or does not apply, returns zero.

void yield_timeslice();
On systems that support this, gives up the rest of the current scheduler timeslice. Also known as the "play nice with multitasking" option.

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.

extern char cpu_vendor[];
Contains the CPU vendor name, if known (empty string on non-Intel platforms).

extern int cpu_family;
Contains the Intel CPU type, where applicable: 3=386, 4=486, 5=Pentium, 6=PPro, etc.

extern int cpu_model;
Contains the Intel CPU submodel, where applicable. On a 486 (cpu_family=4), zero or one indicates a DX chip, 2 an SX, 3 a 487 (SX) or 486 DX, 4 an SL, 5 an SX2, 7 a DX2 write-back enhanced, 8 a DX4 or DX4 overdrive, 14 a Cyrix, and 15 is unknown. On a Pentium chip (cpu_family=5), 1 indicates a Pentium (510\66, 567\66), 2 is a Pentium P54C, 3 is a Pentium overdrive processor, 5 is a Pentium overdrive for IntelDX4, 14 is a Cyrix, and 15 is unknown.

extern int cpu_fpu;
Contains TRUE or FALSE, depending on whether an Intel floating point processor is available.

extern int cpu_mmx;
Contains TRUE or FALSE, depending on whether the Intel MMX instruction set is available.

extern int cpu_3dnow;
Contains TRUE or FALSE, depending on whether the AMD 3DNow! instruction set is available.

extern int cpu_cpuid;
Contains TRUE or FALSE, depending on whether the Intel "cpuid" instruction was available (if this is set, the other CPU variables are 100% reliable, otherwise there may be some mistakes).




Back to Contents