64#ifndef __NILOREA_ALLEGRO_4_COMPAT__
65#define __NILOREA_ALLEGRO_4_COMPAT__
80#define ALLEGRO_ERROR_SIZE 256
88#define END_OF_FUNCTION(x)
90#define END_OF_STATIC_FUNCTION(x)
92#define LOCK_VARIABLE(x)
94#define LOCK_FUNCTION(x)
98#define U_ASCII 0x41534338
100#define U_UTF8 0x55544638
104int ustricmp(
const char* s1,
const char* s2);
143#define SCREEN_W (screen ? screen->w : 0)
145#define SCREEN_H (screen ? screen->h : 0)
151#define GFX_AUTODETECT 0
153#define GFX_AUTODETECT_FULLSCREEN 1
155#define GFX_AUTODETECT_WINDOWED 2
161#define GFX_DIRECTX_WIN 5
163#define GFX_OPENGL_WINDOWED 6
165#define GFX_OPENGL_FULLSCREEN 7
177int alert(
const char* s1,
const char* s2,
const char* s3,
const char* b1,
const char* b2,
int c1,
int c2);
183int set_gfx_mode(
int card,
int w,
int h,
int v_w,
int v_h);
198#ifndef GL_COLOR_BUFFER_BIT
200#define GL_COLOR_BUFFER_BIT 0x00004000
202#define glClear(mask) ((void)(mask))
322#define KEY_BACKSPACE 63
350#define KEY_ENTER_PAD 91
352#define KEY_LSHIFT 215
354#define KEY_RSHIFT 216
356#define KEY_LCONTROL 217
358#define KEY_RCONTROL 218
386#define TIMERS_PER_SECOND 1193181L
388#define SECS_TO_TIMER(x) ((long)(x) * TIMERS_PER_SECOND)
390#define MSEC_TO_TIMER(x) ((long)(x) * (TIMERS_PER_SECOND / 1000))
392#define BPS_TO_TIMER(x) (TIMERS_PER_SECOND / (long)(x))
394#define BPM_TO_TIMER(x) ((60 * TIMERS_PER_SECOND) / (long)(x))
404void rest(
unsigned int ms);
433void blit(
BITMAP* source,
BITMAP* dest,
int source_x,
int source_y,
int dest_x,
int dest_y,
int width,
int height);
435void masked_blit(
BITMAP* source,
BITMAP* dest,
int source_x,
int source_y,
int dest_x,
int dest_y,
int width,
int height);
437void stretch_blit(
BITMAP* source,
BITMAP* dest,
int source_x,
int source_y,
int source_width,
int source_height,
int dest_x,
int dest_y,
int dest_width,
int dest_height);
439void masked_stretch_blit(
BITMAP* source,
BITMAP* dest,
int source_x,
int source_y,
int source_w,
int source_h,
int dest_x,
int dest_y,
int dest_w,
int dest_h);
456#define itofix(x) ((fixed)((x) * 65536))
458#define fixtoi(x) ((int)(((x) + 0x8000) >> 16))
460#define ftofix(x) ((fixed)((x) * 65536.0 + ((x) < 0 ? -0.5 : 0.5)))
462#define fixtof(x) ((double)(x) / 65536.0)
474#define DRAW_MODE_SOLID 0
476#define DRAW_MODE_TRANS 5
490void line(
BITMAP* bmp,
int x1,
int y1,
int x2,
int y2,
int color);
492void hline(
BITMAP* bmp,
int x1,
int y,
int x2,
int color);
494void vline(
BITMAP* bmp,
int x,
int y1,
int y2,
int color);
496void rect(
BITMAP* bmp,
int x1,
int y1,
int x2,
int y2,
int color);
498void rectfill(
BITMAP* bmp,
int x1,
int y1,
int x2,
int y2,
int color);
500void circle(
BITMAP* bmp,
int x,
int y,
int radius,
int color);
504void ellipse(
BITMAP* bmp,
int x,
int y,
int rx,
int ry,
int color);
508void triangle(
BITMAP* bmp,
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int color);
522#define bmp_write32(addr, c) (*((uint32_t*)(uintptr_t)(addr)) = _a4_pixel_from_color(c))
524#define bmp_write24(addr, c) bmp_write32(addr, c)
526#define bmp_write16(addr, c) bmp_write32(addr, c)
528#define bmp_write15(addr, c) bmp_write32(addr, c)
530#define bmp_write8(addr, c) bmp_write32(addr, c)
534int makecol(
int r,
int g,
int b);
538int makeacol(
int r,
int g,
int b,
int a);
572#define ALLEGTTF_NOSMOOTH 0
574#define ALLEGTTF_TTFSMOOTH 1
576#define ALLEGTTF_REALSMOOTH 2
584#define DIGI_AUTODETECT -1
588#define MIDI_AUTODETECT -1
596void set_volume(
int digi_volume,
int midi_volume);
635int gfx_mode(
int mode,
int w,
int h,
int v_w,
int v_h,
int depth,
double r,
double g,
double b,
double a);
639void fill_str(
char* str,
int c,
size_t len);
647#define get_keyboard a4_get_keyboard
651#define LEX_MENU_NORMAL 0
653#define LEX_MENU_OVER 1
static void type(N_GUI_CTX *gui, const char *s)
Type a whole string into whatever has focus.
unsigned char filler
padding
void * priv
private state of the compatibility layer
unsigned char ** line
always NULL: direct line access goes through bmp_write_line()
int makeacol32(int r, int g, int b, int a)
make a colour with alpha
void allegro_gl_unset_allegro_mode(void)
no-op
void stretch_blit(BITMAP *source, BITMAP *dest, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int dest_width, int dest_height)
copy and scale a rectangle
int install_mouse(void)
start the input thread for the mouse
SAMPLE * load_sample(const char *filename)
load a WAV, OGG, FLAC or VOC file
uintptr_t bmp_write_line(BITMAP *bmp, int y)
lock the bitmap and return the address of line y, 32 bit ARGB pixels
FONT * load_ttf_font_mem(const char *filename, int points, int smooth)
same as load_ttf_font()
void draw_sprite_h_flip(BITMAP *bmp, BITMAP *sprite, int x, int y)
draw a sprite mirrored horizontally
void destroy_bitmap(BITMAP *bmp)
free a bitmap
void set_trans_blender(int r, int g, int b, int a)
blend with a constant opacity a (0-255), r, g and b are ignored
void allegro_exit(void)
shut everything down
int is_memory_bitmap(BITMAP *bmp)
always FALSE: pixels are reached through bmp_write_line()
char allegro_error[256]
last error message, as in Allegro 4
BITMAP * create_video_bitmap(int width, int height)
same as create_bitmap()
int set_close_button_callback(void(*proc)(void))
call proc when the window close button is pressed
int a4_get_keyboard(char *keybuf, int *cur, int flags, int max)
read the typed keys into keybuf at *cur (printable ASCII, backspace erases), keeping it nul terminate...
int poll_mouse(void)
no-op, input is updated by a thread
uintptr_t bmp_read_line(BITMAP *bmp, int y)
lock the bitmap and return the address of line y, 32 bit ARGB pixels
void bmp_unwrite_line(BITMAP *bmp)
no-op, the bitmap is unlocked when next drawn with the GPU
int install_int_ex(void(*proc)(void), long speed)
call proc every speed timer ticks, from the timer thread
BITMAP * create_bitmap(int width, int height)
create a w x h bitmap
int install_sound(int digi, int midi, const char *cfg_path)
start the audio, cfg_path is ignored
void destroy_sample(SAMPLE *spl)
free a sample, stopping it
int bitmap_mask_color(BITMAP *bmp)
the mask colour, magenta
int getr(int c)
red component
int readkey(void)
wait for a key: (scancode << 8) | ascii
void line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color)
draw a line
volatile char key[227]
TRUE while the key is held.
int save_bitmap(const char *filename, BITMAP *bmp, const RGB *pal)
save a bitmap
void draw_sprite_vh_flip(BITMAP *bmp, BITMAP *sprite, int x, int y)
draw a sprite mirrored both ways
void textout_right_ex(BITMAP *bmp, const FONT *f, const char *s, int x, int y, int color, int bg)
draw a string ending at x
int ustricmp(const char *s1, const char *s2)
case insensitive string compare
FONT * font
the default 8x8 font, valid after allegro_init()
void clear_keybuf(void)
empty the readkey() buffer
void set_uformat(int type)
no-op, kept for source compatibility
void textprintf_ex(BITMAP *bmp, const FONT *f, int x, int y, int color, int bg, const char *format,...)
draw a formatted string
void drawing_mode(int mode, BITMAP *pattern, int x_anchor, int y_anchor)
set the drawing mode of primitives, pattern arguments are ignored
int makecol32(int r, int g, int b)
make an opaque colour
volatile int mouse_x
mouse x in screen coordinates
int poll_keyboard(void)
no-op, input is updated by a thread
volatile int key_shifts
modifier flags, unused
void ellipse(BITMAP *bmp, int x, int y, int rx, int ry, int color)
draw an ellipse outline
void rotate_scaled_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle, fixed scale)
rotate and scale a sprite around its centre
void destroy_midi(MIDI *midi)
free a MIDI song, stopping it if it plays
void remove_int(void(*proc)(void))
stop calling proc
int makeacol(int r, int g, int b, int a)
make a colour with alpha
void solid_mode(void)
same as drawing_mode(DRAW_MODE_SOLID, ...)
BITMAP * screen
the screen, valid after set_gfx_mode()
void textout_centre_ex(BITMAP *bmp, const FONT *f, const char *s, int x, int y, int color, int bg)
draw a string centred on x
void set_alpha_blender(void)
blend with the alpha channel of the source colour or sprite
#define KEY_MAX
number of entries in key[]
void masked_stretch_blit(BITMAP *source, BITMAP *dest, int source_x, int source_y, int source_w, int source_h, int dest_x, int dest_y, int dest_w, int dest_h)
copy and scale a rectangle, skipping mask colour pixels
void get_mouse_mickeys(int *mickeyx, int *mickeyy)
movement since the last call
int install_keyboard(void)
start the input thread for the keyboard
BITMAP * create_bitmap_ex(int depth, int width, int height)
same as create_bitmap(), depth is ignored
void vline(BITMAP *bmp, int x, int y1, int y2, int color)
draw a vertical line
void allegro_message(const char *format,...)
show a message: a box over the screen, or stderr without a display
int set_gfx_mode(int card, int w, int h, int v_w, int v_h)
open a display of w x h pixels, or close it with GFX_TEXT
void position_mouse(int x, int y)
move the mouse pointer
void set_volume(int digi_volume, int midi_volume)
set the volumes (0-255), a negative value leaves one unchanged
int allegro_init(void)
init the layer and Allegro 5
int install_timer(void)
no-op, timers are always available
void circle(BITMAP *bmp, int x, int y, int radius, int color)
draw a circle outline
int lexMenuRun(LexMenu *menu, BITMAP *buf)
run the menu, drawing into buf: the chosen item index, -1 on escape
void adjust_sample(const SAMPLE *spl, int vol, int pan, int freq, int loop)
change the settings of the playing instances of a sample
void clear_bitmap(BITMAP *bmp)
clear to black
void set_window_title(const char *name)
set the window title
int makecol(int r, int g, int b)
make an opaque colour
int play_sample(const SAMPLE *spl, int vol, int pan, int freq, int loop)
play a sample: vol and pan 0-255, freq 1000 = normal speed
void blit(BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)
copy a rectangle
void allegro_gl_set_allegro_mode(void)
no-op
int bitmap_color_depth(BITMAP *bmp)
always 32
void masked_blit(BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height)
copy a rectangle, skipping mask colour pixels
void ellipsefill(BITMAP *bmp, int x, int y, int rx, int ry, int color)
draw a filled ellipse
int get_color_depth(void)
return the color depth (always 32)
void stop_sample(const SAMPLE *spl)
stop every playing instance of a sample
int install_int(void(*proc)(void), int speed)
call proc every speed milliseconds, from the timer thread
void textprintf_centre_ex(BITMAP *bmp, const FONT *f, int x, int y, int color, int bg, const char *format,...)
draw a formatted string centred on x
int32_t fixed
16.16 fixed point number
int getb(int c)
blue component
int gfx_mode(int mode, int w, int h, int v_w, int v_h, int depth, double r, double g, double b, double a)
set the color depth and the graphics mode in one go, clearing the screen to (r,g,b),...
void destroy_font(FONT *f)
free a font loaded with load_ttf_font()
void bmp_select(BITMAP *bmp)
no-op
LexMenu * lexMenuDestroy(LexMenu *menu)
free a menu, returns NULL
volatile int mouse_b
button flags: 1 left, 2 right, 4 middle
void remove_sound(void)
stop the audio
void midi_pause(void)
pause the MIDI song
void pivot_scaled_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle, fixed scale)
rotate and scale a sprite around (cx,cy) in the sprite, drawn at (x,y)
int install_allegro_gl(void)
no-op, the layer always uses Allegro 5's own driver
MIDI * load_midi(const char *filename)
load a MIDI file
int getg(int c)
green component
void fill_str(char *str, int c, size_t len)
fill len bytes of str with c
void draw_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y)
draw a sprite
void rotate_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle)
rotate a sprite around its centre, angle in 256ths of a turn, clockwise
int alert(const char *s1, const char *s2, const char *s3, const char *b1, const char *b2, int c1, int c2)
a box with up to three lines and one or two buttons (b2 may be NULL), chosen with the mouse,...
volatile int mouse_y
mouse y in screen coordinates
void midi_resume(void)
resume the MIDI song
void textprintf_right_ex(BITMAP *bmp, const FONT *f, int x, int y, int color, int bg, const char *format,...)
draw a formatted string ending at x
int keypressed(void)
TRUE if a key is waiting in the readkey() buffer.
uint32_t _a4_pixel_from_color(int color)
store a colour as it is kept in a bitmap (opaque when its alpha byte is 0)
BITMAP * load_bitmap(const char *filename, RGB *pal)
load a BMP, PCX, TGA, PNG or JPG file, pal is ignored
void stretch_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int w, int h)
draw a sprite scaled to w x h
void putpixel(BITMAP *bmp, int x, int y, int color)
write a pixel
int gfx_status(int action, int value)
with GET, MODE_OGL when the current mode is an AllegroGL one, else MODE_STD
void set_color_depth(int depth)
set the color depth, only 32 is honoured
void clear_to_color(BITMAP *bmp, int color)
clear to a colour
void rectfill(BITMAP *bmp, int x1, int y1, int x2, int y2, int color)
draw a filled rectangle
void hline(BITMAP *bmp, int x1, int y, int x2, int color)
draw a horizontal line
void triangle(BITMAP *bmp, int x1, int y1, int x2, int y2, int x3, int y3, int color)
draw a filled triangle
FONT * load_ttf_font(const char *filename, int points, int smooth)
load a TrueType font at the given pixel size
void pivot_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int cx, int cy, fixed angle)
rotate a sprite around (cx,cy) in the sprite, drawn at (x,y)
int text_height(const FONT *f)
height of the font in pixels
void rest(unsigned int ms)
sleep ms milliseconds
int text_length(const FONT *f, const char *str)
width of str in pixels
int geta(int c)
alpha component, 255 for an opaque colour
void circlefill(BITMAP *bmp, int x, int y, int radius, int color)
draw a filled circle
void textout_ex(BITMAP *bmp, const FONT *f, const char *s, int x, int y, int color, int bg)
draw a string
LexMenu * lexLoadMenuFromFile(const char *file, const char *section)
load menu section from INI file file, NULL on error
#define ALLEGRO_ERROR_SIZE
size of the allegro_error buffer
void draw_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y)
draw a sprite mirrored vertically
volatile int mouse_z
mouse wheel position
void draw_trans_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y)
draw a sprite with the current blender (set_alpha_blender / set_trans_blender)
void show_mouse(BITMAP *bmp)
show the system cursor (bmp != NULL) or hide it (NULL)
void clear(BITMAP *bmp)
clear to black
int getpixel(BITMAP *bmp, int x, int y)
read a pixel, -1 outside the bitmap
void allegro_gl_flip(void)
show the screen bitmap
void stop_midi(void)
stop the MIDI song
BITMAP * lexMenuGetBitmap(LexMenu *menu, int item, int state)
the image of item item in state state, NULL if there is none
void rect(BITMAP *bmp, int x1, int y1, int x2, int y2, int color)
draw a rectangle outline
int play_midi(MIDI *midi, int loop)
play a MIDI song, replacing the current one, NULL stops
palette entry, unused in 32 bit mode
a font: the built in one, or a TTF font loaded with load_ttf_font()