Allegro Folder Renamed

This commit is contained in:
Asrın Doğan
2019-09-10 12:50:01 +03:00
parent 881a08e94b
commit cea9e179ef
271 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,53 @@
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Some definitions for internal use by the library code.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*/
#ifndef __al_included_allegro5_aintern_h
#define __al_included_allegro5_aintern_h
#ifndef __al_included_allegro5_allegro_h
#error must include allegro5/allegro.h first
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define _ALLEGRO_MIN(x,y) (((x) < (y)) ? (x) : (y))
#define _ALLEGRO_MAX(x,y) (((x) > (y)) ? (x) : (y))
#define _ALLEGRO_CLAMP(x,y,z) _ALLEGRO_MAX((x), _ALLEGRO_MIN((y), (z)))
/* message stuff */
#define ALLEGRO_MESSAGE_SIZE 4096
/* 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));
AL_FUNC(int, _al_stricmp, (const char *s1, const char *s2));
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,24 @@
#ifndef __al_included_allegro5_aintern_aatree_h
#define __al_included_allegro5_aintern_aatree_h
typedef struct _AL_AATREE _AL_AATREE;
struct _AL_AATREE
{
int level;
_AL_AATREE *left;
_AL_AATREE *right;
const void *key;
void *value;
};
typedef int (*_al_cmp_t)(const void *a, const void *b);
_AL_AATREE *_al_aa_insert(_AL_AATREE *T, const void *key, void *value, _al_cmp_t compare);
void *_al_aa_search(const _AL_AATREE *T, const void *key, _al_cmp_t compare);
_AL_AATREE *_al_aa_delete(_AL_AATREE *T, const void *key, _al_cmp_t compare, void **ret_value);
void _al_aa_free(_AL_AATREE *T);
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,9 @@
#define ALLEGRO_CFG_ACODEC_FLAC
#define ALLEGRO_CFG_ACODEC_MODAUDIO
#define ALLEGRO_CFG_ACODEC_VORBIS
/* #undef ALLEGRO_CFG_ACODEC_TREMOR */
/* Define if the library should be loaded dynamically. */
/* #undef ALLEGRO_CFG_ACODEC_FLAC_DLL */
/* #undef ALLEGRO_CFG_ACODEC_DUMB_DLL */
/* #undef ALLEGRO_CFG_ACODEC_VORBISFILE_DLL */

View File

@@ -0,0 +1,120 @@
#ifndef __al_included_allegro5_aintern_atomicops_h
#define __al_included_allegro5_aintern_atomicops_h
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
/* gcc 4.1 and above have builtin atomic operations. */
typedef int _AL_ATOMIC;
AL_INLINE(_AL_ATOMIC,
_al_fetch_and_add1, (volatile _AL_ATOMIC *ptr),
{
return __sync_fetch_and_add(ptr, 1);
})
AL_INLINE(_AL_ATOMIC,
_al_sub1_and_fetch, (volatile _AL_ATOMIC *ptr),
{
return __sync_sub_and_fetch(ptr, 1);
})
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
/* gcc, x86 or x86-64 */
typedef int _AL_ATOMIC;
#define __al_fetch_and_add(ptr, value, result) \
__asm__ __volatile__ ( \
"lock; xaddl %0, %1" \
: "=r" (result), "=m" (*ptr) \
: "0" (value), "m" (*ptr) \
: "memory" \
)
AL_INLINE(_AL_ATOMIC,
_al_fetch_and_add1, (volatile _AL_ATOMIC *ptr),
{
_AL_ATOMIC result;
__al_fetch_and_add(ptr, 1, result);
return result;
})
AL_INLINE(_AL_ATOMIC,
_al_sub1_and_fetch, (volatile _AL_ATOMIC *ptr),
{
_AL_ATOMIC old;
__al_fetch_and_add(ptr, -1, old);
return old - 1;
})
#elif defined(_MSC_VER) && _M_IX86 >= 400
/* MSVC, x86 */
/* MinGW supports these too, but we already have asm code above. */
typedef LONG _AL_ATOMIC;
AL_INLINE(_AL_ATOMIC,
_al_fetch_and_add1, (volatile _AL_ATOMIC *ptr),
{
return InterlockedIncrement(ptr) - 1;
})
AL_INLINE(_AL_ATOMIC,
_al_sub1_and_fetch, (volatile _AL_ATOMIC *ptr),
{
return InterlockedDecrement(ptr);
})
#elif defined(ALLEGRO_HAVE_OSATOMIC_H)
/* OS X, GCC < 4.1
* These functions only work on Tiger (10.4) and above.
* FIXME: Apple's manpage says these functions take volatile int*
* arguments, but at least the 10.4 SDK seems to prototype them as
* taking int * - should the volatile qualifier be removed from the
* wrapper functions in this case? (EG)
*/
#include <libkern/OSAtomic.h>
typedef int32_t _AL_ATOMIC;
AL_INLINE(_AL_ATOMIC,
_al_fetch_and_add1, (volatile _AL_ATOMIC *ptr),
{
return OSAtomicIncrement32Barrier((_AL_ATOMIC *)ptr) - 1;
})
AL_INLINE(_AL_ATOMIC,
_al_sub1_and_fetch, (volatile _AL_ATOMIC *ptr),
{
return OSAtomicDecrement32Barrier((_AL_ATOMIC *)ptr);
})
#else
/* Hope for the best? */
#warning Atomic operations undefined for your compiler/architecture.
typedef int _AL_ATOMIC;
AL_INLINE(_AL_ATOMIC,
_al_fetch_and_add1, (volatile _AL_ATOMIC *ptr),
{
return (*ptr)++;
})
AL_INLINE(_AL_ATOMIC,
_al_sub1_and_fetch, (volatile _AL_ATOMIC *ptr),
{
return --(*ptr);
})
#endif
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,327 @@
/* internal-only header
* Updated for 4.9 api inclusion by Ryan Dickie
* Originally done by KC/Milan
*/
#ifndef AINTERN_AUDIO_H
#define AINTERN_AUDIO_H
#include "allegro5/allegro.h"
#include "allegro5/internal/aintern_vector.h"
#include "../allegro_audio.h"
typedef enum ALLEGRO_AUDIO_DRIVER_ENUM
{
/* Various driver modes. */
ALLEGRO_AUDIO_DRIVER_AUTODETECT = 0x20000,
ALLEGRO_AUDIO_DRIVER_OPENAL = 0x20001,
ALLEGRO_AUDIO_DRIVER_ALSA = 0x20002,
ALLEGRO_AUDIO_DRIVER_DSOUND = 0x20003,
ALLEGRO_AUDIO_DRIVER_OSS = 0x20004,
ALLEGRO_AUDIO_DRIVER_AQUEUE = 0x20005,
ALLEGRO_AUDIO_DRIVER_PULSEAUDIO = 0x20006
} ALLEGRO_AUDIO_DRIVER_ENUM;
typedef struct ALLEGRO_AUDIO_DRIVER ALLEGRO_AUDIO_DRIVER;
struct ALLEGRO_AUDIO_DRIVER {
const char *specifier;
int (*open)(void);
void (*close)(void);
int (*allocate_voice)(ALLEGRO_VOICE*);
void (*deallocate_voice)(ALLEGRO_VOICE*);
int (*load_voice)(ALLEGRO_VOICE*, const void*);
void (*unload_voice)(ALLEGRO_VOICE*);
int (*start_voice)(ALLEGRO_VOICE*);
int (*stop_voice)(ALLEGRO_VOICE*);
bool (*voice_is_playing)(const ALLEGRO_VOICE*);
unsigned int (*get_voice_position)(const ALLEGRO_VOICE*);
int (*set_voice_position)(ALLEGRO_VOICE*, unsigned int);
};
extern ALLEGRO_AUDIO_DRIVER *_al_kcm_driver;
const void *_al_voice_update(ALLEGRO_VOICE *voice, unsigned int *samples);
bool _al_kcm_set_voice_playing(ALLEGRO_VOICE *voice, bool val);
/* A voice structure that you'd attach a mixer or sample to. Ideally there
* would be one ALLEGRO_VOICE per system/hardware voice.
*/
struct ALLEGRO_VOICE {
ALLEGRO_AUDIO_DEPTH depth;
ALLEGRO_CHANNEL_CONF chan_conf;
unsigned int frequency;
size_t buffer_size;
size_t num_buffers;
/* If non-0, they must be honored by the driver. */
ALLEGRO_SAMPLE_INSTANCE *attached_stream;
/* The stream that is attached to the voice, or NULL.
* May be an ALLEGRO_SAMPLE_INSTANCE or ALLEGRO_MIXER object.
*/
bool is_streaming;
/* True for voices with an attached mixer. */
ALLEGRO_MUTEX *mutex;
ALLEGRO_COND *cond;
ALLEGRO_AUDIO_DRIVER *driver;
/* XXX shouldn't there only be one audio driver active
* at a time?
*/
void *extra;
/* Extra data for use by the driver. */
};
typedef union {
float *f32;
uint32_t *u24;
int32_t *s24;
uint16_t *u16;
int16_t *s16;
uint8_t *u8;
int8_t *s8;
void *ptr;
} any_buffer_t;
struct ALLEGRO_SAMPLE {
ALLEGRO_AUDIO_DEPTH depth;
ALLEGRO_CHANNEL_CONF chan_conf;
unsigned int frequency;
int len;
any_buffer_t buffer;
bool free_buf;
/* Whether `buffer' needs to be freed when the sample
* is destroyed, or when `buffer' changes.
*/
};
/* Read some samples into a mixer buffer.
*
* source:
* The object to read samples from. This may be one of several types.
*
* *vbuf: (in-out parameter)
* Pointer to pointer to destination buffer.
* (should confirm what it means to change the pointer on return)
*
* *samples: (in-out parameter)
* On input indicates the maximum number of samples that can fit into *vbuf.
* On output indicates the actual number of samples that were read.
*
* buffer_depth:
* The audio depth of the destination buffer.
*
* dest_maxc:
* The number of channels in the destination.
*/
typedef void (*stream_reader_t)(void *source, void **vbuf,
unsigned int *samples, ALLEGRO_AUDIO_DEPTH buffer_depth, size_t dest_maxc);
typedef struct {
union {
ALLEGRO_MIXER *mixer;
ALLEGRO_VOICE *voice;
void *ptr;
} u;
bool is_voice;
} sample_parent_t;
/* The sample struct also serves the base of ALLEGRO_AUDIO_STREAM, ALLEGRO_MIXER. */
struct ALLEGRO_SAMPLE_INSTANCE {
/* ALLEGRO_SAMPLE_INSTANCE does not generate any events yet but ALLEGRO_AUDIO_STREAM
* does, which can inherit only ALLEGRO_SAMPLE_INSTANCE. */
ALLEGRO_EVENT_SOURCE es;
ALLEGRO_SAMPLE spl_data;
volatile bool is_playing;
/* Is this sample is playing? */
ALLEGRO_PLAYMODE loop;
float speed;
float gain;
float pan;
/* When resampling an audio stream there will be fractional sample
* positions due to the difference in frequencies.
*/
int pos;
int pos_bresenham_error;
int loop_start;
int loop_end;
int step;
int step_denom;
/* The numerator and denominator of the step are
* stored separately. The actual step is obtained by
* dividing step by step_denom */
float *matrix;
/* Used to convert from this format to the attached
* mixers, if any. Otherwise is NULL.
* The gain is premultiplied in.
*/
bool is_mixer;
stream_reader_t spl_read;
/* Reads sample data into the provided buffer, using
* the specified format, converting as necessary.
*/
ALLEGRO_MUTEX *mutex;
/* Points to the parent object's mutex. It is NULL if
* the sample is not directly or indirectly attached
* to a voice.
*/
sample_parent_t parent;
/* The object that this sample is attached to, if any.
*/
};
void _al_kcm_destroy_sample(ALLEGRO_SAMPLE_INSTANCE *sample, bool unregister);
void _al_kcm_stream_set_mutex(ALLEGRO_SAMPLE_INSTANCE *stream, ALLEGRO_MUTEX *mutex);
void _al_kcm_detach_from_parent(ALLEGRO_SAMPLE_INSTANCE *spl);
typedef size_t (*stream_callback_t)(ALLEGRO_AUDIO_STREAM *, void *, size_t);
typedef void (*unload_feeder_t)(ALLEGRO_AUDIO_STREAM *);
typedef bool (*rewind_feeder_t)(ALLEGRO_AUDIO_STREAM *);
typedef bool (*seek_feeder_t)(ALLEGRO_AUDIO_STREAM *, double);
typedef double (*get_feeder_position_t)(ALLEGRO_AUDIO_STREAM *);
typedef double (*get_feeder_length_t)(ALLEGRO_AUDIO_STREAM *);
typedef bool (*set_feeder_loop_t)(ALLEGRO_AUDIO_STREAM *, double, double);
struct ALLEGRO_AUDIO_STREAM {
ALLEGRO_SAMPLE_INSTANCE spl;
/* ALLEGRO_AUDIO_STREAM is derived from
* ALLEGRO_SAMPLE_INSTANCE.
*/
unsigned int buf_count;
/* The stream buffer is divided into a number of
* fragments; this is the number of fragments.
*/
void *main_buffer;
/* Pointer to a single buffer big enough to hold all
* the fragments. Each fragment has additional samples
* at the start for linear/cubic interpolation.
*/
void **pending_bufs;
void **used_bufs;
/* Arrays of offsets into the main_buffer.
* The arrays are each 'buf_count' long.
*
* 'pending_bufs' holds pointers to fragments supplied
* by the user which are yet to be handed off to the
* audio driver.
*
* 'used_bufs' holds pointers to fragments which
* have been sent to the audio driver and so are
* ready to receive new data.
*/
volatile bool is_draining;
/* Set to true if sample data is not going to be passed
* to the stream any more. The stream must change its
* playing state to false after all buffers have been
* played.
*/
ALLEGRO_THREAD *feed_thread;
volatile bool quit_feed_thread;
unload_feeder_t unload_feeder;
rewind_feeder_t rewind_feeder;
seek_feeder_t seek_feeder;
get_feeder_position_t get_feeder_position;
get_feeder_length_t get_feeder_length;
set_feeder_loop_t set_feeder_loop;
stream_callback_t feeder;
/* If ALLEGRO_AUDIO_STREAM has been created by
* al_load_audio_stream(), the stream will be fed
* by a thread using the 'feeder' callback. Such
* streams don't need to be fed by the user.
*/
void *extra;
/* Extra data for use by the flac/vorbis addons. */
};
bool _al_kcm_refill_stream(ALLEGRO_AUDIO_STREAM *stream);
typedef void (*postprocess_callback_t)(void *buf, unsigned int samples,
void *userdata);
/* ALLEGRO_MIXER is derived from ALLEGRO_SAMPLE_INSTANCE. Certain internal functions and
* pointers may take either object type, and such things are explicitly noted.
* This is never exposed to the user, though. The sample object's read method
* will be set to a different function that will call the read method of all
* attached streams (which may be a sample, or another mixer).
*/
struct ALLEGRO_MIXER {
ALLEGRO_SAMPLE_INSTANCE ss;
/* ALLEGRO_MIXER is derived from ALLEGRO_SAMPLE_INSTANCE. */
ALLEGRO_MIXER_QUALITY quality;
postprocess_callback_t postprocess_callback;
void *pp_callback_userdata;
_AL_VECTOR streams;
/* Vector of ALLEGRO_SAMPLE_INSTANCE*. Holds the list of
* streams being mixed together.
*/
};
extern void _al_kcm_mixer_rejig_sample_matrix(ALLEGRO_MIXER *mixer,
ALLEGRO_SAMPLE_INSTANCE *spl);
extern void _al_kcm_mixer_read(void *source, void **buf, unsigned int *samples,
ALLEGRO_AUDIO_DEPTH buffer_depth, size_t dest_maxc);
typedef enum {
ALLEGRO_NO_ERROR = 0,
ALLEGRO_INVALID_PARAM = 1,
ALLEGRO_INVALID_OBJECT = 2,
ALLEGRO_GENERIC_ERROR = 255
} AL_ERROR_ENUM;
extern void _al_set_error(int error, char* string);
/* Supposedly internal */
ALLEGRO_KCM_AUDIO_FUNC(int, _al_kcm_get_silence, (ALLEGRO_AUDIO_DEPTH depth));
ALLEGRO_KCM_AUDIO_FUNC(void*, _al_kcm_feed_stream, (ALLEGRO_THREAD *self, void *vstream));
/* Helper to emit an event that the stream has got a buffer ready to be refilled. */
void _al_kcm_emit_stream_events(ALLEGRO_AUDIO_STREAM *stream);
void _al_kcm_init_destructors(void);
void _al_kcm_shutdown_destructors(void);
void _al_kcm_register_destructor(void *object, void (*func)(void*));
void _al_kcm_unregister_destructor(void *object);
void _al_kcm_foreach_destructor(
void (*callback)(void *object, void (*func)(void *), void *udata),
void *userdata);
ALLEGRO_KCM_AUDIO_FUNC(void, _al_kcm_shutdown_default_mixer, (void));
ALLEGRO_KCM_AUDIO_FUNC(ALLEGRO_CHANNEL_CONF, _al_count_to_channel_conf, (int num_channels));
ALLEGRO_KCM_AUDIO_FUNC(ALLEGRO_AUDIO_DEPTH, _al_word_size_to_depth_conf, (int word_size));
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,6 @@
/* #undef ALLEGRO_CFG_KCM_ALSA */
#define ALLEGRO_CFG_KCM_OPENAL
#define ALLEGRO_CFG_KCM_DSOUND
/* #undef ALLEGRO_CFG_KCM_OSS */
/* #undef ALLEGRO_CFG_KCM_PULSEAUDIO */
/* #undef ALLEGRO_CFG_KCM_AQUEUE */

View File

@@ -0,0 +1,141 @@
#ifndef __al_included_allegro5_aintern_bitmap_h
#define __al_included_allegro5_aintern_bitmap_h
#include "allegro5/bitmap.h"
#include "allegro5/bitmap_lock.h"
#include "allegro5/display.h"
#include "allegro5/transformations.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ALLEGRO_BITMAP_INTERFACE ALLEGRO_BITMAP_INTERFACE;
struct ALLEGRO_BITMAP
{
ALLEGRO_BITMAP_INTERFACE *vt;
ALLEGRO_DISPLAY *display;
int format;
int flags;
int w, h;
/*
* The number of bytes between a pixel at (x,y) and (x,y+1).
* This is larger than w * pixel_size if there is padding between lines.
*/
int pitch;
/*
* clip left, right, top, bottom
* Clip anything outside of this. cr/cb are exclusive, that is (0, 0, 1, 1)
* is the single pixel spawning a rectangle from floating point 0/0 to 1/1 -
* or in other words, the single pixel 0/0.
*
* There is always confusion as to whether cr/cb are exclusive, leading to
* subtle bugs. The suffixes are supposed to help with that.
*/
int cl;
int cr_excl;
int ct;
int cb_excl;
/*
* Locking info.
*
* locked - locked or not?
* lock_x/y - top left of the locked region
* lock_w/h - width and height of the locked region
* lock_flags - flags the region was locked with
* locked_region - a copy of the locked rectangle
*/
bool locked;
int lock_x;
int lock_y;
int lock_w;
int lock_h;
int lock_flags;
ALLEGRO_LOCKED_REGION locked_region;
/* Transformation for this bitmap */
ALLEGRO_TRANSFORM transform;
/* Info for sub-bitmaps */
ALLEGRO_BITMAP *parent;
int xofs;
int yofs;
/* A memory copy of the bitmap data. May be NULL for an empty bitmap. */
unsigned char *memory;
/* Size of the bitmap object. Used only by functions to convert bitmap
storage type. Can be missleading. */
size_t size;
bool preserve_texture;
};
struct ALLEGRO_BITMAP_INTERFACE
{
int id;
void (*draw_bitmap_region)(ALLEGRO_BITMAP *bitmap,
ALLEGRO_COLOR tint,float sx, float sy,
float sw, float sh, int flags);
/* After the memory-copy of the bitmap has been modified, need to call this
* to update the display-specific copy. E.g. with an OpenGL driver, this
* might create/update a texture. Returns false on failure.
*/
bool (*upload_bitmap)(ALLEGRO_BITMAP *bitmap);
/* If the display version of the bitmap has been modified, use this to update
* the memory copy accordingly. E.g. with an OpenGL driver, this might
* read the contents of an associated texture.
*/
void (*update_clipping_rectangle)(ALLEGRO_BITMAP *bitmap);
void (*destroy_bitmap)(ALLEGRO_BITMAP *bitmap);
ALLEGRO_LOCKED_REGION * (*lock_region)(ALLEGRO_BITMAP *bitmap,
int x, int y, int w, int h, int format,
int flags);
void (*unlock_region)(ALLEGRO_BITMAP *bitmap);
};
extern void (*_al_convert_funcs[ALLEGRO_NUM_PIXEL_FORMATS]
[ALLEGRO_NUM_PIXEL_FORMATS])(void *, int, void *, int,
int, int, int, int, int, int);
/* Bitmap conversion */
void _al_convert_bitmap_data(
void *src, int src_format, int src_pitch,
void *dst, int dst_format, int dst_pitch,
int sx, int sy, int dx, int dy,
int width, int height);
void _al_convert_to_memory_bitmap(ALLEGRO_BITMAP *bitmap);
void _al_convert_to_display_bitmap(ALLEGRO_BITMAP *bitmap);
#ifdef ALLEGRO_GP2XWIZ
/* Optimized blitters */
void _al_draw_bitmap_region_optimized_rgba_4444_to_rgb_565(
ALLEGRO_BITMAP *src, int sx, int sy, int sw, int sh,
ALLEGRO_BITMAP *dest, int dx, int dy, int flags);
void _al_draw_bitmap_region_optimized_rgb_565_to_rgb_565(
ALLEGRO_BITMAP *src, int sx, int sy, int sw, int sh,
ALLEGRO_BITMAP *dest, int dx, int dy, int flags);
void _al_draw_bitmap_region_optimized_rgba_4444_to_rgba_4444(
ALLEGRO_BITMAP *src, int sx, int sy, int sw, int sh,
ALLEGRO_BITMAP *dest, int dx, int dy, int flags);
#endif
/* Simple bitmap drawing */
/* _al_put_pixel was inadvertently exported in 5.0.x releases. */
AL_FUNC(void, _al_put_pixel, (ALLEGRO_BITMAP *bitmap, int x, int y, ALLEGRO_COLOR color));
/* Bitmap I/O */
void _al_init_iio_table(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,244 @@
#ifndef __al_included_allegro5_aintern_blend_h
#define __al_included_allegro5_aintern_blend_h
#include "allegro5/internal/aintern.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUC__
#define _AL_ALWAYS_INLINE inline __attribute__((always_inline))
#else
#define _AL_ALWAYS_INLINE INLINE
#endif
#define _AL_DEST_IS_ZERO \
(dst_mode == ALLEGRO_ZERO && dst_alpha == ALLEGRO_ZERO && \
op != ALLEGRO_DEST_MINUS_SRC && op_alpha != ALLEGRO_DEST_MINUS_SRC)
#define _AL_SRC_NOT_MODIFIED \
(src_mode == ALLEGRO_ONE && src_alpha == ALLEGRO_ONE)
#define _AL_SRC_NOT_MODIFIED_TINT_WHITE \
(_AL_SRC_NOT_MODIFIED && \
tint.r == 1.0f && tint.g == 1.0f && tint.b == 1.0f && tint.a == 1.0f)
#ifndef _AL_NO_BLEND_INLINE_FUNC
/* Only cares about alpha blending modes. */
static _AL_ALWAYS_INLINE float
get_alpha_factor(enum ALLEGRO_BLEND_MODE operation, float src_alpha, float dst_alpha)
{
switch (operation) {
case ALLEGRO_ZERO: return 0;
case ALLEGRO_ONE: return 1;
case ALLEGRO_ALPHA: return src_alpha;
case ALLEGRO_INVERSE_ALPHA: return 1 - src_alpha;
case ALLEGRO_SRC_COLOR: return src_alpha;
case ALLEGRO_DEST_COLOR: return dst_alpha;
case ALLEGRO_INVERSE_SRC_COLOR: return 1 - src_alpha;
case ALLEGRO_INVERSE_DEST_COLOR: return 1 - dst_alpha;
default:
ASSERT(false);
return 0; /* silence warning in release build */
}
}
/* Puts the blending factor in an ALLEGRO_COLOR object. */
static _AL_ALWAYS_INLINE void get_factor(enum ALLEGRO_BLEND_MODE operation,
const ALLEGRO_COLOR *source, const ALLEGRO_COLOR *dest,
ALLEGRO_COLOR *factor)
{
switch (operation) {
case ALLEGRO_ZERO:
factor->r = factor->g = factor->b = factor->a = 0;
break;
case ALLEGRO_ONE:
factor->r = factor->g = factor->b = factor->a = 1;
break;
case ALLEGRO_ALPHA:
factor->r = factor->g = factor->b = factor->a = source->a;
break;
case ALLEGRO_INVERSE_ALPHA:
factor->r = factor->g = factor->b = factor->a = 1 - source->a;
break;
case ALLEGRO_SRC_COLOR:
*factor = *source;
break;
case ALLEGRO_DEST_COLOR:
*factor = *dest;
break;
case ALLEGRO_INVERSE_SRC_COLOR:
factor->r = 1 - source->r;
factor->g = 1 - source->g;
factor->b = 1 - source->b;
factor->a = 1 - source->a;
break;
case ALLEGRO_INVERSE_DEST_COLOR:
factor->r = 1 - dest->r;
factor->g = 1 - dest->g;
factor->b = 1 - dest->b;
factor->a = 1 - dest->a;
break;
default:
ASSERT(false);
factor->r = factor->g = factor->b = factor->a = 0;
break;
}
}
/* Only call this if the blend modes are one of:
* ALLEGRO_ONE, ALLEGRO_ZERO, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA
*/
static _AL_ALWAYS_INLINE
void _al_blend_alpha_inline(
const ALLEGRO_COLOR *scol, const ALLEGRO_COLOR *dcol,
int op, int src_, int dst_, int aop, int asrc_, int adst_,
ALLEGRO_COLOR *result)
{
float asrc, adst;
float src, dst;
result->r = scol->r;
result->g = scol->g;
result->b = scol->b;
result->a = scol->a;
asrc = get_alpha_factor(asrc_, scol->a, dcol->a);
adst = get_alpha_factor(adst_, scol->a, dcol->a);
src = get_alpha_factor(src_, scol->a, dcol->a);
dst = get_alpha_factor(dst_, scol->a, dcol->a);
#define BLEND(c, src, dst) \
result->c = OP(result->c * src, dcol->c * dst);
switch (op) {
case ALLEGRO_ADD:
#define OP(x, y) _ALLEGRO_MIN(1, x + y)
BLEND(r, src, dst)
BLEND(g, src, dst)
BLEND(b, src, dst)
#undef OP
break;
case ALLEGRO_SRC_MINUS_DEST:
#define OP(x, y) _ALLEGRO_MAX(0, x - y)
BLEND(r, src, dst)
BLEND(g, src, dst)
BLEND(b, src, dst)
#undef OP
break;
case ALLEGRO_DEST_MINUS_SRC:
#define OP(x, y) _ALLEGRO_MAX(0, y - x)
BLEND(r, src, dst)
BLEND(g, src, dst)
BLEND(b, src, dst)
#undef OP
break;
}
switch (aop) {
case ALLEGRO_ADD:
#define OP(x, y) _ALLEGRO_MIN(1, x + y)
BLEND(a, asrc, adst)
#undef OP
break;
case ALLEGRO_SRC_MINUS_DEST:
#define OP(x, y) _ALLEGRO_MAX(0, x - y)
BLEND(a, asrc, adst)
#undef OP
break;
case ALLEGRO_DEST_MINUS_SRC:
#define OP(x, y) _ALLEGRO_MAX(0, y - x)
BLEND(a, asrc, adst)
#undef OP
break;
}
#undef BLEND
}
/* call this for general blending. its a little slower than just using alpha */
static _AL_ALWAYS_INLINE
void _al_blend_inline(
const ALLEGRO_COLOR *scol, const ALLEGRO_COLOR *dcol,
int op, int src_, int dst_, int aop, int asrc_, int adst_,
ALLEGRO_COLOR *result)
{
float asrc, adst;
ALLEGRO_COLOR src, dst;
result->r = scol->r;
result->g = scol->g;
result->b = scol->b;
result->a = scol->a;
asrc = get_alpha_factor(asrc_, scol->a, dcol->a);
adst = get_alpha_factor(adst_, scol->a, dcol->a);
get_factor(src_, scol, dcol, &src);
get_factor(dst_, scol, dcol, &dst);
#define BLEND(c, src, dst) \
result->c = OP(result->c * src.c, dcol->c * dst.c);
switch (op) {
case ALLEGRO_ADD:
#define OP(x, y) _ALLEGRO_MIN(1, x + y)
BLEND(r, src, dst)
BLEND(g, src, dst)
BLEND(b, src, dst)
#undef OP
break;
case ALLEGRO_SRC_MINUS_DEST:
#define OP(x, y) _ALLEGRO_MAX(0, x - y)
BLEND(r, src, dst)
BLEND(g, src, dst)
BLEND(b, src, dst)
#undef OP
break;
case ALLEGRO_DEST_MINUS_SRC:
#define OP(x, y) _ALLEGRO_MAX(0, y - x)
BLEND(r, src, dst)
BLEND(g, src, dst)
BLEND(b, src, dst)
#undef OP
break;
}
#undef BLEND
#define BLEND(c, src, dst) \
result->c = OP(result->c * src, dcol->c * dst);
switch (aop) {
case ALLEGRO_ADD:
#define OP(x, y) _ALLEGRO_MIN(1, x + y)
BLEND(a, asrc, adst)
#undef OP
break;
case ALLEGRO_SRC_MINUS_DEST:
#define OP(x, y) _ALLEGRO_MAX(0, x - y)
BLEND(a, asrc, adst)
#undef OP
break;
case ALLEGRO_DEST_MINUS_SRC:
#define OP(x, y) _ALLEGRO_MAX(0, y - x)
BLEND(a, asrc, adst)
#undef OP
break;
}
#undef BLEND
}
#endif
void _al_blend_memory(ALLEGRO_COLOR *src_color, ALLEGRO_BITMAP *dest,
int dx, int dy, ALLEGRO_COLOR *result);
#ifdef __cplusplus
}
#endif
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,29 @@
#ifndef __al_included_allegro5_aintern_config_h
#define __al_included_allegro5_aintern_config_h
#include "allegro5/internal/aintern_aatree.h"
struct ALLEGRO_CONFIG_ENTRY {
bool is_comment;
ALLEGRO_USTR *key; /* comment if is_comment is true */
ALLEGRO_USTR *value;
ALLEGRO_CONFIG_ENTRY *next;
};
struct ALLEGRO_CONFIG_SECTION {
ALLEGRO_USTR *name;
ALLEGRO_CONFIG_ENTRY *head;
ALLEGRO_CONFIG_ENTRY *last;
_AL_AATREE *tree;
ALLEGRO_CONFIG_SECTION *next;
};
struct ALLEGRO_CONFIG {
ALLEGRO_CONFIG_SECTION *head;
ALLEGRO_CONFIG_SECTION *last;
_AL_AATREE *tree;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
#ifndef __al_included_allegro5_aintern_debug_h
#define __al_included_allegro5_aintern_debug_h
#ifdef __cplusplus
extern "C" {
#endif
void _al_shutdown_logging(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,18 @@
#ifndef __al_included_allegro5_aintern_direct3d_h
#define __al_included_allegro5_aintern_direct3d_h
#ifdef __cplusplus
extern "C" {
#endif
struct ALLEGRO_DISPLAY_D3D;
AL_FUNC(void, _al_d3d_set_blender, (struct ALLEGRO_DISPLAY_D3D *disp));
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,148 @@
#ifndef __al_included_allegro5_aintern_display_h
#define __al_included_allegro5_aintern_display_h
#include "allegro5/allegro.h"
#include "allegro5/transformations.h"
#include "allegro5/display.h"
#include "allegro5/bitmap.h"
#include "allegro5/internal/aintern_events.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ALLEGRO_DISPLAY_INTERFACE ALLEGRO_DISPLAY_INTERFACE;
struct ALLEGRO_DISPLAY_INTERFACE
{
int id;
ALLEGRO_DISPLAY *(*create_display)(int w, int h);
void (*destroy_display)(ALLEGRO_DISPLAY *display);
bool (*set_current_display)(ALLEGRO_DISPLAY *d);
void (*unset_current_display)(ALLEGRO_DISPLAY *d);
void (*clear)(ALLEGRO_DISPLAY *d, ALLEGRO_COLOR *color);
void (*draw_pixel)(ALLEGRO_DISPLAY *d, float x, float y, ALLEGRO_COLOR *color);
void (*flip_display)(ALLEGRO_DISPLAY *d);
void (*update_display_region)(ALLEGRO_DISPLAY *d, int x, int y,
int width, int height);
bool (*acknowledge_resize)(ALLEGRO_DISPLAY *d);
bool (*resize_display)(ALLEGRO_DISPLAY *d, int width, int height);
void (*quick_size)(ALLEGRO_DISPLAY *d);
ALLEGRO_BITMAP *(*create_bitmap)(ALLEGRO_DISPLAY *d,
int w, int h);
void (*set_target_bitmap)(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bitmap);
ALLEGRO_BITMAP *(*get_backbuffer)(ALLEGRO_DISPLAY *d);
bool (*is_compatible_bitmap)(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bitmap);
void (*switch_out)(ALLEGRO_DISPLAY *display);
void (*switch_in)(ALLEGRO_DISPLAY *display);
void (*draw_memory_bitmap_region)(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bitmap,
float sx, float sy, float sw, float sh, int flags);
ALLEGRO_BITMAP *(*create_sub_bitmap)(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *parent,
int x, int y, int width, int height);
bool (*wait_for_vsync)(ALLEGRO_DISPLAY *display);
bool (*set_mouse_cursor)(ALLEGRO_DISPLAY *display,
ALLEGRO_MOUSE_CURSOR *cursor);
bool (*set_system_mouse_cursor)(ALLEGRO_DISPLAY *display,
ALLEGRO_SYSTEM_MOUSE_CURSOR cursor_id);
bool (*show_mouse_cursor)(ALLEGRO_DISPLAY *display);
bool (*hide_mouse_cursor)(ALLEGRO_DISPLAY *display);
void (*set_icons)(ALLEGRO_DISPLAY *display, int num_icons, ALLEGRO_BITMAP *bitmap[]);
void (*set_window_position)(ALLEGRO_DISPLAY *display, int x, int y);
void (*get_window_position)(ALLEGRO_DISPLAY *display, int *x, int *y);
bool (*set_display_flag)(ALLEGRO_DISPLAY *display, int flag, bool onoff);
void (*set_window_title)(ALLEGRO_DISPLAY *display, const char *title);
void (*flush_vertex_cache)(ALLEGRO_DISPLAY *d);
void* (*prepare_vertex_cache)(ALLEGRO_DISPLAY *d, int num_new_vertices);
void (*update_transformation)(ALLEGRO_DISPLAY* d, ALLEGRO_BITMAP *target);
void (*shutdown)(void);
};
struct ALLEGRO_OGL_EXTRAS;
typedef struct ALLEGRO_BLENDER
{
int blend_op;
int blend_source;
int blend_dest;
int blend_alpha_op;
int blend_alpha_source;
int blend_alpha_dest;
} ALLEGRO_BLENDER;
/* These are settings Allegro itself doesn't really care about on its
* own, but which users may want to specify for a display anyway.
*/
ALLEGRO_STATIC_ASSERT(aintern_display, ALLEGRO_DISPLAY_OPTIONS_COUNT <= 32);
typedef struct
{
int required, suggested; /* Bitfields. */
int settings[ALLEGRO_DISPLAY_OPTIONS_COUNT];
/* These are come in handy when creating a context. */
void *info;
int index, score;
} ALLEGRO_EXTRA_DISPLAY_SETTINGS;
struct ALLEGRO_DISPLAY
{
/* Must be first, so the display can be used as event source. */
ALLEGRO_EVENT_SOURCE es;
ALLEGRO_DISPLAY_INTERFACE *vt;
int refresh_rate;
int flags;
int w, h;
int backbuffer_format; /* ALLEGRO_PIXELFORMAT */
ALLEGRO_EXTRA_DISPLAY_SETTINGS extra_settings;
struct ALLEGRO_OGL_EXTRAS *ogl_extras;
_AL_VECTOR bitmaps; /* A list of bitmaps created for this display. */
int num_cache_vertices;
bool cache_enabled;
int vertex_cache_size;
void* vertex_cache;
uintptr_t cache_texture;
ALLEGRO_BLENDER cur_blender;
void (*display_invalidated)(ALLEGRO_DISPLAY*);
};
int _al_score_display_settings(ALLEGRO_EXTRA_DISPLAY_SETTINGS *eds, ALLEGRO_EXTRA_DISPLAY_SETTINGS *ref);
void _al_fill_display_settings(ALLEGRO_EXTRA_DISPLAY_SETTINGS *eds);
void _al_set_color_components(int format, ALLEGRO_EXTRA_DISPLAY_SETTINGS *eds, int importance);
int _al_deduce_color_format(ALLEGRO_EXTRA_DISPLAY_SETTINGS *eds);
int _al_display_settings_sorter(const void *p0, const void *p1);
void _al_destroy_display_bitmaps(ALLEGRO_DISPLAY *d);
/* This is called from the primitives addon. */
AL_FUNC(void, _al_set_display_invalidated_callback, (ALLEGRO_DISPLAY *display,
void (*display_invalidated)(ALLEGRO_DISPLAY*)));
/* Defined in tls.c */
bool _al_set_current_display_only(ALLEGRO_DISPLAY *display);
void _al_set_new_display_settings(ALLEGRO_EXTRA_DISPLAY_SETTINGS *settings);
ALLEGRO_EXTRA_DISPLAY_SETTINGS *_al_get_new_display_settings(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,13 @@
#ifndef __al_included_allegro5_internal_aintern_driver_h
#define __al_included_allegro5_internal_aintern_driver_h
typedef struct _AL_DRIVER_INFO /* info about a hardware driver */
{
int id; /* integer ID */
void *driver; /* the driver structure */
int autodetect; /* set to allow autodetection */
} _AL_DRIVER_INFO;
#endif

View File

@@ -0,0 +1,31 @@
#ifndef __al_included_allegro5_aintern_dtor_h
#define __al_included_allegro5_aintern_dtor_h
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _AL_DTOR_LIST _AL_DTOR_LIST;
AL_FUNC(_AL_DTOR_LIST *, _al_init_destructors, (void));
AL_FUNC(void, _al_push_destructor_owner, (void));
AL_FUNC(void, _al_pop_destructor_owner, (void));
AL_FUNC(void, _al_run_destructors, (_AL_DTOR_LIST *dtors));
AL_FUNC(void, _al_shutdown_destructors, (_AL_DTOR_LIST *dtors));
AL_FUNC(void, _al_register_destructor, (_AL_DTOR_LIST *dtors, void *object,
void (*func)(void*)));
AL_FUNC(void, _al_unregister_destructor, (_AL_DTOR_LIST *dtors, void *object));
AL_FUNC(void, _al_foreach_destructor, (_AL_DTOR_LIST *dtors,
void (*callback)(void *object, void (*func)(void *), void *udata),
void *userdata));
#ifdef __cplusplus
}
#endif
#endif
/* vim: set ts=8 sts=3 sw=3 et: */

View File

@@ -0,0 +1,48 @@
#ifndef __al_included_allegro5_aintern_events_h
#define __al_included_allegro5_aintern_events_h
#include "allegro5/internal/aintern_thread.h"
#include "allegro5/internal/aintern_vector.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ALLEGRO_EVENT_SOURCE_REAL ALLEGRO_EVENT_SOURCE_REAL;
struct ALLEGRO_EVENT_SOURCE_REAL
{
_AL_MUTEX mutex;
_AL_VECTOR queues;
intptr_t data;
};
typedef struct ALLEGRO_USER_EVENT_DESCRIPTOR
{
void (*dtor)(ALLEGRO_USER_EVENT *event);
int refcount;
} ALLEGRO_USER_EVENT_DESCRIPTOR;
AL_FUNC(void, _al_init_events, (void));
AL_FUNC(void, _al_event_source_init, (ALLEGRO_EVENT_SOURCE*));
AL_FUNC(void, _al_event_source_free, (ALLEGRO_EVENT_SOURCE*));
AL_FUNC(void, _al_event_source_lock, (ALLEGRO_EVENT_SOURCE*));
AL_FUNC(void, _al_event_source_unlock, (ALLEGRO_EVENT_SOURCE*));
AL_FUNC(void, _al_event_source_on_registration_to_queue, (ALLEGRO_EVENT_SOURCE*, ALLEGRO_EVENT_QUEUE*));
AL_FUNC(void, _al_event_source_on_unregistration_from_queue, (ALLEGRO_EVENT_SOURCE*, ALLEGRO_EVENT_QUEUE*));
AL_FUNC(bool, _al_event_source_needs_to_generate_event, (ALLEGRO_EVENT_SOURCE*));
AL_FUNC(void, _al_event_source_emit_event, (ALLEGRO_EVENT_SOURCE *, ALLEGRO_EVENT*));
AL_FUNC(void, _al_event_queue_push_event, (ALLEGRO_EVENT_QUEUE*, const ALLEGRO_EVENT*));
#ifdef __cplusplus
}
#endif
#endif
/* vi ts=8 sts=3 sw=3 et */

View File

@@ -0,0 +1,19 @@
#ifndef __al_included_allegro5_aintern_exitfunc_h
#define __al_included_allegro5_aintern_exitfunc_h
#ifdef __cplusplus
extern "C" {
#endif
/* list of functions to call at program cleanup */
AL_FUNC(void, _al_add_exit_func, (AL_METHOD(void, func, (void)), const char *desc));
AL_FUNC(void, _al_remove_exit_func, (AL_METHOD(void, func, (void))));
AL_FUNC(void, _al_run_exit_funcs, (void));
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,27 @@
#ifndef __al_included_allegro5_aintern_file_h
#define __al_included_allegro5_aintern_file_h
#ifdef __cplusplus
extern "C" {
#endif
extern const ALLEGRO_FILE_INTERFACE _al_file_interface_stdio;
#define ALLEGRO_UNGETC_SIZE 16
struct ALLEGRO_FILE
{
const ALLEGRO_FILE_INTERFACE *vtable;
void *userdata;
unsigned char ungetc[ALLEGRO_UNGETC_SIZE];
int ungetc_len;
};
#ifdef __cplusplus
}
#endif
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,16 @@
#ifndef __al_included_allegro5_aintern_float_h
#define __al_included_allegro5_aintern_float_h
/* This file used to contain a tricky function that sped up float->int
* conversions on x86 machines when the SSE instruction CVTTSS2SI wasn't
* available (or when SSE wasn't enabled in the compiler).
*
* However, it performed rounding instead of truncating like (int)f, which
* did cause problems. If an alternative is found we could define this
* macro once again.
*/
#define _al_fast_float_to_int(f) ((int)(f))
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,33 @@
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Internal File System Hook support.
*
* See readme.txt for copyright information.
*/
#ifndef __al_included_allegro5_aintern_fshook_h
#define __al_included_allegro5_aintern_fshook_h
#include "allegro5/base.h"
#ifdef __cplusplus
extern "C" {
#endif
extern struct ALLEGRO_FS_INTERFACE _al_fs_interface_stdio;
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,51 @@
#ifndef __al_included_allegro5_aintern_gp2xwiz_h
#define __al_included_allegro5_aintern_gp2xwiz_h
#include "allegro5/allegro.h"
#include "allegro5/allegro_opengl.h"
#include "allegro5/internal/aintern.h"
#include "allegro5/internal/aintern_system.h"
#include "allegro5/internal/aintern_bitmap.h"
#include "allegro5/platform/aintwiz.h"
#include "allegro5/internal/aintern_opengl.h"
#include <wiz/castor.h>
typedef struct ALLEGRO_SYSTEM_GP2XWIZ ALLEGRO_SYSTEM_GP2XWIZ;
typedef struct ALLEGRO_DISPLAY_GP2XWIZ_OGL ALLEGRO_DISPLAY_GP2XWIZ_OGL;
typedef struct ALLEGRO_DISPLAY_GP2XWIZ_FB ALLEGRO_DISPLAY_GP2XWIZ_FB;
struct ALLEGRO_SYSTEM_GP2XWIZ
{
ALLEGRO_SYSTEM system; /* This must be the first member, we "derive" from it. */
ALLEGRO_EXTRA_DISPLAY_SETTINGS extras;
};
/* This is our version of ALLEGRO_DISPLAY with driver specific extra data. */
struct ALLEGRO_DISPLAY_GP2XWIZ_OGL
{
ALLEGRO_DISPLAY display; /* This must be the first member. */
EGLDisplay egl_display;
EGLConfig egl_config;
EGLContext egl_context;
EGLSurface egl_surface;
NativeWindowType hNativeWnd;
};
/* This is our version of ALLEGRO_DISPLAY with driver specific extra data. */
struct ALLEGRO_DISPLAY_GP2XWIZ_FB
{
ALLEGRO_DISPLAY display; /* This must be the first member. */
ALLEGRO_BITMAP *backbuffer;
/*
* We create the backbuffer bitmap then points it's ->memory at
* lc_fb1 (initialized with libcastor. This is a backup of the
* ->memory as created by al_create_bitmap.
*/
unsigned char *screen_mem;
};
#endif

View File

@@ -0,0 +1,73 @@
#ifndef __al_included_allegro_aintern_image_h
#define __al_included_allegro_aintern_image_h
#include "allegro5/platform/alplatf.h"
#include "allegro5/internal/aintern_image_cfg.h"
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef ALLEGRO_CFG_WANT_NATIVE_IMAGE_LOADER
#ifdef ALLEGRO_IPHONE
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_iphone_load_image, (const char *filename));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_iphone_load_image_f, (ALLEGRO_FILE *f));
#endif
#ifdef ALLEGRO_MACOSX
ALLEGRO_IIO_FUNC(bool, _al_osx_register_image_loader, (void));
#endif
#endif
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_pcx, (const char *filename));
ALLEGRO_IIO_FUNC(bool, _al_save_pcx, (const char *filename, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_pcx_f, (ALLEGRO_FILE *f));
ALLEGRO_IIO_FUNC(bool, _al_save_pcx_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_bmp, (const char *filename));
ALLEGRO_IIO_FUNC(bool, _al_save_bmp, (const char *filename, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_bmp_f, (ALLEGRO_FILE *f));
ALLEGRO_IIO_FUNC(bool, _al_save_bmp_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_tga, (const char *filename));
ALLEGRO_IIO_FUNC(bool, _al_save_tga, (const char *filename, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_tga_f, (ALLEGRO_FILE *f));
ALLEGRO_IIO_FUNC(bool, _al_save_tga_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
#ifdef ALLEGRO_CFG_IIO_HAVE_GDIPLUS
ALLEGRO_IIO_FUNC(bool, _al_init_gdiplus, (void));
ALLEGRO_IIO_FUNC(void, _al_shutdown_gdiplus, (void));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_gdiplus_bitmap, (const char *filename));
ALLEGRO_IIO_FUNC(bool, _al_save_gdiplus_bitmap, (const char *filename, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_gdiplus_bitmap_f, (ALLEGRO_FILE *f));
ALLEGRO_IIO_FUNC(bool, _al_save_gdiplus_png_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(bool, _al_save_gdiplus_jpg_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(bool, _al_save_gdiplus_tif_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(bool, _al_save_gdiplus_gif_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
#endif
/* ALLEGRO_CFG_IIO_HAVE_PNG/JPG implies that "native" loaders aren't available. */
#ifdef ALLEGRO_CFG_IIO_HAVE_PNG
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_png, (const char *filename));
ALLEGRO_IIO_FUNC(bool, _al_save_png, (const char *filename, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_png_f, (ALLEGRO_FILE *f));
ALLEGRO_IIO_FUNC(bool, _al_save_png_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
#endif
#ifdef ALLEGRO_CFG_IIO_HAVE_JPG
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_jpg, (const char *filename));
ALLEGRO_IIO_FUNC(bool, _al_save_jpg, (const char *filename, ALLEGRO_BITMAP *bmp));
ALLEGRO_IIO_FUNC(ALLEGRO_BITMAP *, _al_load_jpg_f, (ALLEGRO_FILE *f));
ALLEGRO_IIO_FUNC(bool, _al_save_jpg_f, (ALLEGRO_FILE *f, ALLEGRO_BITMAP *bmp));
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,12 @@
#define ALLEGRO_CFG_WANT_NATIVE_IMAGE_LOADER
/* which libraries are present and needed? */
#define ALLEGRO_CFG_IIO_HAVE_GDIPLUS
/* #undef ALLEGRO_CFG_IIO_HAVE_GDIPLUS_LOWERCASE_H */
/* #undef ALLEGRO_CFG_IIO_HAVE_ANDROID */
/* #undef ALLEGRO_CFG_IIO_HAVE_PNG */
/* #undef ALLEGRO_CFG_IIO_HAVE_JPG */
/* which formats are supported and wanted? */
#define ALLEGRO_CFG_IIO_SUPPORT_PNG
#define ALLEGRO_CFG_IIO_SUPPORT_JPG

View File

@@ -0,0 +1,42 @@
#include "allegro5/allegro.h"
#include <allegro5/internal/aintern_system.h>
#include <allegro5/internal/aintern_display.h>
typedef struct ALLEGRO_SYSTEM_IPHONE {
ALLEGRO_SYSTEM system;
ALLEGRO_MUTEX *mutex;
ALLEGRO_COND *cond;
bool has_shutdown, wants_shutdown;
int visuals_count;
ALLEGRO_EXTRA_DISPLAY_SETTINGS **visuals;
} ALLEGRO_SYSTEM_IPHONE;
typedef struct ALLEGRO_DISPLAY_IPHONE {
ALLEGRO_DISPLAY display;
} ALLEGRO_DISPLAY_IPHONE;
void _al_iphone_init_path(void);
void _al_iphone_add_view(ALLEGRO_DISPLAY *d);
void _al_iphone_make_view_current(void);
void _al_iphone_flip_view(void);
void _al_iphone_reset_framebuffer(void);
ALLEGRO_SYSTEM_INTERFACE *_al_get_iphone_system_interface(void);
ALLEGRO_DISPLAY_INTERFACE *_al_get_iphone_display_interface(void);
ALLEGRO_PATH *_al_iphone_get_path(int id);
ALLEGRO_KEYBOARD_DRIVER *_al_get_iphone_keyboard_driver(void);
ALLEGRO_MOUSE_DRIVER *_al_get_iphone_mouse_driver(void);
ALLEGRO_JOYSTICK_DRIVER *_al_get_iphone_joystick_driver(void);
void _al_iphone_setup_opengl_view(ALLEGRO_DISPLAY *d);
void _al_iphone_generate_mouse_event(unsigned int type,
int x, int y, unsigned int button, ALLEGRO_DISPLAY *d);
void _al_iphone_update_visuals(void);
void _al_iphone_accelerometer_control(int frequency);
void _al_iphone_generate_joystick_event(float x, float y, float z);
void _al_iphone_await_termination(void);
void _al_iphone_get_screen_size(int *w, int *h);
void _al_iphone_translate_from_screen(ALLEGRO_DISPLAY *d, int *x, int *y);
void _al_iphone_translate_to_screen(ALLEGRO_DISPLAY *d, int *x, int *y);
void _al_iphone_clip(ALLEGRO_BITMAP const *bitmap, int x_1, int y_1, int x_2, int y_2);
float _al_iphone_get_screen_scale(void);

View File

@@ -0,0 +1,90 @@
#ifndef __al_included_allegro5_aintern_joystick_h
#define __al_included_allegro5_aintern_joystick_h
#include "allegro5/internal/aintern_driver.h"
#include "allegro5/internal/aintern_events.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ALLEGRO_JOYSTICK_DRIVER
{
int joydrv_id;
const char *joydrv_name;
const char *joydrv_desc;
const char *joydrv_ascii_name;
AL_METHOD(bool, init_joystick, (void));
AL_METHOD(void, exit_joystick, (void));
AL_METHOD(bool, reconfigure_joysticks, (void));
AL_METHOD(int, num_joysticks, (void));
AL_METHOD(ALLEGRO_JOYSTICK *, get_joystick, (int joyn));
AL_METHOD(void, release_joystick, (ALLEGRO_JOYSTICK *joy));
AL_METHOD(void, get_joystick_state, (ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state));
AL_METHOD(const char *, get_name, (ALLEGRO_JOYSTICK *joy));
AL_METHOD(bool, get_active, (ALLEGRO_JOYSTICK *joy));
} ALLEGRO_JOYSTICK_DRIVER;
AL_ARRAY(_AL_DRIVER_INFO, _al_joystick_driver_list);
/* macros for constructing the driver list */
#define _AL_BEGIN_JOYSTICK_DRIVER_LIST \
_AL_DRIVER_INFO _al_joystick_driver_list[] = \
{
#define _AL_END_JOYSTICK_DRIVER_LIST \
{ 0, NULL, false } \
};
/* information about a single joystick axis */
typedef struct _AL_JOYSTICK_AXIS_INFO
{
char *name;
} _AL_JOYSTICK_AXIS_INFO;
/* information about one or more axis (a slider or directional control) */
typedef struct _AL_JOYSTICK_STICK_INFO
{
int flags; /* bit-field */
int num_axes;
_AL_JOYSTICK_AXIS_INFO axis[_AL_MAX_JOYSTICK_AXES];
char *name;
} _AL_JOYSTICK_STICK_INFO;
/* information about a joystick button */
typedef struct _AL_JOYSTICK_BUTTON_INFO
{
const char *name;
} _AL_JOYSTICK_BUTTON_INFO;
/* information about an entire joystick */
typedef struct _AL_JOYSTICK_INFO
{
int num_sticks;
int num_buttons;
_AL_JOYSTICK_STICK_INFO stick[_AL_MAX_JOYSTICK_STICKS];
_AL_JOYSTICK_BUTTON_INFO button[_AL_MAX_JOYSTICK_BUTTONS];
} _AL_JOYSTICK_INFO;
struct ALLEGRO_JOYSTICK
{
_AL_JOYSTICK_INFO info;
};
void _al_generate_joystick_event(ALLEGRO_EVENT *event);
#ifdef __cplusplus
}
#endif
#endif
/* vi ts=8 sts=3 sw=3 et */

View File

@@ -0,0 +1,64 @@
#ifndef __al_included_allegro5_aintern_keyboard_h
#define __al_included_allegro5_aintern_keyboard_h
#include "allegro5/internal/aintern_driver.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ALLEGRO_KEYBOARD_DRIVER
{
int keydrv_id;
const char *keydrv_name;
const char *keydrv_desc;
const char *keydrv_ascii_name;
AL_METHOD(bool, init_keyboard, (void));
AL_METHOD(void, exit_keyboard, (void));
AL_METHOD(ALLEGRO_KEYBOARD*, get_keyboard, (void));
AL_METHOD(bool, set_keyboard_leds, (int leds));
AL_METHOD(const char *, keycode_to_name, (int keycode));
AL_METHOD(void, get_keyboard_state, (ALLEGRO_KEYBOARD_STATE *ret_state));
} ALLEGRO_KEYBOARD_DRIVER;
AL_ARRAY(_AL_DRIVER_INFO, _al_keyboard_driver_list);
AL_ARRAY(const char *, _al_keyboard_common_names);
int _al_parse_key_binding(const char *s, unsigned int *modifiers);
struct ALLEGRO_KEYBOARD
{
ALLEGRO_EVENT_SOURCE es;
};
/* Helpers for AL_KEYBOARD_STATE structures. */
#define _AL_KEYBOARD_STATE_KEY_DOWN(STATE, KEYCODE) \
(((STATE).__key_down__internal__[(KEYCODE) / 32] & (1 << ((KEYCODE) % 32)))\
? true : false)
#define _AL_KEYBOARD_STATE_SET_KEY_DOWN(STATE, KEYCODE) \
do { \
int kc = (KEYCODE); \
(STATE).__key_down__internal__[kc / 32] |= (1 << (kc % 32)); \
} while (0)
#define _AL_KEYBOARD_STATE_CLEAR_KEY_DOWN(STATE, KEYCODE) \
do { \
int kc = (KEYCODE); \
(STATE).__key_down__internal__[kc / 32] &= ~(1 << (kc % 32)); \
} while (0)
#ifdef __cplusplus
}
#endif
#endif
/* vi ts=8 sts=3 sw=3 et */

View File

@@ -0,0 +1,75 @@
#ifndef __al_included_allegro5_aintern_list_h
#define __al_included_allegro5_aintern_list_h
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _AL_LIST _AL_LIST;
typedef struct _AL_LIST_ITEM _AL_LIST_ITEM;
typedef void (*_AL_LIST_DTOR)(void* userdata);
typedef void (*_AL_LIST_ITEM_DTOR)(void* value, void* userdata);
AL_FUNC(_AL_LIST*, _al_list_create, (void));
AL_FUNC(_AL_LIST*, _al_list_create_static, (size_t capacity));
AL_FUNC(void, _al_list_destroy, (_AL_LIST* list));
AL_FUNC(void, _al_list_set_dtor, (_AL_LIST* list, _AL_LIST_DTOR dtor));
AL_FUNC(_AL_LIST_DTOR, _al_list_get_dtor, (_AL_LIST* list));
AL_FUNC(_AL_LIST_ITEM*, _al_list_push_front, (_AL_LIST* list, void* data));
AL_FUNC(_AL_LIST_ITEM*, _al_list_push_front_ex, (_AL_LIST* list, void* data, _AL_LIST_ITEM_DTOR dtor));
AL_FUNC(_AL_LIST_ITEM*, _al_list_push_back, (_AL_LIST* list, void* data));
AL_FUNC(_AL_LIST_ITEM*, _al_list_push_back_ex, (_AL_LIST* list, void* data, _AL_LIST_ITEM_DTOR dtor));
AL_FUNC(void, _al_list_pop_front, (_AL_LIST* list));
AL_FUNC(void, _al_list_pop_back, (_AL_LIST* list));
AL_FUNC(_AL_LIST_ITEM*, _al_list_insert_after, (_AL_LIST* list, _AL_LIST_ITEM* where, void* data));
AL_FUNC(_AL_LIST_ITEM*, _al_list_insert_after_ex, (_AL_LIST* list, _AL_LIST_ITEM* where, void* data, _AL_LIST_ITEM_DTOR dtor));
AL_FUNC(_AL_LIST_ITEM*, _al_list_insert_before, (_AL_LIST* list, _AL_LIST_ITEM* where, void* data));
AL_FUNC(_AL_LIST_ITEM*, _al_list_insert_before_ex, (_AL_LIST* list, _AL_LIST_ITEM* where, void* data, _AL_LIST_ITEM_DTOR dtor));
AL_FUNC(void, _al_list_erase, (_AL_LIST* list, _AL_LIST_ITEM* item));
AL_FUNC(void, _al_list_clear, (_AL_LIST* list));
AL_FUNC(void, _al_list_remove, (_AL_LIST* list, void* data));
AL_FUNC(bool, _al_list_is_empty, (_AL_LIST* list));
AL_FUNC(bool, _al_list_contains, (_AL_LIST* list, void* data));
AL_FUNC(_AL_LIST_ITEM*, _al_list_find_first, (_AL_LIST* list, void* data));
AL_FUNC(_AL_LIST_ITEM*, _al_list_find_last, (_AL_LIST* list, void* data));
AL_FUNC(_AL_LIST_ITEM*, _al_list_find_after, (_AL_LIST* list, _AL_LIST_ITEM* where, void* data));
AL_FUNC(_AL_LIST_ITEM*, _al_list_find_before, (_AL_LIST* list, _AL_LIST_ITEM* where, void* data));
AL_FUNC(size_t, _al_list_size, (_AL_LIST* list));
AL_FUNC(_AL_LIST_ITEM*, _al_list_at, (_AL_LIST* list, size_t index));
AL_FUNC(_AL_LIST_ITEM*, _al_list_front, (_AL_LIST* list));
AL_FUNC(_AL_LIST_ITEM*, _al_list_back, (_AL_LIST* list));
AL_FUNC(_AL_LIST_ITEM*, _al_list_next, (_AL_LIST* list, _AL_LIST_ITEM* item));
AL_FUNC(_AL_LIST_ITEM*, _al_list_previous, (_AL_LIST* list, _AL_LIST_ITEM* item));
AL_FUNC(_AL_LIST_ITEM*, _al_list_next_circular, (_AL_LIST* list, _AL_LIST_ITEM* item));
AL_FUNC(_AL_LIST_ITEM*, _al_list_previous_circular, (_AL_LIST* list, _AL_LIST_ITEM* item));
AL_FUNC(void*, _al_list_item_data, (_AL_LIST_ITEM* item));
AL_FUNC(void, _al_list_item_set_dtor, (_AL_LIST_ITEM* item, _AL_LIST_ITEM_DTOR dtor));
AL_FUNC(_AL_LIST_ITEM_DTOR, _al_list_item_get_dtor, (_AL_LIST_ITEM* item));
AL_FUNC(void, _al_list_set_user_data, (_AL_LIST* list, void* user_data));
AL_FUNC(void*, _al_list_get_user_data, (_AL_LIST* list));
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,20 @@
#ifndef __al_included_allegro5_aintern_memblit_h
#define __al_included_allegro5_aintern_memblit_h
#ifdef __cplusplus
extern "C" {
#endif
void _al_draw_bitmap_region_memory(ALLEGRO_BITMAP *bitmap,
ALLEGRO_COLOR tint,
int sx, int sy, int sw, int sh, int dx, int dy, int flags);
#ifdef __cplusplus
}
#endif
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,19 @@
#ifndef __al_included_allegro5_aintern_memdraw_h
#define __al_included_allegro5_aintern_memdraw_h
#ifdef __cplusplus
extern "C" {
#endif
void _al_clear_bitmap_by_locking(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR *color);
void _al_draw_pixel_memory(ALLEGRO_BITMAP *bmp, float x, float y, ALLEGRO_COLOR *color);
#ifdef __cplusplus
}
#endif
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,44 @@
#ifndef __al_included_allegro5_aintern_mouse_h
#define __al_included_allegro5_aintern_mouse_h
#include "allegro5/internal/aintern_driver.h"
#include "allegro5/internal/aintern_events.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ALLEGRO_MOUSE_DRIVER
{
int msedrv_id;
const char *msedrv_name;
const char *msedrv_desc;
const char *msedrv_ascii_name;
AL_METHOD(bool, init_mouse, (void));
AL_METHOD(void, exit_mouse, (void));
AL_METHOD(ALLEGRO_MOUSE*, get_mouse, (void));
AL_METHOD(unsigned int, get_mouse_num_buttons, (void));
AL_METHOD(unsigned int, get_mouse_num_axes, (void));
AL_METHOD(bool, set_mouse_xy, (ALLEGRO_DISPLAY *display, int x, int y));
AL_METHOD(bool, set_mouse_axis, (int which, int value));
AL_METHOD(void, get_mouse_state, (ALLEGRO_MOUSE_STATE *ret_state));
} ALLEGRO_MOUSE_DRIVER;
AL_ARRAY(_AL_DRIVER_INFO, _al_mouse_driver_list);
struct ALLEGRO_MOUSE
{
ALLEGRO_EVENT_SOURCE es;
};
#ifdef __cplusplus
}
#endif
#endif
/* vi ts=8 sts=3 sw=3 et */

View File

@@ -0,0 +1,53 @@
#ifndef __al_included_allegro_aintern_native_dialog_h
#define __al_included_allegro_aintern_native_dialog_h
typedef struct ALLEGRO_NATIVE_DIALOG ALLEGRO_NATIVE_DIALOG;
/* We could use different structs for the different dialogs. But why
* bother.
*/
struct ALLEGRO_NATIVE_DIALOG
{
ALLEGRO_USTR *title;
int flags;
/* Only used by file chooser. */
ALLEGRO_PATH *fc_initial_path;
size_t fc_path_count;
ALLEGRO_PATH **fc_paths;
ALLEGRO_USTR *fc_patterns;
/* Only used by message box. */
ALLEGRO_USTR *mb_heading;
ALLEGRO_USTR *mb_text;
ALLEGRO_USTR *mb_buttons;
int mb_pressed_button;
/* Only used by text log. */
ALLEGRO_THREAD *tl_thread;
ALLEGRO_COND *tl_text_cond;
ALLEGRO_MUTEX *tl_text_mutex;
ALLEGRO_USTR *tl_pending_text;
bool tl_init_error;
bool tl_done;
bool tl_have_pending;
ALLEGRO_EVENT_SOURCE tl_events;
void *tl_textview;
/* Only used by platform implementations. */
bool is_active;
void *window;
void *async_queue;
};
extern bool _al_init_native_dialog_addon(void);
extern void _al_shutdown_native_dialog_addon(void);
extern bool _al_show_native_file_dialog(ALLEGRO_DISPLAY *display,
ALLEGRO_NATIVE_DIALOG *fd);
extern int _al_show_native_message_box(ALLEGRO_DISPLAY *display,
ALLEGRO_NATIVE_DIALOG *fd);
extern bool _al_open_native_text_log(ALLEGRO_NATIVE_DIALOG *textlog);
extern void _al_close_native_text_log(ALLEGRO_NATIVE_DIALOG *textlog);
extern void _al_append_native_text_log(ALLEGRO_NATIVE_DIALOG *textlog);
#endif

View File

@@ -0,0 +1,3 @@
/* #undef ALLEGRO_CFG_NATIVE_DIALOG_GTK */
/* #undef ALLEGRO_CFG_NATIVE_DIALOG_OSX */
#define ALLEGRO_CFG_NATIVE_DIALOG_WINDOWS

View File

@@ -0,0 +1,143 @@
#ifndef __al_included_allegro5_aintern_opengl_h
#define __al_included_allegro5_aintern_opengl_h
#include "allegro5/opengl/gl_ext.h"
#include "allegro5/internal/aintern_bitmap.h"
#include "allegro5/internal/aintern_display.h"
enum {
_ALLEGRO_OPENGL_VERSION_0 = 0, /* dummy */
_ALLEGRO_OPENGL_VERSION_1_0 = 0x01000000,
_ALLEGRO_OPENGL_VERSION_1_1 = 0x01010000,
_ALLEGRO_OPENGL_VERSION_1_2 = 0x01020000,
_ALLEGRO_OPENGL_VERSION_1_2_1 = 0x01020100,
_ALLEGRO_OPENGL_VERSION_1_3 = 0x01030000,
_ALLEGRO_OPENGL_VERSION_1_4 = 0x01040000,
_ALLEGRO_OPENGL_VERSION_1_5 = 0x01050000,
_ALLEGRO_OPENGL_VERSION_2_0 = 0x02000000,
_ALLEGRO_OPENGL_VERSION_2_1 = 0x02010000,
_ALLEGRO_OPENGL_VERSION_3_0 = 0x03000000,
_ALLEGRO_OPENGL_VERSION_3_1 = 0x03010000,
_ALLEGRO_OPENGL_VERSION_3_2 = 0x03020000,
_ALLEGRO_OPENGL_VERSION_3_3 = 0x03030000,
_ALLEGRO_OPENGL_VERSION_4_0 = 0x04000000
};
#define ALLEGRO_MAX_OPENGL_FBOS 8
struct ALLEGRO_BITMAP_OGL;
enum {
FBO_INFO_UNUSED = 0,
FBO_INFO_TRANSIENT = 1, /* may be destroyed for another bitmap */
FBO_INFO_PERSISTENT = 2 /* exclusive to the owner bitmap */
};
typedef struct ALLEGRO_FBO_INFO
{
int fbo_state;
GLuint fbo;
struct ALLEGRO_BITMAP_OGL *owner;
double last_use_time;
} ALLEGRO_FBO_INFO;
typedef struct ALLEGRO_BITMAP_OGL
{
ALLEGRO_BITMAP bitmap; /* This must be the first member. */
/* Driver specifics. */
int true_w;
int true_h;
GLuint texture; /* 0 means, not uploaded yet. */
#if defined ALLEGRO_GP2XWIZ
EGLSurface pbuffer;
EGLContext context;
NativeWindowType pbuf_native_wnd;
bool changed;
#else
ALLEGRO_FBO_INFO *fbo_info;
#endif
unsigned char *lock_buffer;
float left, top, right, bottom; /* Texture coordinates. */
bool is_backbuffer; /* This is not a real bitmap, but the backbuffer. */
} ALLEGRO_BITMAP_OGL;
typedef struct OPENGL_INFO {
uint32_t version; /* OpenGL version */
int max_texture_size; /* Maximum texture size */
int is_voodoo3_and_under; /* Special cases for Voodoo 1-3 */
int is_voodoo; /* Special cases for Voodoo cards */
int is_matrox_g200; /* Special cases for Matrox G200 boards */
int is_ati_rage_pro; /* Special cases for ATI Rage Pro boards */
int is_ati_radeon_7000; /* Special cases for ATI Radeon 7000 */
int is_ati_r200_chip; /* Special cases for ATI card with chip R200 */
int is_mesa_driver; /* Special cases for MESA */
} OPENGL_INFO;
typedef struct ALLEGRO_OGL_EXTRAS
{
/* A list of extensions supported by Allegro, for this context. */
ALLEGRO_OGL_EXT_LIST *extension_list;
/* A list of extension API, loaded by Allegro, for this context. */
ALLEGRO_OGL_EXT_API *extension_api;
/* Various info about OpenGL implementation. */
OPENGL_INFO ogl_info;
ALLEGRO_BITMAP_OGL *opengl_target;
ALLEGRO_BITMAP_OGL *backbuffer;
/* True if display resources are shared among displays. */
bool is_shared;
ALLEGRO_FBO_INFO fbos[ALLEGRO_MAX_OPENGL_FBOS];
} ALLEGRO_OGL_EXTRAS;
typedef struct ALLEGRO_OGL_BITMAP_VERTEX
{
float x, y;
float tx, ty;
float r, g, b, a;
} ALLEGRO_OGL_BITMAP_VERTEX;
/* extensions */
int _al_ogl_look_for_an_extension(const char *name, const GLubyte *extensions);
void _al_ogl_set_extensions(ALLEGRO_OGL_EXT_API *ext);
void _al_ogl_manage_extensions(ALLEGRO_DISPLAY *disp);
void _al_ogl_unmanage_extensions(ALLEGRO_DISPLAY *disp);
/* bitmap */
ALLEGRO_BITMAP *_al_ogl_create_bitmap(ALLEGRO_DISPLAY *d, int w, int h);
ALLEGRO_BITMAP *_al_ogl_create_sub_bitmap(ALLEGRO_DISPLAY *d, ALLEGRO_BITMAP *parent,
int x, int y, int w, int h);
/* common driver */
void _al_ogl_reset_fbo_info(ALLEGRO_FBO_INFO *info);
bool _al_ogl_create_persistent_fbo(ALLEGRO_BITMAP *bitmap);
ALLEGRO_FBO_INFO *_al_ogl_persist_fbo(ALLEGRO_DISPLAY *display,
ALLEGRO_FBO_INFO *transient_fbo_info);
void _al_ogl_setup_gl(ALLEGRO_DISPLAY *d);
void _al_ogl_set_target_bitmap(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bitmap);
void _al_ogl_setup_bitmap_clipping(const ALLEGRO_BITMAP *bitmap);
ALLEGRO_BITMAP *_al_ogl_get_backbuffer(ALLEGRO_DISPLAY *d);
ALLEGRO_BITMAP_OGL* _al_ogl_create_backbuffer(ALLEGRO_DISPLAY *disp);
void _al_ogl_destroy_backbuffer(ALLEGRO_BITMAP_OGL *b);
bool _al_ogl_resize_backbuffer(ALLEGRO_BITMAP_OGL *b, int w, int h);
struct ALLEGRO_DISPLAY_INTERFACE;
/* draw */
void _al_ogl_add_drawing_functions(struct ALLEGRO_DISPLAY_INTERFACE *vt);
AL_FUNC(bool, _al_opengl_set_blender, (ALLEGRO_DISPLAY *disp));
#endif

View File

@@ -0,0 +1,14 @@
#ifndef __al_included_allegro5_aintern_path_h
#define __al_included_allegro5_aintern_path_h
struct ALLEGRO_PATH {
ALLEGRO_USTR *drive;
ALLEGRO_USTR *filename;
_AL_VECTOR segments; /* vector of ALLEGRO_USTR * */
ALLEGRO_USTR *basename;
ALLEGRO_USTR *full_string;
};
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,473 @@
#ifndef __al_included_allegro5_aintern_pixels_h
#define __al_included_allegro5_aintern_pixels_h
#include "allegro5/internal/aintern_float.h"
#ifdef __cplusplus
extern "C" {
#endif
#define _AL_MAP_RGBA(_color, _r, _g, _b, _a) \
do { \
(_color).r = _al_u8_to_float[_r]; \
(_color).g = _al_u8_to_float[_g]; \
(_color).b = _al_u8_to_float[_b]; \
(_color).a = _al_u8_to_float[_a]; \
} while (0)
#define _AL_INLINE_GET_PIXEL(format, data, color, advance) \
do { \
switch (format) { \
case ALLEGRO_PIXEL_FORMAT_ARGB_8888: { \
uint32_t _gp_pixel = *(uint32_t *)(data); \
_AL_MAP_RGBA(color, \
(_gp_pixel & 0x00FF0000) >> 16, \
(_gp_pixel & 0x0000FF00) >> 8, \
(_gp_pixel & 0x000000FF) >> 0, \
(_gp_pixel & 0xFF000000) >> 24); \
if (advance) \
data += 4; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_RGBA_8888: { \
uint32_t _gp_pixel = *(uint32_t *)(data); \
_AL_MAP_RGBA(color, \
(_gp_pixel & 0xFF000000) >> 24, \
(_gp_pixel & 0x00FF0000) >> 16, \
(_gp_pixel & 0x0000FF00) >> 8, \
(_gp_pixel & 0x000000FF) >> 0); \
if (advance) \
data += 4; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_ARGB_4444: { \
uint16_t _gp_pixel = *(uint16_t *)(data); \
_AL_MAP_RGBA(color, \
_al_rgb_scale_4[(_gp_pixel & 0x0F00) >> 8], \
_al_rgb_scale_4[(_gp_pixel & 0x00F0) >> 4], \
_al_rgb_scale_4[(_gp_pixel & 0x000F)], \
_al_rgb_scale_4[(_gp_pixel & 0xF000) >> 12]); \
if (advance) \
data += 2; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_RGB_888: { \
uint32_t _gp_pixel = READ3BYTES(data); \
_AL_MAP_RGBA(color, \
(_gp_pixel & 0xFF0000) >> 16, \
(_gp_pixel & 0x00FF00) >> 8, \
(_gp_pixel & 0x0000FF) >> 0, \
255); \
if (advance) \
data += 3; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_RGB_565: { \
uint16_t _gp_pixel = *(uint16_t *)(data); \
_AL_MAP_RGBA(color, \
_al_rgb_scale_5[(_gp_pixel & 0xF800) >> 11], \
_al_rgb_scale_6[(_gp_pixel & 0x07E0) >> 5], \
_al_rgb_scale_5[(_gp_pixel & 0x001F)], \
255); \
if (advance) \
data += 2; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_RGB_555: { \
uint16_t _gp_pixel = *(uint16_t *)(data); \
_AL_MAP_RGBA(color, \
_al_rgb_scale_5[(_gp_pixel & 0x7C00) >> 10], \
_al_rgb_scale_5[(_gp_pixel & 0x03E0) >> 5], \
_al_rgb_scale_5[(_gp_pixel & 0x001F)], \
255); \
if (advance) \
data += 2; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_RGBA_5551: { \
uint16_t _gp_pixel = *(uint16_t *)(data); \
_AL_MAP_RGBA(color, \
_al_rgb_scale_5[(_gp_pixel & 0xF800) >> 11], \
_al_rgb_scale_5[(_gp_pixel & 0x07C0) >> 6], \
_al_rgb_scale_5[(_gp_pixel & 0x003E) >> 1], \
_al_rgb_scale_1[_gp_pixel & 1]); \
if (advance) \
data += 2; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_ARGB_1555: { \
uint16_t _gp_pixel = *(uint16_t *)(data); \
_AL_MAP_RGBA(color, \
_al_rgb_scale_5[(_gp_pixel & 0x7C00) >> 10], \
_al_rgb_scale_5[(_gp_pixel & 0x03E0) >> 5], \
_al_rgb_scale_5[(_gp_pixel & 0x001F)], \
_al_rgb_scale_1[(_gp_pixel & 0x8000) >> 15]); \
if (advance) \
data += 2; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_ABGR_8888: { \
uint32_t _gp_pixel = *(uint32_t *)(data); \
_AL_MAP_RGBA(color, \
(_gp_pixel & 0x000000FF) >> 0, \
(_gp_pixel & 0x0000FF00) >> 8, \
(_gp_pixel & 0x00FF0000) >> 16, \
(_gp_pixel & 0xFF000000) >> 24); \
if (advance) \
data += 4; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_XBGR_8888: { \
uint32_t _gp_pixel = *(uint32_t *)(data); \
_AL_MAP_RGBA(color, \
(_gp_pixel & 0x000000FF) >> 0, \
(_gp_pixel & 0x0000FF00) >> 8, \
(_gp_pixel & 0x00FF0000) >> 16, \
255); \
if (advance) \
data += 4; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_BGR_888: { \
uint32_t _gp_pixel = READ3BYTES(data); \
_AL_MAP_RGBA(color, \
(_gp_pixel & 0x000000FF) >> 0, \
(_gp_pixel & 0x0000FF00) >> 8, \
(_gp_pixel & 0x00FF0000) >> 16, \
255); \
if (advance) \
data += 4; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_BGR_565: { \
uint16_t _gp_pixel = *(uint16_t *)(data); \
_AL_MAP_RGBA(color, \
_al_rgb_scale_5[(_gp_pixel & 0x001F)], \
_al_rgb_scale_6[(_gp_pixel & 0x07E0) >> 5], \
_al_rgb_scale_5[(_gp_pixel & 0xF800) >> 11], \
255); \
if (advance) \
data += 2; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_BGR_555: { \
uint16_t _gp_pixel = *(uint16_t *)(data); \
_AL_MAP_RGBA(color, \
_al_rgb_scale_5[(_gp_pixel & 0x001F)], \
_al_rgb_scale_5[(_gp_pixel & 0x03E0) >> 5], \
_al_rgb_scale_5[(_gp_pixel & 0x7C00) >> 10], \
255); \
if (advance) \
data += 2; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_RGBX_8888: { \
uint32_t _gp_pixel = *(uint32_t *)(data); \
_AL_MAP_RGBA(color, \
(_gp_pixel & 0xFF000000) >> 24, \
(_gp_pixel & 0x00FF0000) >> 16, \
(_gp_pixel & 0x0000FF00) >> 8, \
255); \
if (advance) \
data += 4; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_XRGB_8888: { \
uint32_t _gp_pixel = *(uint32_t *)(data); \
_AL_MAP_RGBA(color, \
(_gp_pixel & 0x00FF0000) >> 16, \
(_gp_pixel & 0x0000FF00) >> 8, \
(_gp_pixel & 0x000000FF), \
255); \
if (advance) \
data += 4; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_ABGR_F32: { \
float *f = (float *)data; \
color.r = f[0]; \
color.g = f[1]; \
color.b = f[2]; \
color.a = f[3]; \
if (advance) \
data += 4 * sizeof(float); \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE: { \
uint8_t *p = (uint8_t *)data; \
_AL_MAP_RGBA(color, *p, *(p + 1), *(p + 2), *(p + 3)); \
if (advance) \
data += 4; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_RGBA_4444: { \
uint16_t _gp_pixel = *(uint16_t *)(data); \
_AL_MAP_RGBA(color, \
_al_rgb_scale_4[(_gp_pixel & 0xF000) >> 12], \
_al_rgb_scale_4[(_gp_pixel & 0x0F00) >> 8], \
_al_rgb_scale_4[(_gp_pixel & 0x00F0) >> 4], \
_al_rgb_scale_4[(_gp_pixel & 0x000F)]); \
if (advance) \
data += 2; \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_ANY: \
case ALLEGRO_PIXEL_FORMAT_ANY_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_15_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_16_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_16_WITH_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_24_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_32_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA: \
ALLEGRO_ERROR("INLINE_GET got fake _gp_pixel format: %d\n", format); \
abort(); \
break; \
\
case ALLEGRO_NUM_PIXEL_FORMATS: \
default: \
ALLEGRO_ERROR("INLINE_GET got non _gp_pixel format: %d\n", format); \
abort(); \
break; \
} \
} while (0)
#define _AL_INLINE_PUT_PIXEL(format, data, color, advance) \
do { \
uint32_t _pp_pixel; \
switch (format) { \
case ALLEGRO_PIXEL_FORMAT_ARGB_8888: \
_pp_pixel = _al_fast_float_to_int(color.a * 255) << 24; \
_pp_pixel |= _al_fast_float_to_int(color.r * 255) << 16; \
_pp_pixel |= _al_fast_float_to_int(color.g * 255) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.b * 255); \
*(uint32_t *)(data) = _pp_pixel; \
if (advance) \
data += 4; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_RGBA_8888: \
_pp_pixel = _al_fast_float_to_int(color.r * 255) << 24; \
_pp_pixel |= _al_fast_float_to_int(color.g * 255) << 16; \
_pp_pixel |= _al_fast_float_to_int(color.b * 255) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.a * 255); \
*(uint32_t *)(data) = _pp_pixel; \
if (advance) \
data += 4; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_ARGB_4444: \
_pp_pixel = _al_fast_float_to_int(color.a * 15) << 12; \
_pp_pixel |= _al_fast_float_to_int(color.r * 15) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.g * 15) << 4; \
_pp_pixel |= _al_fast_float_to_int(color.b * 15); \
*(uint16_t *)(data) = _pp_pixel; \
if (advance) \
data += 2; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_RGB_888: \
_pp_pixel = _al_fast_float_to_int(color.r * 255) << 16; \
_pp_pixel |= _al_fast_float_to_int(color.g * 255) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.b * 255); \
WRITE3BYTES(data, _pp_pixel); \
if (advance) \
data += 3; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_RGB_565: \
_pp_pixel = _al_fast_float_to_int(color.r * 0x1f) << 11; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0x3f) << 5; \
_pp_pixel |= _al_fast_float_to_int(color.b * 0x1f); \
*(uint16_t *)(data) = _pp_pixel; \
if (advance) \
data += 2; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_RGB_555: \
_pp_pixel = _al_fast_float_to_int(color.r * 0x1f) << 10; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0x1f) << 5; \
_pp_pixel |= _al_fast_float_to_int(color.b * 0x1f); \
*(uint16_t *)(data) = _pp_pixel; \
if (advance) \
data += 2; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_RGBA_5551: \
_pp_pixel = _al_fast_float_to_int(color.r * 0x1f) << 11; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0x1f) << 6; \
_pp_pixel |= _al_fast_float_to_int(color.b * 0x1f) << 1; \
_pp_pixel |= _al_fast_float_to_int(color.a); \
*(uint16_t *)(data) = _pp_pixel; \
if (advance) \
data += 2; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_ARGB_1555: \
_pp_pixel = _al_fast_float_to_int(color.a) << 15; \
_pp_pixel |= _al_fast_float_to_int(color.r * 0x1f) << 10; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0x1f) << 5; \
_pp_pixel |= _al_fast_float_to_int(color.b * 0x1f); \
*(uint16_t *)(data) = _pp_pixel; \
if (advance) \
data += 2; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_ABGR_8888: \
_pp_pixel = _al_fast_float_to_int(color.a * 0xff) << 24; \
_pp_pixel |= _al_fast_float_to_int(color.b * 0xff) << 16; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0xff) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.r * 0xff); \
*(uint32_t *)(data) = _pp_pixel; \
if (advance) \
data += 4; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_XBGR_8888: \
_pp_pixel = 0xff000000; \
_pp_pixel |= _al_fast_float_to_int(color.b * 0xff) << 16; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0xff) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.r * 0xff); \
*(uint32_t *)(data) = _pp_pixel; \
if (advance) \
data += 4; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_BGR_888: \
_pp_pixel = _al_fast_float_to_int(color.b * 0xff) << 16; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0xff) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.r * 0xff); \
WRITE3BYTES(data, _pp_pixel); \
if (advance) \
data += 3; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_BGR_565: \
_pp_pixel = _al_fast_float_to_int(color.b * 0x1f) << 11; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0x3f) << 5; \
_pp_pixel |= _al_fast_float_to_int(color.r * 0x1f); \
*(uint16_t *)(data) = _pp_pixel; \
if (advance) \
data += 2; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_BGR_555: \
_pp_pixel = _al_fast_float_to_int(color.b * 0x1f) << 10; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0x1f) << 5; \
_pp_pixel |= _al_fast_float_to_int(color.r * 0x1f); \
*(uint16_t *)(data) = _pp_pixel; \
if (advance) \
data += 2; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_RGBX_8888: \
_pp_pixel = 0xff; \
_pp_pixel |= _al_fast_float_to_int(color.r * 0xff) << 24; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0xff) << 16; \
_pp_pixel |= _al_fast_float_to_int(color.b * 0xff) << 8; \
*(uint32_t *)(data) = _pp_pixel; \
if (advance) \
data += 4; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_XRGB_8888: \
_pp_pixel = 0xff000000; \
_pp_pixel |= _al_fast_float_to_int(color.r * 0xff) << 16; \
_pp_pixel |= _al_fast_float_to_int(color.g * 0xff) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.b * 0xff); \
*(uint32_t *)(data) = _pp_pixel; \
if (advance) \
data += 4; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_ABGR_F32: { \
float *f = (float *)data; \
f[0] = color.r; \
f[1] = color.g; \
f[2] = color.b; \
f[3] = color.a; \
if (advance) \
data += 4 * sizeof(float); \
break; \
} \
\
case ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE: \
*((uint8_t *)data + 0) = _al_fast_float_to_int(color.r * 0xff); \
*((uint8_t *)data + 1) = _al_fast_float_to_int(color.g * 0xff); \
*((uint8_t *)data + 2) = _al_fast_float_to_int(color.b * 0xff); \
*((uint8_t *)data + 3) = _al_fast_float_to_int(color.a * 0xff); \
if (advance) \
data += 4; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_RGBA_4444: \
_pp_pixel = _al_fast_float_to_int(color.a * 15); \
_pp_pixel |= _al_fast_float_to_int(color.r * 15) << 12; \
_pp_pixel |= _al_fast_float_to_int(color.g * 15) << 8; \
_pp_pixel |= _al_fast_float_to_int(color.b * 15) << 4; \
*(uint16_t *)(data) = _pp_pixel; \
if (advance) \
data += 2; \
break; \
\
case ALLEGRO_PIXEL_FORMAT_ANY: \
case ALLEGRO_PIXEL_FORMAT_ANY_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_15_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_16_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_16_WITH_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_24_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_32_NO_ALPHA: \
case ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA: \
ALLEGRO_ERROR("INLINE_PUT got fake _pp_pixel format: %d\n", format); \
abort(); \
break; \
\
case ALLEGRO_NUM_PIXEL_FORMATS: \
ALLEGRO_ERROR("INLINE_PUT got non _pp_pixel format: %d\n", format); \
abort(); \
break; \
} \
} while (0)
AL_ARRAY(int, _al_rgb_scale_1);
AL_ARRAY(int, _al_rgb_scale_4);
AL_ARRAY(int, _al_rgb_scale_5);
AL_ARRAY(int, _al_rgb_scale_6);
AL_ARRAY(float, _al_u8_to_float);
void _al_init_pixels(void);
bool _al_pixel_format_has_alpha(int format);
bool _al_pixel_format_is_real(int format);
int _al_get_real_pixel_format(ALLEGRO_DISPLAY *display, int format);
char const *_al_pixel_format_name(ALLEGRO_PIXEL_FORMAT format);
#ifdef __cplusplus
}
#endif
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,13 @@
#ifndef __al_included_allegro5_aintern_prim_h
#define __al_included_allegro5_aintern_prim_h
int _al_bitmap_region_is_locked(ALLEGRO_BITMAP* bmp, int x1, int y1, int x2, int y2);
struct ALLEGRO_VERTEX_DECL {
ALLEGRO_VERTEX_ELEMENT* elements;
int stride;
void* d3d_decl;
void* d3d_dummy_shader;
};
#endif

View File

@@ -0,0 +1,21 @@
#ifndef __al_included_allegro5_aintern_prim_directx_h
#define __al_included_allegro5_aintern_prim_directx_h
struct ALLEGRO_BITMAP;
struct ALLEGRO_VERTEX;
int _al_draw_prim_directx(ALLEGRO_BITMAP* target, ALLEGRO_BITMAP* texture, const void* vtxs, const ALLEGRO_VERTEX_DECL* decl, int start, int end, int type);
int _al_draw_prim_indexed_directx(ALLEGRO_BITMAP* target, ALLEGRO_BITMAP* texture, const void* vtxs, const ALLEGRO_VERTEX_DECL* decl, const int* indices, int num_vtx, int type);
void _al_set_d3d_decl(ALLEGRO_DISPLAY* display, ALLEGRO_VERTEX_DECL* ret);
bool _al_init_d3d_driver(void);
void _al_shutdown_d3d_driver(void);
void* _al_create_default_shader(void* dev);
void _al_setup_default_shader(void* dev, void* shader);
void _al_setup_shader(void* dev, const ALLEGRO_VERTEX_DECL* decl);
void _al_create_shader(void* dev, ALLEGRO_VERTEX_DECL* decl);
void _al_set_texture_matrix(void* dev, float* mat);
#endif

View File

@@ -0,0 +1,10 @@
#ifndef __al_included_allegro5_aintern_prim_opengl_h
#define __al_included_allegro5_aintern_prim_opengl_h
struct ALLEGRO_BITMAP;
struct ALLEGRO_VERTEX;
int _al_draw_prim_opengl(ALLEGRO_BITMAP* target, ALLEGRO_BITMAP* texture, const void* vtxs, const ALLEGRO_VERTEX_DECL* decl, int start, int end, int type);
int _al_draw_prim_indexed_opengl(ALLEGRO_BITMAP *target, ALLEGRO_BITMAP* texture, const void* vtxs, const ALLEGRO_VERTEX_DECL* decl, const int* indices, int num_vtx, int type);
#endif

View File

@@ -0,0 +1,13 @@
#ifndef __al_included_allegro5_aintern_prim_soft_h
#define __al_included_allegro5_aintern_prim_soft_h
struct ALLEGRO_BITMAP;
struct ALLEGRO_VERTEX;
int _al_draw_prim_soft(ALLEGRO_BITMAP* texture, const void* vtxs, const ALLEGRO_VERTEX_DECL* decl, int start, int end, int type);
int _al_draw_prim_indexed_soft(ALLEGRO_BITMAP* texture, const void* vtxs, const ALLEGRO_VERTEX_DECL* decl, const int* indices, int num_vtx, int type);
void _al_line_2d(ALLEGRO_BITMAP* texture, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2);
void _al_point_2d(ALLEGRO_BITMAP* texture, ALLEGRO_VERTEX* v);
#endif

View File

@@ -0,0 +1,60 @@
#ifndef __al_included_allegro5_aintern_system_h
#define __al_included_allegro5_aintern_system_h
#include "allegro5/system.h"
#include "allegro5/internal/aintern_display.h"
#include "allegro5/internal/aintern_dtor.h"
#include "allegro5/internal/aintern_events.h"
#include "allegro5/internal/aintern_joystick.h"
#include "allegro5/internal/aintern_keyboard.h"
#include "allegro5/internal/aintern_mouse.h"
#include "allegro5/internal/aintern_vector.h"
typedef struct ALLEGRO_SYSTEM_INTERFACE ALLEGRO_SYSTEM_INTERFACE;
struct ALLEGRO_SYSTEM_INTERFACE
{
int id;
ALLEGRO_SYSTEM *(*initialize)(int flags);
ALLEGRO_DISPLAY_INTERFACE *(*get_display_driver)(void);
ALLEGRO_KEYBOARD_DRIVER *(*get_keyboard_driver)(void);
ALLEGRO_MOUSE_DRIVER *(*get_mouse_driver)(void);
ALLEGRO_JOYSTICK_DRIVER *(*get_joystick_driver)(void);
int (*get_num_display_modes)(void);
ALLEGRO_DISPLAY_MODE *(*get_display_mode)(int index, ALLEGRO_DISPLAY_MODE *mode);
void (*shutdown_system)(void);
int (*get_num_video_adapters)(void);
bool (*get_monitor_info)(int adapter, ALLEGRO_MONITOR_INFO *info);
ALLEGRO_MOUSE_CURSOR *(*create_mouse_cursor)(ALLEGRO_BITMAP *bmp, int x_focus, int y_focus);
void (*destroy_mouse_cursor)(ALLEGRO_MOUSE_CURSOR *cursor);
bool (*get_cursor_position)(int *ret_x, int *ret_y);
bool (*grab_mouse)(ALLEGRO_DISPLAY *display);
bool (*ungrab_mouse)(void);
ALLEGRO_PATH *(*get_path)(int id);
bool (*inhibit_screensaver)(bool inhibit);
void (*thread_init)(ALLEGRO_THREAD *thread);
void (*thread_exit)(ALLEGRO_THREAD *thread);
void *(*open_library)(const char *filename);
void *(*import_symbol)(void *library, const char *symbol);
void (*close_library)(void *handle);
};
struct ALLEGRO_SYSTEM
{
ALLEGRO_SYSTEM_INTERFACE *vt;
_AL_VECTOR displays; /* Keep a list of all displays attached to us. */
ALLEGRO_CONFIG *config;
ALLEGRO_PATH *user_exe_path;
bool installed;
};
AL_FUNC(void, _al_register_system_interfaces, (void));
AL_VAR(_AL_VECTOR, _al_system_interfaces);
AL_VAR(_AL_DTOR_LIST *, _al_dtor_list);
AL_FUNC(void *, _al_open_library, (const char *filename));
AL_FUNC(void *, _al_import_symbol, (void *library, const char *symbol));
AL_FUNC(void, _al_close_library, (void *library));
#endif

View File

@@ -0,0 +1,52 @@
#ifndef __al_included_allegro5_aintern_thread_h
#define __al_included_allegro5_aintern_thread_h
#include ALLEGRO_INTERNAL_THREAD_HEADER
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _AL_THREAD _AL_THREAD;
typedef struct _AL_MUTEX _AL_MUTEX;
typedef struct _AL_COND _AL_COND;
AL_FUNC(void, _al_thread_create, (_AL_THREAD*,
void (*proc)(_AL_THREAD*, void*),
void *arg));
AL_FUNC(void, _al_thread_set_should_stop, (_AL_THREAD *));
/* static inline bool _al_get_thread_should_stop(_AL_THREAD *); */
AL_FUNC(void, _al_thread_join, (_AL_THREAD*));
AL_FUNC(void, _al_thread_detach, (_AL_THREAD*));
AL_FUNC(void, _al_mutex_init, (_AL_MUTEX*));
AL_FUNC(void, _al_mutex_init_recursive, (_AL_MUTEX*));
AL_FUNC(void, _al_mutex_destroy, (_AL_MUTEX*));
/* static inline void _al_mutex_lock(_AL_MUTEX*); */
/* static inline void _al_mutex_unlock(_AL_MUTEX*); */
/* All 5 functions below are declared inline in aintuthr.h.
* FIXME: Why are they all inline? And if they have to be, why not treat them
* the same as the two functions above?
*/
#ifdef ALLEGRO_WINDOWS
AL_FUNC(void, _al_cond_init, (_AL_COND*));
AL_FUNC(void, _al_cond_destroy, (_AL_COND*));
AL_FUNC(void, _al_cond_wait, (_AL_COND*, _AL_MUTEX*));
AL_FUNC(void, _al_cond_broadcast, (_AL_COND*));
AL_FUNC(void, _al_cond_signal, (_AL_COND*));
#endif
AL_FUNC(int, _al_cond_timedwait, (_AL_COND*, _AL_MUTEX*, const ALLEGRO_TIMEOUT *timeout));
#ifdef __cplusplus
}
#endif
#endif
/* vim: set ts=8 sts=3 sw=3 et: */

View File

@@ -0,0 +1,16 @@
#ifndef __al_included_allegro5_aintern_timer_h
#define __al_included_allegro5_aintern_timer_h
#ifdef __cplusplus
extern "C" {
#endif
void _al_init_timers(void);
#ifdef __cplusplus
}
#endif
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,20 @@
#ifndef __al_included_allegro5_aintern_tls_h
#define __al_included_allegro5_aintern_tls_h
#ifdef __cplusplus
extern "C" {
#endif
void _al_tls_init_once(void);
int *_al_tls_get_dtor_owner_count(void);
#ifdef __cplusplus
}
#endif
#endif
/* vim: set ts=8 sts=3 sw=3 et: */

View File

@@ -0,0 +1,9 @@
#ifndef __al_included_allegro5_aintern_transform_h
#define __al_included_allegro5_aintern_transform_h
bool _al_transform_is_translation(const ALLEGRO_TRANSFORM* trans,
float *dx, float *dy);
#endif

View File

@@ -0,0 +1,27 @@
#ifndef __al_included_allegro5_aintern_tri_soft_h
#define __al_included_allegro5_aintern_tri_soft_h
struct ALLEGRO_BITMAP;
/* Duplicated in allegro_primitives.h */
#ifndef _ALLEGRO_VERTEX_DEFINED
#define _ALLEGRO_VERTEX_DEFINED
typedef struct ALLEGRO_VERTEX ALLEGRO_VERTEX;
struct ALLEGRO_VERTEX {
float x, y, z;
float u, v;
ALLEGRO_COLOR color;
};
#endif
AL_FUNC(void, _al_triangle_2d, (ALLEGRO_BITMAP* texture, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3));
AL_FUNC(void, _al_draw_soft_triangle, (
ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3, uintptr_t state,
void (*init)(uintptr_t, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*),
void (*first)(uintptr_t, int, int, int, int),
void (*step)(uintptr_t, int),
void (*draw)(uintptr_t, int, int, int)));
#endif

View File

@@ -0,0 +1 @@
/* #undef ALLEGRO_CFG_TTF_FREETYPE */

View File

@@ -0,0 +1,55 @@
#ifndef __al_included_allegro5_aintern_vector_h
#define __al_included_allegro5_aintern_vector_h
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _AL_VECTOR
{
/* private */
size_t _itemsize;
char* _items; /* total size == (size + unused) * itemsize */
size_t _size;
size_t _unused;
} _AL_VECTOR;
#define _AL_VECTOR_INITIALIZER(typ) { sizeof(typ), 0, 0, 0 }
AL_FUNC(void, _al_vector_init, (_AL_VECTOR*, size_t itemsize));
AL_INLINE(size_t, _al_vector_size, (const _AL_VECTOR *vec),
{
return vec->_size;
})
AL_INLINE(bool, _al_vector_is_empty, (const _AL_VECTOR *vec),
{
ASSERT(vec);
return vec->_size == 0 ? true : false;
})
AL_INLINE(bool, _al_vector_is_nonempty, (const _AL_VECTOR *vec),
{
ASSERT(vec);
return !_al_vector_is_empty(vec);
})
AL_FUNC(void*, _al_vector_ref, (const _AL_VECTOR*, unsigned int index));
AL_FUNC(void*, _al_vector_ref_front, (const _AL_VECTOR*));
AL_FUNC(void*, _al_vector_ref_back, (const _AL_VECTOR*));
AL_FUNC(bool, _al_vector_append_array, (_AL_VECTOR *vec, unsigned int num, const void *arr));
AL_FUNC(void*, _al_vector_alloc_back, (_AL_VECTOR*));
AL_FUNC(void*, _al_vector_alloc_mid, (_AL_VECTOR*, unsigned int index));
AL_FUNC(int, _al_vector_find, (const _AL_VECTOR*, const void *ptr_item));
AL_FUNC(bool, _al_vector_contains, (const _AL_VECTOR*, const void *ptr_item));
AL_FUNC(void, _al_vector_delete_at, (_AL_VECTOR*, unsigned int index));
AL_FUNC(bool, _al_vector_find_and_delete, (_AL_VECTOR*, const void *ptr_item));
AL_FUNC(void, _al_vector_free, (_AL_VECTOR*));
#ifdef __cplusplus
}
#endif
#endif
/* vi ts=8 sts=3 sw=3 et */

View File

@@ -0,0 +1,23 @@
#ifndef __al_included_allegro5_aintern_wunicode_h
#define __al_included_allegro5_aintern_wunicode_h
#ifdef ALLEGRO_WINDOWS
#ifdef __cplusplus
extern "C" {
#endif
AL_FUNC(wchar_t *, _al_win_utf16, (const char *s));
AL_FUNC(char *, _al_win_utf8, (const wchar_t *ws));
#ifdef __cplusplus
}
#endif
#endif
#endif
/* vim: set ts=8 sts=3 sw=3 et: */

View File

@@ -0,0 +1,9 @@
#ifndef __al_included_allegro5_aintern_x_h
#define __al_included_allegro5_aintern_x_h
#include <X11/Xlib.h>
typedef struct ALLEGRO_SYSTEM_XGLX ALLEGRO_SYSTEM_XGLX;
typedef struct ALLEGRO_DISPLAY_XGLX ALLEGRO_DISPLAY_XGLX;
#endif

View File

@@ -0,0 +1,24 @@
#ifndef __al_included_allegro5_aintern_xcursor_h
#define __al_included_allegro5_aintern_xcursor_h
#ifdef ALLEGRO_XWINDOWS_WITH_XCURSOR
#include <X11/Xcursor/Xcursor.h>
#endif
#include "allegro5/internal/aintern_display.h"
typedef struct ALLEGRO_MOUSE_CURSOR_XWIN ALLEGRO_MOUSE_CURSOR_XWIN;
struct ALLEGRO_MOUSE_CURSOR_XWIN
{
Cursor cursor;
};
ALLEGRO_MOUSE_CURSOR *_al_xwin_create_mouse_cursor(ALLEGRO_BITMAP *bmp,
int x_focus, int y_focus);
void _al_xwin_destroy_mouse_cursor(ALLEGRO_MOUSE_CURSOR *cursor);
void _al_xwin_add_cursor_functions(ALLEGRO_DISPLAY_INTERFACE *vt);
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,61 @@
#ifndef __al_included_allegro5_aintern_xdisplay_h
#define __al_included_allegro5_aintern_xdisplay_h
#include <GL/glx.h>
#include "allegro5/internal/aintern_display.h"
#include "allegro5/internal/aintern_x.h"
/* This is our version of ALLEGRO_DISPLAY with driver specific extra data. */
struct ALLEGRO_DISPLAY_XGLX
{
/* This must be the first member. */
ALLEGRO_DISPLAY display;
/* Driver specifics. */
Window window;
int xscreen; /* X Screen ID */
int adapter; /* allegro virtual adapter id/index */
GLXWindow glxwindow;
GLXContext context;
Atom wm_delete_window_atom;
XVisualInfo *xvinfo; /* Used when selecting the X11 visual to use. */
GLXFBConfig *fbc; /* Used when creating the OpenGL context. */
int glx_version; /* 130 means 1 major and 3 minor, aka 1.3 */
/* If our window is embedded by the XEmbed protocol, this gives
* the window ID of the embedder; Otherwise None.
*/
Window embedder_window;
_AL_COND mapped; /* Condition variable to wait for mapping a window. */
bool is_mapped; /* Set to true when mapped. */
int resize_count; /* Increments when resized. */
bool programmatic_resize; /* Set while programmatic resize in progress. */
/* Cursor for this window. */
Cursor invisible_cursor;
Cursor current_cursor;
bool cursor_hidden;
/* Icon for this window. */
Pixmap icon, icon_mask;
/* Desktop position. */
int x, y;
/* al_set_mouse_xy implementation */
bool mouse_warp;
};
void _al_display_xglx_await_resize(ALLEGRO_DISPLAY *d, int old_resize_count, bool delay_hack);
void _al_xglx_display_configure(ALLEGRO_DISPLAY *d, int x, int y, int width, int height, bool setglxy);
void _al_xglx_display_configure_event(ALLEGRO_DISPLAY *d, XEvent *event);
void _al_xwin_display_switch_handler(ALLEGRO_DISPLAY *d,
XFocusChangeEvent *event);
void _al_xwin_display_switch_handler_inner(ALLEGRO_DISPLAY *d, bool focus_in);
void _al_xwin_display_expose(ALLEGRO_DISPLAY *display, XExposeEvent *xevent);
#endif

View File

@@ -0,0 +1,8 @@
#ifndef __al_included_allegro5_aintern_xevents_h
#define __al_included_allegro5_aintern_xevents_h
#include "allegro5/internal/aintern_thread.h"
void _al_xwin_background_thread(_AL_THREAD *self, void *arg);
#endif

View File

@@ -0,0 +1,65 @@
#ifndef __al_included_allegro5_aintern_xfullscreen_h
#define __al_included_allegro5_aintern_xfullscreen_h
/* fullscreen and multi monitor stuff */
typedef struct _ALLEGRO_XGLX_MMON_INTERFACE _ALLEGRO_XGLX_MMON_INTERFACE;
struct _ALLEGRO_XGLX_MMON_INTERFACE {
int (*get_num_display_modes)(ALLEGRO_SYSTEM_XGLX *s, int adapter);
ALLEGRO_DISPLAY_MODE *(*get_display_mode)(ALLEGRO_SYSTEM_XGLX *s, int, int, ALLEGRO_DISPLAY_MODE*);
bool (*set_mode)(ALLEGRO_SYSTEM_XGLX *, ALLEGRO_DISPLAY_XGLX *, int, int, int, int);
void (*store_mode)(ALLEGRO_SYSTEM_XGLX *);
void (*restore_mode)(ALLEGRO_SYSTEM_XGLX *, int);
void (*get_display_offset)(ALLEGRO_SYSTEM_XGLX *, int, int *, int *);
int (*get_num_adapters)(ALLEGRO_SYSTEM_XGLX *);
bool (*get_monitor_info)(ALLEGRO_SYSTEM_XGLX *, int, ALLEGRO_MONITOR_INFO *);
int (*get_default_adapter)(ALLEGRO_SYSTEM_XGLX *);
int (*get_adapter)(ALLEGRO_SYSTEM_XGLX *, ALLEGRO_DISPLAY_XGLX *);
int (*get_xscreen)(ALLEGRO_SYSTEM_XGLX *, int);
void (*post_setup)(ALLEGRO_SYSTEM_XGLX *, ALLEGRO_DISPLAY_XGLX *);
void (*handle_xevent)(ALLEGRO_SYSTEM_XGLX *, ALLEGRO_DISPLAY_XGLX *, XEvent *e);
};
extern _ALLEGRO_XGLX_MMON_INTERFACE _al_xglx_mmon_interface;
int _al_xsys_mheadx_get_default_adapter(ALLEGRO_SYSTEM_XGLX *s);
int _al_xsys_mheadx_get_xscreen(ALLEGRO_SYSTEM_XGLX *s, int adapter);
void _al_xsys_get_active_window_center(ALLEGRO_SYSTEM_XGLX *s, int *x, int *y);
void _al_xsys_mmon_exit(ALLEGRO_SYSTEM_XGLX *s);
int _al_xglx_get_num_display_modes(ALLEGRO_SYSTEM_XGLX *s, int adapter);
ALLEGRO_DISPLAY_MODE *_al_xglx_get_display_mode(
ALLEGRO_SYSTEM_XGLX *s, int adapter, int index, ALLEGRO_DISPLAY_MODE *mode);
bool _al_xglx_fullscreen_set_mode(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d, int w, int h,
int format, int refresh_rate);
void _al_xglx_store_video_mode(ALLEGRO_SYSTEM_XGLX *s);
void _al_xglx_restore_video_mode(ALLEGRO_SYSTEM_XGLX *s, int adapter);
void _al_xglx_fullscreen_to_display(ALLEGRO_SYSTEM_XGLX *s,
ALLEGRO_DISPLAY_XGLX *d);
void _al_xglx_set_fullscreen_window(ALLEGRO_DISPLAY *display, int value);
void _al_xglx_get_display_offset(ALLEGRO_SYSTEM_XGLX *s, int adapter, int *x, int *y);
int _al_xglx_fullscreen_select_mode(ALLEGRO_SYSTEM_XGLX *s, int adapter, int w, int h, int format, int refresh_rate);
bool _al_xglx_get_monitor_info(ALLEGRO_SYSTEM_XGLX *s, int adapter, ALLEGRO_MONITOR_INFO *info);
int _al_xglx_get_num_video_adapters(ALLEGRO_SYSTEM_XGLX *s);
int _al_xglx_get_default_adapter(ALLEGRO_SYSTEM_XGLX *s);
int _al_xglx_get_xscreen(ALLEGRO_SYSTEM_XGLX *s, int adapter);
void _al_xglx_set_above(ALLEGRO_DISPLAY *display, int value);
int _al_xglx_get_adapter(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d, bool recalc);
void _al_xglx_handle_mmon_event(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d, XEvent *e);
#ifdef ALLEGRO_XWINDOWS_WITH_XRANDR
void _al_xsys_xrandr_init(ALLEGRO_SYSTEM_XGLX *s);
void _al_xsys_xrandr_exit(ALLEGRO_SYSTEM_XGLX *s);
#endif /* ALLEGRO_XWINDOWS_WITH_XRANDR */
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,9 @@
#ifndef __al_included_allegro5_aintern_xglx_h
#define __al_included_allegro5_aintern_xglx_h
#include "allegro5/internal/aintern_x.h"
void _al_xglx_config_select_visual(ALLEGRO_DISPLAY_XGLX *glx);
bool _al_xglx_config_create_context(ALLEGRO_DISPLAY_XGLX *glx);
#endif

View File

@@ -0,0 +1,14 @@
#ifndef __al_included_allegro5_aintern_xkeyboard_h
#define __al_included_allegro5_aintern_xkeyboard_h
#include "allegro5/internal/aintern_keyboard.h"
ALLEGRO_KEYBOARD_DRIVER *_al_xwin_keyboard_driver(void);
void _al_xwin_keyboard_handler(XKeyEvent *event, ALLEGRO_DISPLAY *display);
void _al_xwin_keyboard_switch_handler(ALLEGRO_DISPLAY *display, bool focus_in);
void _al_xwin_keyboard_handler_alternative(bool press, int hardware_keycode,
uint32_t unichar, ALLEGRO_DISPLAY *display);
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,15 @@
#ifndef __al_included_allegro5_aintern_xmouse_h
#define __al_included_allegro5_aintern_xmouse_h
#include "allegro5/internal/aintern_mouse.h"
ALLEGRO_MOUSE_DRIVER *_al_xwin_mouse_driver(void);
void _al_xwin_mouse_button_press_handler(int button, ALLEGRO_DISPLAY *display);
void _al_xwin_mouse_button_release_handler(int button, ALLEGRO_DISPLAY *d);
void _al_xwin_mouse_motion_notify_handler(int x, int y, ALLEGRO_DISPLAY *d);
void _al_xwin_mouse_switch_handler(ALLEGRO_DISPLAY *display,
const XCrossingEvent *event);
bool _al_xwin_grab_mouse(ALLEGRO_DISPLAY *display);
bool _al_xwin_ungrab_mouse(void);
#endif

View File

@@ -0,0 +1,88 @@
#ifndef __al_included_allegro5_aintern_xsystem_h
#define __al_included_allegro5_aintern_xsystem_h
#ifdef ALLEGRO_XWINDOWS_WITH_XF86VIDMODE
#include <X11/extensions/xf86vmode.h>
#endif
#ifdef ALLEGRO_XWINDOWS_WITH_XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
#ifdef ALLEGRO_XWINDOWS_WITH_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
#include "allegro5/internal/aintern_system.h"
/* This is our version of ALLEGRO_SYSTEM with driver specific extra data. */
struct ALLEGRO_SYSTEM_XGLX
{
/* This must be the first member, we "derive" from it. */
ALLEGRO_SYSTEM system;
/* Driver specifics. */
/* X11 is not thread-safe. But we use a separate thread to handle X11 events.
* Plus, users may call OpenGL commands in the main thread, and we have no
* way to enforce locking for them.
* The only solution seems to be two X11 display connections. One to do our
* input handling, and one for OpenGL graphics.
*
* Note: these may be NULL if we are not connected to an X server, for
* headless command-line tools. We don't have a separate "null" system
* driver.
*/
/* The X11 display. You *MUST* only access this from one
* thread at a time, use the mutex lock below to ensure it.
*/
Display *x11display;
/* Another X11 display we use for graphics. You *MUST*
* only use this in the main thread.
*/
Display *gfxdisplay;
Atom AllegroAtom;
Atom XEmbedAtom;
_AL_THREAD thread; /* background thread. */
_AL_MUTEX lock; /* thread lock for whenever we access internals. */
// FIXME: One condition variable really would be enough.
_AL_COND resized; /* Condition variable to wait for resizing a window. */
ALLEGRO_DISPLAY *mouse_grab_display; /* Best effort: may be inaccurate. */
int toggle_mouse_grab_keycode; /* Disabled if zero */
unsigned int toggle_mouse_grab_modifiers;
bool inhibit_screensaver; /* Should we inhibit the screensaver? */
bool mmon_interface_inited;
#ifdef ALLEGRO_XWINDOWS_WITH_XINERAMA
int xinerama_available;
int xinerama_screen_count;
XineramaScreenInfo *xinerama_screen_info;
#endif
#ifdef ALLEGRO_XWINDOWS_WITH_XF86VIDMODE
/* For VidMode extension. */
int xfvm_available;
int xfvm_screen_count;
struct {
int mode_count;
XF86VidModeModeInfo **modes;
XF86VidModeModeInfo *original_mode;
} *xfvm_screen;
#endif
#ifdef ALLEGRO_XWINDOWS_WITH_XRANDR
int xrandr_available;
int xrandr_event_base;
_AL_VECTOR xrandr_screens;
_AL_VECTOR xrandr_adaptermap;
#endif
/* Used to keep track of how many adapters are in use, so the multi-head
* code can bail if we try to use more than one. */
int adapter_use_count;
int adapter_map[32]; /* XXX magic constant */
};
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,14 @@
#ifndef __al_included_allegro5_aintern_xwindow_h
#define __al_included_allegro5_aintern_xwindow_h
void _al_xwin_set_size_hints(ALLEGRO_DISPLAY *d, int x_off, int y_off);
void _al_xwin_reset_size_hints(ALLEGRO_DISPLAY *d);
void _al_xwin_set_fullscreen_window(ALLEGRO_DISPLAY *display, int value);
void _al_xwin_set_above(ALLEGRO_DISPLAY *display, int value);
void _al_xwin_set_frame(ALLEGRO_DISPLAY *display, bool frame_on);
void _al_xwin_set_icons(ALLEGRO_DISPLAY *d,
int num_icons, ALLEGRO_BITMAP *bitmaps[]);
#endif
/* vim: set sts=3 sw=3 et: */

View File

@@ -0,0 +1,267 @@
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Configuration defines.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*/
/* for backward compatibility */
#ifdef USE_CONSOLE
#define ALLEGRO_NO_MAGIC_MAIN
#define ALLEGRO_USE_CONSOLE
#endif
/* include platform-specific stuff */
#include "allegro5/platform/alplatf.h"
#if defined ALLEGRO_WATCOM
#include "allegro5/platform/alwatcom.h"
#elif defined ALLEGRO_MINGW32
#include "allegro5/platform/almngw32.h"
#elif defined ALLEGRO_BCC32
#include "allegro5/platform/albcc32.h"
#elif defined ALLEGRO_MSVC
#include "allegro5/platform/almsvc.h"
#elif defined ALLEGRO_IPHONE
#include "allegro5/platform/aliphonecfg.h"
#elif defined ALLEGRO_MACOSX
#include "allegro5/platform/alosxcfg.h"
#elif defined ALLEGRO_UNIX
#include "allegro5/platform/alucfg.h"
#else
#error platform not supported
#endif
#include "allegro5/platform/astdint.h"
#include "allegro5/platform/astdbool.h"
/* 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
/* Needed if this header is included by C99 code, as
* "extern __inline__" in C99 exports a new global function.
*/
#elif __GNUC_STDC_INLINE__
#define AL_INLINE(type, name, args, code) \
extern __inline__ __attribute__((__gnu_inline__)) type name args; \
extern __inline__ __attribute__((__gnu_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
#ifndef AL_INLINE_STATIC
#ifdef __cplusplus
#define AL_INLINE_STATIC(type, name, args, code) \
AL_INLINE(type, name, args, code)
#else
#define AL_INLINE_STATIC(type, name, args, code) \
static __inline__ type name args; \
static __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
#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
#endif
#ifdef __amd64__
#define ALLEGRO_AMD64
#endif
#ifdef __arm__
#define ALLEGRO_ARM
#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
/* 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 INLINE
#define INLINE
#endif
#ifndef ZERO_SIZE_ARRAY
#define ZERO_SIZE_ARRAY(type, name) type name[]
#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
#ifdef __cplusplus
extern "C" {
#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)))
#else
#error endianess not defined
#endif
/* generic versions of the video memory access helpers */
/* FIXME: why do we need macros for this? */
#define bmp_write16(addr, c) (*((uint16_t *)(addr)) = (c))
#define bmp_write32(addr, c) (*((uint32_t *)(addr)) = (c))
#define bmp_read16(addr) (*((uint16_t *)(addr)))
#define bmp_read32(addr) (*((uint32_t *)(addr)))
/* default random function definition */
#ifndef AL_RAND
#define AL_RAND() (rand())
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,309 @@
/*
* This source file has had its exported symbols prefixed with _al_ or _AL_
* for the Allegro project.
*/
/*
* This source file is part of the _al_bstring string library. This code was
* written by Paul Hsieh in 2002-2008, and is covered by the BSD open source
* license and the GPL. Refer to the accompanying documentation for details
* on usage and license.
*/
/*
* bstrlib.c
*
* This file is the core module for implementing the _al_bstring functions.
*/
#ifndef _AL_BSTRLIB_INCLUDE
#define _AL_BSTRLIB_INCLUDE
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#if !defined (BSTRLIB_VSNP_OK) && !defined (BSTRLIB_NOVSNP)
# if defined (__TURBOC__) && !defined (__BORLANDC__)
# define BSTRLIB_NOVSNP
# endif
#endif
#define _AL_BSTR_ERR (-1)
#define _AL_BSTR_OK (0)
#define _AL_BSTR_BS_BUFF_LENGTH_GET (0)
typedef struct _al_tagbstring * _al_bstring;
typedef const struct _al_tagbstring * _al_const_bstring;
/* Copy functions */
#define _al_cstr2bstr _al_bfromcstr
extern _al_bstring _al_bfromcstr (const char * str);
extern _al_bstring _al_bfromcstralloc (int mlen, const char * str);
extern _al_bstring _al_blk2bstr (const void * blk, int len);
extern char * _al_bstr2cstr (_al_const_bstring s, char z);
extern int _al_bcstrfree (char * s);
extern _al_bstring _al_bstrcpy (_al_const_bstring b1);
extern int _al_bassign (_al_bstring a, _al_const_bstring b);
extern int _al_bassignmidstr (_al_bstring a, _al_const_bstring b, int left, int len);
extern int _al_bassigncstr (_al_bstring a, const char * str);
extern int _al_bassignblk (_al_bstring a, const void * s, int len);
/* Destroy function */
extern int _al_bdestroy (_al_bstring b);
/* Space allocation hinting functions */
extern int _al_balloc (_al_bstring s, int len);
extern int _al_ballocmin (_al_bstring b, int len);
/* Substring extraction */
extern _al_bstring _al_bmidstr (_al_const_bstring b, int left, int len);
/* Various standard manipulations */
extern int _al_bconcat (_al_bstring b0, _al_const_bstring b1);
extern int _al_bconchar (_al_bstring b0, char c);
extern int _al_bcatcstr (_al_bstring b, const char * s);
extern int _al_bcatblk (_al_bstring b, const void * s, int len);
extern int _al_binsert (_al_bstring s1, int pos, _al_const_bstring s2, unsigned char fill);
extern int _al_binsertch (_al_bstring s1, int pos, int len, unsigned char fill);
extern int _al_breplace (_al_bstring b1, int pos, int len, _al_const_bstring b2, unsigned char fill);
extern int _al_bdelete (_al_bstring s1, int pos, int len);
extern int _al_bsetstr (_al_bstring b0, int pos, _al_const_bstring b1, unsigned char fill);
extern int _al_btrunc (_al_bstring b, int n);
/* Scan/search functions */
extern int _al_bstricmp (_al_const_bstring b0, _al_const_bstring b1);
extern int _al_bstrnicmp (_al_const_bstring b0, _al_const_bstring b1, int n);
extern int _al_biseqcaseless (_al_const_bstring b0, _al_const_bstring b1);
extern int _al_bisstemeqcaselessblk (_al_const_bstring b0, const void * blk, int len);
extern int _al_biseq (_al_const_bstring b0, _al_const_bstring b1);
extern int _al_bisstemeqblk (_al_const_bstring b0, const void * blk, int len);
extern int _al_biseqcstr (_al_const_bstring b, const char * s);
extern int _al_biseqcstrcaseless (_al_const_bstring b, const char * s);
extern int _al_bstrcmp (_al_const_bstring b0, _al_const_bstring b1);
extern int _al_bstrncmp (_al_const_bstring b0, _al_const_bstring b1, int n);
extern int _al_binstr (_al_const_bstring s1, int pos, _al_const_bstring s2);
extern int _al_binstrr (_al_const_bstring s1, int pos, _al_const_bstring s2);
extern int _al_binstrcaseless (_al_const_bstring s1, int pos, _al_const_bstring s2);
extern int _al_binstrrcaseless (_al_const_bstring s1, int pos, _al_const_bstring s2);
extern int _al_bstrchrp (_al_const_bstring b, int c, int pos);
extern int _al_bstrrchrp (_al_const_bstring b, int c, int pos);
#define _al_bstrchr(b,c) _al_bstrchrp ((b), (c), 0)
#define _al_bstrrchr(b,c) _al_bstrrchrp ((b), (c), _al_blength(b)-1)
extern int _al_binchr (_al_const_bstring b0, int pos, _al_const_bstring b1);
extern int _al_binchrr (_al_const_bstring b0, int pos, _al_const_bstring b1);
extern int _al_bninchr (_al_const_bstring b0, int pos, _al_const_bstring b1);
extern int _al_bninchrr (_al_const_bstring b0, int pos, _al_const_bstring b1);
extern int _al_bfindreplace (_al_bstring b, _al_const_bstring find, _al_const_bstring repl, int pos);
extern int _al_bfindreplacecaseless (_al_bstring b, _al_const_bstring find, _al_const_bstring repl, int pos);
/* List of string container functions */
struct _al_bstrList {
int qty, mlen;
_al_bstring * entry;
};
extern struct _al_bstrList * _al_bstrListCreate (void);
extern int _al_bstrListDestroy (struct _al_bstrList * sl);
extern int _al_bstrListAlloc (struct _al_bstrList * sl, int msz);
extern int _al_bstrListAllocMin (struct _al_bstrList * sl, int msz);
/* String split and join functions */
extern struct _al_bstrList * _al_bsplit (_al_const_bstring str, unsigned char splitChar);
extern struct _al_bstrList * _al_bsplits (_al_const_bstring str, _al_const_bstring splitStr);
extern struct _al_bstrList * _al_bsplitstr (_al_const_bstring str, _al_const_bstring splitStr);
extern _al_bstring _al_bjoin (const struct _al_bstrList * bl, _al_const_bstring sep);
extern int _al_bsplitcb (_al_const_bstring str, unsigned char splitChar, int pos,
int (* cb) (void * parm, int ofs, int len), void * parm);
extern int _al_bsplitscb (_al_const_bstring str, _al_const_bstring splitStr, int pos,
int (* cb) (void * parm, int ofs, int len), void * parm);
extern int _al_bsplitstrcb (_al_const_bstring str, _al_const_bstring splitStr, int pos,
int (* cb) (void * parm, int ofs, int len), void * parm);
/* Miscellaneous functions */
extern int _al_bpattern (_al_bstring b, int len);
extern int _al_btoupper (_al_bstring b);
extern int _al_btolower (_al_bstring b);
extern int _al_bltrimws (_al_bstring b);
extern int _al_brtrimws (_al_bstring b);
extern int _al_btrimws (_al_bstring b);
#if !defined (BSTRLIB_NOVSNP)
extern _al_bstring _al_bformat (const char * fmt, ...);
extern int _al_bformata (_al_bstring b, const char * fmt, ...);
extern int _al_bassignformat (_al_bstring b, const char * fmt, ...);
extern int _al_bvcformata (_al_bstring b, int count, const char * fmt, va_list arglist);
#define _al_bvformata(ret, b, fmt, lastarg) { \
_al_bstring bstrtmp_b = (b); \
const char * bstrtmp_fmt = (fmt); \
int bstrtmp_r = _AL_BSTR_ERR, bstrtmp_sz = 16; \
for (;;) { \
va_list bstrtmp_arglist; \
va_start (bstrtmp_arglist, lastarg); \
bstrtmp_r = _al_bvcformata (bstrtmp_b, bstrtmp_sz, bstrtmp_fmt, bstrtmp_arglist); \
va_end (bstrtmp_arglist); \
if (bstrtmp_r >= 0) { /* Everything went ok */ \
bstrtmp_r = _AL_BSTR_OK; \
break; \
} else if (-bstrtmp_r <= bstrtmp_sz) { /* A real error? */ \
bstrtmp_r = _AL_BSTR_ERR; \
break; \
} \
bstrtmp_sz = -bstrtmp_r; /* Doubled or target size */ \
} \
ret = bstrtmp_r; \
}
#endif
typedef int (*_al_bNgetc) (void *parm);
typedef size_t (* _al_bNread) (void *buff, size_t elsize, size_t nelem, void *parm);
/* Input functions */
extern _al_bstring _al_bgets (_al_bNgetc getcPtr, void * parm, char terminator);
extern _al_bstring _al_bread (_al_bNread readPtr, void * parm);
extern int _al_bgetsa (_al_bstring b, _al_bNgetc getcPtr, void * parm, char terminator);
extern int _al_bassigngets (_al_bstring b, _al_bNgetc getcPtr, void * parm, char terminator);
extern int _al_breada (_al_bstring b, _al_bNread readPtr, void * parm);
/* Stream functions */
extern struct _al_bStream * _al_bsopen (_al_bNread readPtr, void * parm);
extern void * _al_bsclose (struct _al_bStream * s);
extern int _al_bsbufflength (struct _al_bStream * s, int sz);
extern int _al_bsreadln (_al_bstring b, struct _al_bStream * s, char terminator);
extern int _al_bsreadlns (_al_bstring r, struct _al_bStream * s, _al_const_bstring term);
extern int _al_bsread (_al_bstring b, struct _al_bStream * s, int n);
extern int _al_bsreadlna (_al_bstring b, struct _al_bStream * s, char terminator);
extern int _al_bsreadlnsa (_al_bstring r, struct _al_bStream * s, _al_const_bstring term);
extern int _al_bsreada (_al_bstring b, struct _al_bStream * s, int n);
extern int _al_bsunread (struct _al_bStream * s, _al_const_bstring b);
extern int _al_bspeek (_al_bstring r, const struct _al_bStream * s);
extern int _al_bssplitscb (struct _al_bStream * s, _al_const_bstring splitStr,
int (* cb) (void * parm, int ofs, _al_const_bstring entry), void * parm);
extern int _al_bssplitstrcb (struct _al_bStream * s, _al_const_bstring splitStr,
int (* cb) (void * parm, int ofs, _al_const_bstring entry), void * parm);
extern int _al_bseof (const struct _al_bStream * s);
#ifndef __al_tagbstring_defined
#define __al_tagbstring_defined
struct _al_tagbstring {
int mlen;
int slen;
unsigned char * data;
};
#endif
/* Accessor macros */
#define _al_blengthe(b, e) (((b) == (void *)0 || (b)->slen < 0) ? (int)(e) : ((b)->slen))
#define _al_blength(b) (_al_blengthe ((b), 0))
#define _al_bdataofse(b, o, e) (((b) == (void *)0 || (b)->data == (void*)0) ? (char *)(e) : ((char *)(b)->data) + (o))
#define _al_bdataofs(b, o) (_al_bdataofse ((b), (o), (void *)0))
#define _al_bdatae(b, e) (_al_bdataofse (b, 0, e))
#define _al_bdata(b) (_al_bdataofs (b, 0))
#define _al_bchare(b, p, e) ((((unsigned)(p)) < (unsigned)_al_blength(b)) ? ((b)->data[(p)]) : (e))
#define _al_bchar(b, p) _al_bchare ((b), (p), '\0')
/* Static constant string initialization macro */
#define _al_bsStaticMlen(q,m) {(m), (int) sizeof(q)-1, (unsigned char *) ("" q "")}
#if defined(_MSC_VER)
# define _al_bsStatic(q) _al_bsStaticMlen(q,-32)
#endif
#ifndef _al_bsStatic
# define _al_bsStatic(q) _al_bsStaticMlen(q,-__LINE__)
#endif
/* Static constant block parameter pair */
#define _al_bsStaticBlkParms(q) ((void *)("" q "")), ((int) sizeof(q)-1)
/* Reference building macros */
#define _al_cstr2tbstr _al_btfromcstr
#define _al_btfromcstr(t,s) { \
(t).data = (unsigned char *) (s); \
(t).slen = ((t).data) ? ((int) (strlen) ((char *)(t).data)) : 0; \
(t).mlen = -1; \
}
#define _al_blk2tbstr(t,s,l) { \
(t).data = (unsigned char *) (s); \
(t).slen = l; \
(t).mlen = -1; \
}
#define _al_btfromblk(t,s,l) _al_blk2tbstr(t,s,l)
#define _al_bmid2tbstr(t,b,p,l) { \
_al_const_bstring bstrtmp_s = (b); \
if (bstrtmp_s && bstrtmp_s->data && bstrtmp_s->slen >= 0) { \
int bstrtmp_left = (p); \
int bstrtmp_len = (l); \
if (bstrtmp_left < 0) { \
bstrtmp_len += bstrtmp_left; \
bstrtmp_left = 0; \
} \
if (bstrtmp_len > bstrtmp_s->slen - bstrtmp_left) \
bstrtmp_len = bstrtmp_s->slen - bstrtmp_left; \
if (bstrtmp_len <= 0) { \
(t).data = (unsigned char *)""; \
(t).slen = 0; \
} else { \
(t).data = bstrtmp_s->data + bstrtmp_left; \
(t).slen = bstrtmp_len; \
} \
} else { \
(t).data = (unsigned char *)""; \
(t).slen = 0; \
} \
(t).mlen = -__LINE__; \
}
#define _al_btfromblkltrimws(t,s,l) { \
int bstrtmp_idx = 0, bstrtmp_len = (l); \
unsigned char * bstrtmp_s = (s); \
if (bstrtmp_s && bstrtmp_len >= 0) { \
for (; bstrtmp_idx < bstrtmp_len; bstrtmp_idx++) { \
if (!isspace (bstrtmp_s[bstrtmp_idx])) break; \
} \
} \
(t).data = bstrtmp_s + bstrtmp_idx; \
(t).slen = bstrtmp_len - bstrtmp_idx; \
(t).mlen = -__LINE__; \
}
#define _al_btfromblkrtrimws(t,s,l) { \
int bstrtmp_len = (l) - 1; \
unsigned char * bstrtmp_s = (s); \
if (bstrtmp_s && bstrtmp_len >= 0) { \
for (; bstrtmp_len >= 0; bstrtmp_len--) { \
if (!isspace (bstrtmp_s[bstrtmp_len])) break; \
} \
} \
(t).data = bstrtmp_s; \
(t).slen = bstrtmp_len + 1; \
(t).mlen = -__LINE__; \
}
#define _al_btfromblktrimws(t,s,l) { \
int bstrtmp_idx = 0, bstrtmp_len = (l) - 1; \
unsigned char * bstrtmp_s = (s); \
if (bstrtmp_s && bstrtmp_len >= 0) { \
for (; bstrtmp_idx <= bstrtmp_len; bstrtmp_idx++) { \
if (!isspace (bstrtmp_s[bstrtmp_idx])) break; \
} \
for (; bstrtmp_len >= bstrtmp_idx; bstrtmp_len--) { \
if (!isspace (bstrtmp_s[bstrtmp_len])) break; \
} \
} \
(t).data = bstrtmp_s + bstrtmp_idx; \
(t).slen = bstrtmp_len + 1 - bstrtmp_idx; \
(t).mlen = -__LINE__; \
}
/* Write protection macros */
#define _al_bwriteprotect(t) { if ((t).mlen >= 0) (t).mlen = -1; }
#define _al_bwriteallow(t) { if ((t).mlen == -1) (t).mlen = (t).slen + ((t).slen == 0); }
#define _al_biswriteprotected(t) ((t).mlen <= 0)
#ifdef __cplusplus
}
#endif
#endif