Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_allegro_4.c File Reference

Allegro 4 compatibility layer on top of Allegro 5. More...

#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <math.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_module.h"
#include "nilorea/n_allegro_4.h"
#include <dirent.h>
#include <unistd.h>
Include dependency graph for n_allegro_4.c:

Go to the source code of this file.

Data Structures

struct  A4_BMP
struct  A4_TIMER
struct  FONT
 a font: the built in one, or a TTF font loaded with load_ttf_font() More...
struct  LEX_ITEM
struct  LexMenu
 an INI driven menu More...
struct  MIDI
 a MIDI song More...
struct  SAMPLE
 a sound sample More...

Macros

#define A4_BATCH_MAX   6144
#define A4_BLEND_ALPHA   1
#define A4_BLEND_COPY   0
#define A4_BLEND_FADE   2
#define A4_KEYBUF_SIZE   64
#define A4_MASK_COLOR   0x00FF00FF
#define A4_MAX_TIMERS   16
#define A4_MIDI_FRAG   1024
#define A4_MIDI_RATE   44100
#define A4_SAMPLE_IDS   16
#define A4_SYM(field, name)
#define A4_TEXTPRINTF(align)
#define A4P(b)
#define ALLEGRO_UNSTABLE

Typedefs

typedef void(* fs_delete_f) (void *)
typedef void *(* fs_new_player_f) (void *)
typedef void *(* fs_new_settings_f) (void)
typedef void *(* fs_new_synth_f) (void *)
typedef int(* fs_player_add_f) (void *, const char *)
typedef int(* fs_player_int_f) (void *)
typedef int(* fs_player_set_loop_f) (void *, int)
typedef void *(* fs_set_log_function_f) (int, void *, void *)
typedef int(* fs_settings_setnum_f) (void *, const char *, double)
typedef int(* fs_settings_setstr_f) (void *, const char *, const char *)
typedef int(* fs_sfload_f) (void *, const char *, int)
typedef int(* fs_write_float_f) (void *, int, void *, int, int, void *, int, int)

Functions

static int _a4_align (const char *v, int is_h)
static void _a4_blend_alpha (void)
static void _a4_blend_copy (void)
static void _a4_box (BITMAP *b, float l, float t, float r, float bt, int color)
static int _a4_color_from_pixel (uint32_t p)
static void _a4_compute_scale (void)
static void _a4_destroy_display (void)
static void _a4_done (const BITMAP *b)
static void _a4_draw_region (BITMAP *source, BITMAP *dest, int masked, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, int flags)
static N_MODULE * _a4_fluidsynth_open (void)
static int _a4_fluidsynth_sym (N_MODULE *lib, const char *name, void *fptr, size_t fsize)
static void _a4_flush (void)
static ALLEGRO_FONT * _a4_font (const FONT *f)
static float _a4_gain (int vol)
static BITMAP * _a4_highlight (BITMAP *src)
static void _a4_input_handle (const ALLEGRO_EVENT *ev)
static void * _a4_input_proc (ALLEGRO_THREAD *thr, void *arg)
static int _a4_item_at (const LexMenu *menu, const BITMAP *buf, int mx, int my)
static void _a4_item_rect (const LexMenu *menu, const BITMAP *buf, int i, float *x, float *y, float *w, float *h)
static ALLEGRO_LOCKED_REGION * _a4_lock (BITMAP *b)
static int _a4_midi_init (void)
static void * _a4_midi_proc (ALLEGRO_THREAD *thr, void *arg)
static void _a4_midi_shutdown (void)
static void _a4_midi_stop_locked (void)
static float _a4_pan (int pan)
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)
static void _a4_present (void)
static ALLEGRO_COLOR _a4_prim (int color, int *blend)
static ALLEGRO_COLOR _a4_prim_color (int color)
static void _a4_quad (BITMAP *b, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, int color)
static ALLEGRO_VERTEX * _a4_reserve (BITMAP *b, int blend, int n)
static char * _a4_resolve (const char *path)
static ALLEGRO_COLOR _a4_rgba (int color, int alpha)
static void _a4_rotated (BITMAP *bmp, BITMAP *sprite, float x, float y, float cx, float cy, fixed angle, fixed scale)
static void _a4_set_blend (int blend)
static const char * _a4_soundfont (void)
static ALLEGRO_BITMAP * _a4_source (BITMAP *b, int masked)
static void _a4_sprite (BITMAP *bmp, BITMAP *sprite, int x, int y, int flags)
static char * _a4_strndup (const char *s, size_t n)
static int _a4_take_click (int *x, int *y)
static int _a4_target (BITMAP *b)
static void _a4_text (BITMAP *bmp, const FONT *f, const char *s, int x, int y, int color, int bg, int align)
static void * _a4_timer_proc (ALLEGRO_THREAD *thr, void *arg)
static void _a4_unlock (BITMAP *b)
static void _a4_vertex (ALLEGRO_VERTEX *v, float x, float y, ALLEGRO_COLOR c)
static BITMAP * _a4_wrap (ALLEGRO_BITMAP *abmp)
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 terminated within max bytes; flags is ignored.
void adjust_sample (const SAMPLE *spl, int vol, int pan, int freq, int loop)
 change the settings of the playing instances of a sample
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, the c1 / c2 shortcut keys, Enter (first) or Escape (second): 1 or 2
void allegro_exit (void)
 shut everything down
void allegro_gl_flip (void)
 show the screen bitmap
void allegro_gl_set_allegro_mode (void)
 no-op
void allegro_gl_unset_allegro_mode (void)
 no-op
int allegro_init (void)
 init the layer and Allegro 5
void allegro_message (const char *format,...)
 show a message: a box over the screen, or stderr without a display
int bitmap_color_depth (BITMAP *bmp)
 always 32
int bitmap_mask_color (BITMAP *bmp)
 the mask colour, magenta
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
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_select (BITMAP *bmp)
 no-op
void bmp_unwrite_line (BITMAP *bmp)
 no-op, the bitmap is unlocked when next drawn with the GPU
uintptr_t bmp_write_line (BITMAP *bmp, int y)
 lock the bitmap and return the address of line y, 32 bit ARGB pixels
void circle (BITMAP *bmp, int x, int y, int radius, int color)
 draw a circle outline
void circlefill (BITMAP *bmp, int x, int y, int radius, int color)
 draw a filled circle
void clear (BITMAP *bmp)
 clear to black
void clear_bitmap (BITMAP *bmp)
 clear to black
void clear_keybuf (void)
 empty the readkey() buffer
void clear_to_color (BITMAP *bmp, int color)
 clear to a colour
BITMAP * create_bitmap (int width, int height)
 create a w x h bitmap
BITMAP * create_bitmap_ex (int depth, int width, int height)
 same as create_bitmap(), depth is ignored
BITMAP * create_video_bitmap (int width, int height)
 same as create_bitmap()
void destroy_bitmap (BITMAP *bmp)
 free a bitmap
void destroy_font (FONT *f)
 free a font loaded with load_ttf_font()
void destroy_midi (MIDI *midi)
 free a MIDI song, stopping it if it plays
void destroy_sample (SAMPLE *spl)
 free a sample, stopping it
void draw_sprite (BITMAP *bmp, BITMAP *sprite, int x, int y)
 draw a sprite
void draw_sprite_h_flip (BITMAP *bmp, BITMAP *sprite, int x, int y)
 draw a sprite mirrored horizontally
void draw_sprite_v_flip (BITMAP *bmp, BITMAP *sprite, int x, int y)
 draw a sprite mirrored vertically
void draw_sprite_vh_flip (BITMAP *bmp, BITMAP *sprite, int x, int y)
 draw a sprite mirrored both ways
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 drawing_mode (int mode, BITMAP *pattern, int x_anchor, int y_anchor)
 set the drawing mode of primitives, pattern arguments are ignored
void ellipse (BITMAP *bmp, int x, int y, int rx, int ry, int color)
 draw an ellipse outline
void ellipsefill (BITMAP *bmp, int x, int y, int rx, int ry, int color)
 draw a filled ellipse
void fill_str (char *str, int c, size_t len)
 fill len bytes of str with c
int get_color_depth (void)
 return the color depth (always 32)
void get_mouse_mickeys (int *mickeyx, int *mickeyy)
 movement since the last call
int geta (int c)
 alpha component, 255 for an opaque colour
int getb (int c)
 blue component
int getg (int c)
 green component
int getpixel (BITMAP *bmp, int x, int y)
 read a pixel, -1 outside the bitmap
int getr (int c)
 red 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), components in 0-1 or 0-255; TRUE or FALSE
int gfx_status (int action, int value)
 with GET, MODE_OGL when the current mode is an AllegroGL one, else MODE_STD
void hline (BITMAP *bmp, int x1, int y, int x2, int color)
 draw a horizontal line
int install_allegro_gl (void)
 no-op, the layer always uses Allegro 5's own driver
int install_int (void(*proc)(void), int speed)
 call proc every speed milliseconds, from the timer thread
int install_int_ex (void(*proc)(void), long speed)
 call proc every speed timer ticks, from the timer thread
int install_keyboard (void)
 start the input thread for the keyboard
int install_mouse (void)
 start the input thread for the mouse
int install_sound (int digi, int midi, const char *cfg_path)
 start the audio, cfg_path is ignored
int install_timer (void)
 no-op, timers are always available
int is_memory_bitmap (BITMAP *bmp)
 always FALSE: pixels are reached through bmp_write_line()
int keypressed (void)
 TRUE if a key is waiting in the readkey() buffer.
LexMenu * lexLoadMenuFromFile (const char *file, const char *section)
 load menu section from INI file file, NULL on error
LexMenu * lexMenuDestroy (LexMenu *menu)
 free a menu, returns NULL
BITMAP * lexMenuGetBitmap (LexMenu *menu, int item, int state)
 the image of item item in state state, NULL if there is none
int lexMenuRun (LexMenu *menu, BITMAP *buf)
 run the menu, drawing into buf: the chosen item index, -1 on escape
void line (BITMAP *bmp, int x1, int y1, int x2, int y2, int color)
 draw a line
BITMAP * load_bitmap (const char *filename, RGB *pal)
 load a BMP, PCX, TGA, PNG or JPG file, pal is ignored
MIDI * load_midi (const char *filename)
 load a MIDI file
SAMPLE * load_sample (const char *filename)
 load a WAV, OGG, FLAC or VOC file
FONT * load_ttf_font (const char *filename, int points, int smooth)
 load a TrueType font at the given pixel size
FONT * load_ttf_font_mem (const char *filename, int points, int smooth)
 same as load_ttf_font()
int makeacol (int r, int g, int b, int a)
 make a colour with alpha
int makeacol32 (int r, int g, int b, int a)
 make a colour with alpha
int makecol (int r, int g, int b)
 make an opaque colour
int makecol32 (int r, int g, int b)
 make an opaque colour
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 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 midi_pause (void)
 pause the MIDI song
void midi_resume (void)
 resume 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)
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 play_midi (MIDI *midi, int loop)
 play a MIDI song, replacing the current one, NULL stops
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
int poll_keyboard (void)
 no-op, input is updated by a thread
int poll_mouse (void)
 no-op, input is updated by a thread
void position_mouse (int x, int y)
 move the mouse pointer
void putpixel (BITMAP *bmp, int x, int y, int color)
 write a pixel
int readkey (void)
 wait for a key: (scancode << 8) | ascii
void rect (BITMAP *bmp, int x1, int y1, int x2, int y2, int color)
 draw a rectangle outline
void rectfill (BITMAP *bmp, int x1, int y1, int x2, int y2, int color)
 draw a filled rectangle
void remove_int (void(*proc)(void))
 stop calling proc
void remove_sound (void)
 stop the audio
void rest (unsigned int ms)
 sleep ms milliseconds
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 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 save_bitmap (const char *filename, BITMAP *bmp, const RGB *pal)
 save a bitmap
void set_alpha_blender (void)
 blend with the alpha channel of the source colour or sprite
int set_close_button_callback (void(*proc)(void))
 call proc when the window close button is pressed
void set_color_depth (int depth)
 set the color depth, only 32 is honoured
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 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 set_uformat (int type)
 no-op, kept for source compatibility
void set_volume (int digi_volume, int midi_volume)
 set the volumes (0-255), a negative value leaves one unchanged
void set_window_title (const char *name)
 set the window title
void show_mouse (BITMAP *bmp)
 show the system cursor (bmp != NULL) or hide it (NULL)
void solid_mode (void)
 same as drawing_mode(DRAW_MODE_SOLID, ...)
void stop_midi (void)
 stop the MIDI song
void stop_sample (const SAMPLE *spl)
 stop every playing instance of a sample
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
void stretch_sprite (BITMAP *bmp, BITMAP *sprite, int x, int y, int w, int h)
 draw a sprite scaled to w x h
int text_height (const FONT *f)
 height of the font in pixels
int text_length (const FONT *f, const char *str)
 width of str in pixels
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 textout_ex (BITMAP *bmp, const FONT *f, const char *s, int x, int y, int color, int bg)
 draw a string
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
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
void textprintf_ex (BITMAP *bmp, const FONT *f, int x, int y, int color, int bg, const char *format,...)
 draw a formatted string
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
void triangle (BITMAP *bmp, int x1, int y1, int x2, int y2, int x3, int y3, int color)
 draw a filled triangle
int ustricmp (const char *s1, const char *s2)
 case insensitive string compare
void vline (BITMAP *bmp, int x, int y1, int y2, int color)
 draw a vertical line

Variables

static int a4_alpha_blender = 0
static ALLEGRO_VERTEX a4_batch [6144]
static int a4_batch_blend = 0
static int a4_batch_n = 0
static BITMAP * a4_batch_target = NULL
static int a4_click_pending = 0
static int a4_click_x = 0
static int a4_click_y = 0
static void(* a4_close_cb )(void) = NULL
static volatile int a4_close_requested = 0
static int a4_cursor_shown = 0
static int a4_digi_volume = 255
static ALLEGRO_DISPLAY * a4_display = NULL
static int a4_draw_mode = 0
struct { 
MIDI * current
fs_delete_f delete_player
fs_delete_f delete_settings
fs_delete_f delete_synth
N_MODULE * lib
ALLEGRO_MUTEX * mutex
fs_new_player_f new_player
fs_new_settings_f new_settings
fs_new_synth_f new_synth
int ok
int paused
void * player
fs_player_add_f player_add
fs_player_int_f player_play
fs_player_set_loop_f player_set_loop
fs_player_int_f player_stop
ALLEGRO_EVENT_QUEUE * queue
fs_set_log_function_f set_log_function
fs_settings_setnum_f setnum
fs_settings_setstr_f setstr
void * settings
fs_sfload_f sfload
ALLEGRO_AUDIO_STREAM * stream
void * synth
fs_player_int_f system_reset
ALLEGRO_THREAD * thread
int tried
fs_write_float_f write_float
} a4_fs
static int a4_gl_mode = 0
static int a4_inited = 0
static ALLEGRO_MUTEX * a4_input_mutex = NULL
static ALLEGRO_EVENT_QUEUE * a4_input_queue = NULL
static ALLEGRO_THREAD * a4_input_thread = NULL
static int a4_keybuf [64]
static int a4_keybuf_count = 0
static int a4_keybuf_start = 0
static int a4_mickey_x = 0
static int a4_mickey_y = 0
static int a4_midi_volume = 255
static float a4_off_x = 0.0f
static float a4_off_y = 0.0f
static float a4_scale = 1.0f
static int a4_screen_dirty = 0
static int a4_sound_ok = 0
static ALLEGRO_MUTEX * a4_timer_mutex = NULL
static ALLEGRO_THREAD * a4_timer_thread = NULL
static A4_TIMER a4_timers [16]
static int a4_trans_alpha = 255
char allegro_error [256] = ""
 last error message, as in Allegro 4
FONT * font = NULL
 the default 8x8 font, valid after allegro_init()
volatile char key [227]
 TRUE while the key is held.
volatile int key_shifts = 0
 modifier flags, unused
volatile int mouse_b = 0
 button flags: 1 left, 2 right, 4 middle
volatile int mouse_x = 0
 mouse x in screen coordinates
volatile int mouse_y = 0
 mouse y in screen coordinates
volatile int mouse_z = 0
 mouse wheel position
BITMAP * screen = NULL
 the screen, valid after set_gfx_mode()

Detailed Description

Allegro 4 compatibility layer on top of Allegro 5.

Author
Castagnier Mickael
Version
1.0
Date
08/10/2026

Definition in file n_allegro_4.c.


Data Structure Documentation

◆ A4_BMP

struct A4_BMP

Definition at line 84 of file n_allegro_4.c.

Collaboration diagram for A4_BMP:
Data Fields
ALLEGRO_BITMAP * bmp
int is_screen
ALLEGRO_LOCKED_REGION * lock
ALLEGRO_BITMAP * masked
int masked_dirty

◆ A4_TIMER

struct A4_TIMER

Definition at line 162 of file n_allegro_4.c.

Collaboration diagram for A4_TIMER:
Data Fields
double next
double period
void(*)(void) proc

◆ FONT

struct FONT

a font: the built in one, or a TTF font loaded with load_ttf_font()

Definition at line 98 of file n_allegro_4.c.

Collaboration diagram for FONT:
Data Fields
ALLEGRO_FONT * f

◆ LEX_ITEM

struct LEX_ITEM

Definition at line 2054 of file n_allegro_4.c.

Collaboration diagram for LEX_ITEM:
Data Fields
int h_align
BITMAP * image
BITMAP * over
SAMPLE * sound
int v_align
int x
int y

◆ LexMenu

struct LexMenu

an INI driven menu

Definition at line 2064 of file n_allegro_4.c.

Collaboration diagram for LexMenu:
Data Fields
BITMAP * bg
LEX_ITEM * items
int nb_items
int selected

◆ MIDI

struct MIDI

a MIDI song

Definition at line 112 of file n_allegro_4.c.

Collaboration diagram for MIDI:
Data Fields
char * path

◆ SAMPLE

struct SAMPLE

a sound sample

Examples
ex_gui_md.c.

Definition at line 104 of file n_allegro_4.c.

Collaboration diagram for SAMPLE:
Data Fields
ALLEGRO_SAMPLE_ID ids[16]
int next
ALLEGRO_SAMPLE * spl
int used[16]

Macro Definition Documentation

◆ A4_BATCH_MAX

#define A4_BATCH_MAX   6144

Definition at line 459 of file n_allegro_4.c.

Referenced by _a4_reserve().

◆ A4_BLEND_ALPHA

#define A4_BLEND_ALPHA   1

Definition at line 277 of file n_allegro_4.c.

Referenced by _a4_prim(), and _a4_set_blend().

◆ A4_BLEND_COPY

#define A4_BLEND_COPY   0

Definition at line 276 of file n_allegro_4.c.

Referenced by _a4_prim(), _a4_prim_color(), _a4_quad(), and triangle().

◆ A4_BLEND_FADE

#define A4_BLEND_FADE   2

Definition at line 278 of file n_allegro_4.c.

Referenced by _a4_prim(), and _a4_set_blend().

◆ A4_KEYBUF_SIZE

#define A4_KEYBUF_SIZE   64

Definition at line 147 of file n_allegro_4.c.

Referenced by _a4_input_handle(), and readkey().

◆ A4_MASK_COLOR

#define A4_MASK_COLOR   0x00FF00FF

Definition at line 81 of file n_allegro_4.c.

Referenced by bitmap_mask_color().

◆ A4_MAX_TIMERS

#define A4_MAX_TIMERS   16

Definition at line 161 of file n_allegro_4.c.

Referenced by _a4_timer_proc(), install_int_ex(), and remove_int().

◆ A4_MIDI_FRAG

#define A4_MIDI_FRAG   1024

Definition at line 1757 of file n_allegro_4.c.

Referenced by _a4_midi_init(), and _a4_midi_proc().

◆ A4_MIDI_RATE

#define A4_MIDI_RATE   44100

Definition at line 1756 of file n_allegro_4.c.

Referenced by _a4_midi_init().

◆ A4_SAMPLE_IDS

#define A4_SAMPLE_IDS   16

Definition at line 103 of file n_allegro_4.c.

Referenced by adjust_sample(), play_sample(), and stop_sample().

◆ A4_SYM

#define A4_SYM ( field,
name )
Value:
ok = ok && _a4_fluidsynth_sym(a4_fs.lib, name, &a4_fs.field, sizeof(a4_fs.field))
static struct @346262156126311217342151060122117020361320217156 a4_fs
static int _a4_fluidsynth_sym(N_MODULE *lib, const char *name, void *fptr, size_t fsize)

Definition at line 1784 of file n_allegro_4.c.

Referenced by _a4_midi_init().

◆ A4_TEXTPRINTF

#define A4_TEXTPRINTF ( align)
Value:
char buf[1024]; \
va_list ap; \
va_start(ap, format); \
vsnprintf(buf, sizeof(buf), format, ap); \
va_end(ap); \
_a4_text(bmp, f, buf, x, y, color, bg, align);

Definition at line 1366 of file n_allegro_4.c.

Referenced by textprintf_centre_ex(), textprintf_ex(), and textprintf_right_ex().

◆ A4P

◆ ALLEGRO_UNSTABLE

#define ALLEGRO_UNSTABLE

Definition at line 28 of file n_allegro_4.c.

Typedef Documentation

◆ fs_delete_f

typedef void(* fs_delete_f) (void *)

Definition at line 1722 of file n_allegro_4.c.

◆ fs_new_player_f

typedef void *(* fs_new_player_f) (void *)

Definition at line 1717 of file n_allegro_4.c.

◆ fs_new_settings_f

typedef void *(* fs_new_settings_f) (void)

Definition at line 1712 of file n_allegro_4.c.

◆ fs_new_synth_f

typedef void *(* fs_new_synth_f) (void *)

Definition at line 1715 of file n_allegro_4.c.

◆ fs_player_add_f

typedef int(* fs_player_add_f) (void *, const char *)

Definition at line 1718 of file n_allegro_4.c.

◆ fs_player_int_f

typedef int(* fs_player_int_f) (void *)

Definition at line 1719 of file n_allegro_4.c.

◆ fs_player_set_loop_f

typedef int(* fs_player_set_loop_f) (void *, int)

Definition at line 1720 of file n_allegro_4.c.

◆ fs_set_log_function_f

typedef void *(* fs_set_log_function_f) (int, void *, void *)

Definition at line 1723 of file n_allegro_4.c.

◆ fs_settings_setnum_f

typedef int(* fs_settings_setnum_f) (void *, const char *, double)

Definition at line 1713 of file n_allegro_4.c.

◆ fs_settings_setstr_f

typedef int(* fs_settings_setstr_f) (void *, const char *, const char *)

Definition at line 1714 of file n_allegro_4.c.

◆ fs_sfload_f

typedef int(* fs_sfload_f) (void *, const char *, int)

Definition at line 1716 of file n_allegro_4.c.

◆ fs_write_float_f

typedef int(* fs_write_float_f) (void *, int, void *, int, int, void *, int, int)

Definition at line 1721 of file n_allegro_4.c.

Function Documentation

◆ _a4_align()

int _a4_align ( const char * v,
int is_h )
static

Definition at line 2071 of file n_allegro_4.c.

Referenced by lexLoadMenuFromFile().

Here is the caller graph for this function:

◆ _a4_blend_alpha()

void _a4_blend_alpha ( void )
static

Definition at line 425 of file n_allegro_4.c.

Referenced by _a4_draw_region(), _a4_rotated(), _a4_set_blend(), draw_trans_sprite(), and lexMenuRun().

Here is the caller graph for this function:

◆ _a4_blend_copy()

void _a4_blend_copy ( void )
static

Definition at line 430 of file n_allegro_4.c.

Referenced by _a4_draw_region(), _a4_highlight(), and _a4_set_blend().

Here is the caller graph for this function:

◆ _a4_box()

void _a4_box ( BITMAP * b,
float l,
float t,
float r,
float bt,
int color )
static

Definition at line 515 of file n_allegro_4.c.

References _a4_quad().

Referenced by line(), putpixel(), rect(), and rectfill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_color_from_pixel()

int _a4_color_from_pixel ( uint32_t p)
static

Definition at line 265 of file n_allegro_4.c.

Referenced by getpixel().

Here is the caller graph for this function:

◆ _a4_compute_scale()

void _a4_compute_scale ( void )
static

Definition at line 705 of file n_allegro_4.c.

References a4_display, a4_off_x, a4_off_y, a4_scale, and screen.

Referenced by set_gfx_mode().

Here is the caller graph for this function:

◆ _a4_destroy_display()

void _a4_destroy_display ( void )
static

Definition at line 645 of file n_allegro_4.c.

References a4_display, a4_input_queue, destroy_bitmap(), and screen.

Referenced by allegro_exit(), and set_gfx_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_done()

void _a4_done ( const BITMAP * b)
static

Definition at line 375 of file n_allegro_4.c.

References _a4_present(), a4_gl_mode, A4P, and BITMAP::priv.

Referenced by _a4_draw_region(), _a4_rotated(), _a4_text(), circle(), circlefill(), clear_to_color(), draw_trans_sprite(), ellipse(), ellipsefill(), line(), putpixel(), rect(), rectfill(), and triangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_draw_region()

void _a4_draw_region ( BITMAP * source,
BITMAP * dest,
int masked,
float sx,
float sy,
float sw,
float sh,
float dx,
float dy,
float dw,
float dh,
int flags )
static

Definition at line 1029 of file n_allegro_4.c.

References _a4_blend_alpha(), _a4_blend_copy(), _a4_done(), _a4_source(), and _a4_target().

Referenced by _a4_sprite(), blit(), masked_blit(), masked_stretch_blit(), stretch_blit(), and stretch_sprite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_fluidsynth_open()

N_MODULE * _a4_fluidsynth_open ( void )
static

Definition at line 1759 of file n_allegro_4.c.

References n_module_open().

Referenced by _a4_midi_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_fluidsynth_sym()

int _a4_fluidsynth_sym ( N_MODULE * lib,
const char * name,
void * fptr,
size_t fsize )
static

Definition at line 1777 of file n_allegro_4.c.

References n_module_symbol().

Referenced by _a4_midi_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_flush()

void _a4_flush ( void )
static

Definition at line 465 of file n_allegro_4.c.

References _a4_set_blend(), a4_batch, a4_batch_blend, a4_batch_n, a4_batch_target, and A4P.

Referenced by _a4_lock(), _a4_present(), _a4_reserve(), _a4_source(), and _a4_target().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_font()

ALLEGRO_FONT * _a4_font ( const FONT * f)
static

Definition at line 1318 of file n_allegro_4.c.

References FONT::f, and font.

Referenced by _a4_text(), text_height(), and text_length().

Here is the caller graph for this function:

◆ _a4_gain()

float _a4_gain ( int vol)
static

Definition at line 1673 of file n_allegro_4.c.

References a4_digi_volume.

Referenced by adjust_sample(), and play_sample().

Here is the caller graph for this function:

◆ _a4_highlight()

BITMAP * _a4_highlight ( BITMAP * src)
static

Definition at line 2080 of file n_allegro_4.c.

References _a4_blend_copy(), _a4_source(), _a4_target(), create_bitmap(), BITMAP::h, and BITMAP::w.

Referenced by lexLoadMenuFromFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_input_handle()

void _a4_input_handle ( const ALLEGRO_EVENT * ev)
static

◆ _a4_input_proc()

void * _a4_input_proc ( ALLEGRO_THREAD * thr,
void * arg )
static

Definition at line 576 of file n_allegro_4.c.

References _a4_input_handle(), and a4_input_queue.

Referenced by allegro_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_item_at()

int _a4_item_at ( const LexMenu * menu,
const BITMAP * buf,
int mx,
int my )
static

Definition at line 2175 of file n_allegro_4.c.

References _a4_item_rect(), and LexMenu::nb_items.

Referenced by lexMenuRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_item_rect()

void _a4_item_rect ( const LexMenu * menu,
const BITMAP * buf,
int i,
float * x,
float * y,
float * w,
float * h )
static

Definition at line 2152 of file n_allegro_4.c.

References LexMenu::bg, BITMAP::h, LEX_ITEM::h_align, LEX_ITEM::image, LexMenu::items, LEX_ITEM::v_align, BITMAP::w, LEX_ITEM::x, and LEX_ITEM::y.

Referenced by _a4_item_at(), and lexMenuRun().

Here is the caller graph for this function:

◆ _a4_lock()

ALLEGRO_LOCKED_REGION * _a4_lock ( BITMAP * b)
static

Definition at line 353 of file n_allegro_4.c.

References _a4_flush(), A4P, A4_BMP::bmp, and A4_BMP::lock.

Referenced by bmp_read_line(), bmp_write_line(), getpixel(), and putpixel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_midi_init()

int _a4_midi_init ( void )
static

Definition at line 1827 of file n_allegro_4.c.

References _a4_fluidsynth_open(), _a4_fluidsynth_sym(), _a4_midi_proc(), _a4_soundfont(), a4_fs, A4_MIDI_FRAG, A4_MIDI_RATE, a4_midi_volume, a4_sound_ok, A4_SYM, LOG_DEBUG, LOG_NOTICE, and n_log.

Referenced by play_midi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_midi_proc()

void * _a4_midi_proc ( ALLEGRO_THREAD * thr,
void * arg )
static

Definition at line 1807 of file n_allegro_4.c.

References a4_fs, and A4_MIDI_FRAG.

Referenced by _a4_midi_init().

Here is the caller graph for this function:

◆ _a4_midi_shutdown()

void _a4_midi_shutdown ( void )
static

Definition at line 1904 of file n_allegro_4.c.

References _a4_midi_stop_locked(), a4_fs, and n_module_close().

Referenced by remove_sound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_midi_stop_locked()

void _a4_midi_stop_locked ( void )
static

Definition at line 1893 of file n_allegro_4.c.

References a4_fs.

Referenced by _a4_midi_shutdown(), play_midi(), and stop_midi().

Here is the caller graph for this function:

◆ _a4_pan()

float _a4_pan ( int pan)
static

Definition at line 1677 of file n_allegro_4.c.

Referenced by adjust_sample(), and play_sample().

Here is the caller graph for this function:

◆ _a4_present()

void _a4_present ( void )
static

Definition at line 761 of file n_allegro_4.c.

References _a4_flush(), _a4_source(), a4_display, a4_off_x, a4_off_y, a4_scale, a4_screen_dirty, and screen.

Referenced by _a4_done(), alert(), allegro_gl_flip(), allegro_message(), gfx_mode(), lexMenuRun(), and set_gfx_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_prim()

ALLEGRO_COLOR _a4_prim ( int color,
int * blend )
static

Definition at line 292 of file n_allegro_4.c.

References _a4_pixel_from_color(), _a4_rgba(), a4_alpha_blender, A4_BLEND_ALPHA, A4_BLEND_COPY, A4_BLEND_FADE, a4_draw_mode, a4_trans_alpha, and DRAW_MODE_TRANS.

Referenced by _a4_prim_color(), _a4_quad(), and triangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_prim_color()

ALLEGRO_COLOR _a4_prim_color ( int color)
static

Definition at line 445 of file n_allegro_4.c.

References _a4_prim(), _a4_set_blend(), and A4_BLEND_COPY.

Referenced by circle(), circlefill(), ellipse(), and ellipsefill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_quad()

void _a4_quad ( BITMAP * b,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
float x4,
float y4,
int color )
static

Definition at line 502 of file n_allegro_4.c.

References _a4_prim(), _a4_reserve(), _a4_vertex(), and A4_BLEND_COPY.

Referenced by _a4_box(), and line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_reserve()

ALLEGRO_VERTEX * _a4_reserve ( BITMAP * b,
int blend,
int n )
static

Definition at line 477 of file n_allegro_4.c.

References _a4_flush(), _a4_unlock(), a4_batch, a4_batch_blend, A4_BATCH_MAX, a4_batch_n, a4_batch_target, a4_screen_dirty, A4P, A4_BMP::is_screen, and A4_BMP::masked_dirty.

Referenced by _a4_quad(), and triangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_resolve()

char * _a4_resolve ( const char * path)
static

Definition at line 186 of file n_allegro_4.c.

Referenced by lexLoadMenuFromFile(), load_bitmap(), load_midi(), load_sample(), and load_ttf_font().

Here is the caller graph for this function:

◆ _a4_rgba()

ALLEGRO_COLOR _a4_rgba ( int color,
int alpha )
static

Definition at line 270 of file n_allegro_4.c.

Referenced by _a4_prim(), _a4_text(), and clear_to_color().

Here is the caller graph for this function:

◆ _a4_rotated()

void _a4_rotated ( BITMAP * bmp,
BITMAP * sprite,
float x,
float y,
float cx,
float cy,
fixed angle,
fixed scale )
static

Definition at line 1110 of file n_allegro_4.c.

References _a4_blend_alpha(), _a4_done(), _a4_source(), _a4_target(), and fixtof.

Referenced by pivot_scaled_sprite(), pivot_sprite(), rotate_scaled_sprite(), and rotate_sprite().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_set_blend()

void _a4_set_blend ( int blend)
static

Definition at line 434 of file n_allegro_4.c.

References _a4_blend_alpha(), _a4_blend_copy(), A4_BLEND_ALPHA, and A4_BLEND_FADE.

Referenced by _a4_flush(), and _a4_prim_color().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_soundfont()

const char * _a4_soundfont ( void )
static

Definition at line 1786 of file n_allegro_4.c.

Referenced by _a4_midi_init().

Here is the caller graph for this function:

◆ _a4_source()

ALLEGRO_BITMAP * _a4_source ( BITMAP * b,
int masked )
static

Definition at line 380 of file n_allegro_4.c.

References _a4_flush(), _a4_unlock(), A4P, A4_BMP::bmp, BITMAP::h, A4_BMP::masked, A4_BMP::masked_dirty, BITMAP::priv, and BITMAP::w.

Referenced by _a4_draw_region(), _a4_highlight(), _a4_present(), _a4_rotated(), draw_trans_sprite(), and lexMenuRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_sprite()

void _a4_sprite ( BITMAP * bmp,
BITMAP * sprite,
int x,
int y,
int flags )
static

Definition at line 1070 of file n_allegro_4.c.

References _a4_draw_region(), BITMAP::h, and BITMAP::w.

Referenced by draw_sprite(), draw_sprite_h_flip(), draw_sprite_v_flip(), and draw_sprite_vh_flip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_strndup()

char * _a4_strndup ( const char * s,
size_t n )
static

Definition at line 248 of file n_allegro_4.c.

Referenced by allegro_message().

Here is the caller graph for this function:

◆ _a4_take_click()

int _a4_take_click ( int * x,
int * y )
static

Definition at line 801 of file n_allegro_4.c.

References a4_click_pending, a4_click_x, a4_click_y, and a4_input_mutex.

Referenced by alert(), allegro_message(), and lexMenuRun().

Here is the caller graph for this function:

◆ _a4_target()

int _a4_target ( BITMAP * b)
static

Definition at line 363 of file n_allegro_4.c.

References _a4_flush(), _a4_unlock(), a4_screen_dirty, A4P, A4_BMP::bmp, A4_BMP::is_screen, A4_BMP::masked_dirty, and BITMAP::priv.

Referenced by _a4_draw_region(), _a4_highlight(), _a4_rotated(), _a4_text(), circle(), circlefill(), clear_to_color(), draw_trans_sprite(), ellipse(), ellipsefill(), and lexMenuRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_text()

void _a4_text ( BITMAP * bmp,
const FONT * f,
const char * s,
int x,
int y,
int color,
int bg,
int align )
static

Definition at line 1334 of file n_allegro_4.c.

References _a4_done(), _a4_font(), _a4_rgba(), _a4_target(), a4_draw_mode, DRAW_MODE_SOLID, mode, and rectfill().

Referenced by textout_centre_ex(), textout_ex(), and textout_right_ex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _a4_timer_proc()

void * _a4_timer_proc ( ALLEGRO_THREAD * thr,
void * arg )
static

Definition at line 585 of file n_allegro_4.c.

References A4_MAX_TIMERS, a4_timer_mutex, and a4_timers.

Referenced by allegro_init().

Here is the caller graph for this function:

◆ _a4_unlock()

void _a4_unlock ( BITMAP * b)
static

Definition at line 344 of file n_allegro_4.c.

References A4P, A4_BMP::bmp, A4_BMP::lock, and BITMAP::priv.

Referenced by _a4_reserve(), _a4_source(), _a4_target(), destroy_bitmap(), and save_bitmap().

Here is the caller graph for this function:

◆ _a4_vertex()

void _a4_vertex ( ALLEGRO_VERTEX * v,
float x,
float y,
ALLEGRO_COLOR c )
static

Definition at line 492 of file n_allegro_4.c.

Referenced by _a4_quad(), and triangle().

Here is the caller graph for this function:

◆ _a4_wrap()

BITMAP * _a4_wrap ( ALLEGRO_BITMAP * abmp)
static

Definition at line 403 of file n_allegro_4.c.

References A4_BMP::bmp, Free, BITMAP::h, BITMAP::line, Malloc, A4_BMP::masked_dirty, BITMAP::priv, and BITMAP::w.

Referenced by create_bitmap(), and load_bitmap().

Here is the caller graph for this function:

Variable Documentation

◆ a4_alpha_blender

int a4_alpha_blender = 0
static

Definition at line 140 of file n_allegro_4.c.

Referenced by _a4_prim(), draw_trans_sprite(), set_alpha_blender(), and set_trans_blender().

◆ a4_batch

ALLEGRO_VERTEX a4_batch[6144]
static

Definition at line 460 of file n_allegro_4.c.

Referenced by _a4_flush(), and _a4_reserve().

◆ a4_batch_blend

int a4_batch_blend = 0
static

Definition at line 463 of file n_allegro_4.c.

Referenced by _a4_flush(), and _a4_reserve().

◆ a4_batch_n

int a4_batch_n = 0
static

Definition at line 461 of file n_allegro_4.c.

Referenced by _a4_flush(), _a4_reserve(), and destroy_bitmap().

◆ a4_batch_target

BITMAP* a4_batch_target = NULL
static

Definition at line 462 of file n_allegro_4.c.

Referenced by _a4_flush(), _a4_reserve(), and destroy_bitmap().

◆ a4_click_pending

int a4_click_pending = 0
static

Definition at line 156 of file n_allegro_4.c.

Referenced by _a4_input_handle(), and _a4_take_click().

◆ a4_click_x

int a4_click_x = 0
static

Definition at line 157 of file n_allegro_4.c.

Referenced by _a4_input_handle(), and _a4_take_click().

◆ a4_click_y

int a4_click_y = 0
static

Definition at line 158 of file n_allegro_4.c.

Referenced by _a4_input_handle(), and _a4_take_click().

◆ a4_close_cb

void(* a4_close_cb) (void) ( void ) = NULL
static

Definition at line 133 of file n_allegro_4.c.

Referenced by _a4_input_handle(), and set_close_button_callback().

◆ a4_close_requested

volatile int a4_close_requested = 0
static

Definition at line 153 of file n_allegro_4.c.

Referenced by _a4_input_handle(), alert(), allegro_message(), and lexMenuRun().

◆ a4_cursor_shown

int a4_cursor_shown = 0
static

Definition at line 132 of file n_allegro_4.c.

Referenced by alert(), lexMenuRun(), set_gfx_mode(), and show_mouse().

◆ a4_digi_volume

int a4_digi_volume = 255
static

Definition at line 173 of file n_allegro_4.c.

Referenced by _a4_gain(), and set_volume().

◆ a4_display

ALLEGRO_DISPLAY* a4_display = NULL
static

◆ a4_draw_mode

int a4_draw_mode = 0
static

◆ [struct]

◆ a4_gl_mode

int a4_gl_mode = 0
static

◆ a4_inited

◆ a4_input_mutex

ALLEGRO_MUTEX* a4_input_mutex = NULL
static

◆ a4_input_queue

ALLEGRO_EVENT_QUEUE* a4_input_queue = NULL
static

◆ a4_input_thread

ALLEGRO_THREAD* a4_input_thread = NULL
static

Definition at line 145 of file n_allegro_4.c.

Referenced by allegro_exit(), and allegro_init().

◆ a4_keybuf

int a4_keybuf[64]
static

Definition at line 148 of file n_allegro_4.c.

Referenced by _a4_input_handle(), and readkey().

◆ a4_keybuf_count

int a4_keybuf_count = 0
static

Definition at line 150 of file n_allegro_4.c.

Referenced by _a4_input_handle(), clear_keybuf(), keypressed(), and readkey().

◆ a4_keybuf_start

int a4_keybuf_start = 0
static

Definition at line 149 of file n_allegro_4.c.

Referenced by _a4_input_handle(), clear_keybuf(), and readkey().

◆ a4_mickey_x

int a4_mickey_x = 0
static

Definition at line 151 of file n_allegro_4.c.

Referenced by _a4_input_handle(), and get_mouse_mickeys().

◆ a4_mickey_y

int a4_mickey_y = 0
static

Definition at line 152 of file n_allegro_4.c.

Referenced by _a4_input_handle(), and get_mouse_mickeys().

◆ a4_midi_volume

int a4_midi_volume = 255
static

Definition at line 174 of file n_allegro_4.c.

Referenced by _a4_midi_init(), and set_volume().

◆ a4_off_x

float a4_off_x = 0.0f
static

Definition at line 136 of file n_allegro_4.c.

Referenced by _a4_compute_scale(), _a4_input_handle(), _a4_present(), and position_mouse().

◆ a4_off_y

float a4_off_y = 0.0f
static

Definition at line 137 of file n_allegro_4.c.

Referenced by _a4_compute_scale(), _a4_input_handle(), _a4_present(), and position_mouse().

◆ a4_scale

float a4_scale = 1.0f
static

Definition at line 135 of file n_allegro_4.c.

Referenced by _a4_compute_scale(), _a4_input_handle(), _a4_present(), and position_mouse().

◆ a4_screen_dirty

int a4_screen_dirty = 0
static

◆ a4_sound_ok

int a4_sound_ok = 0
static

◆ a4_timer_mutex

ALLEGRO_MUTEX* a4_timer_mutex = NULL
static

Definition at line 169 of file n_allegro_4.c.

Referenced by _a4_timer_proc(), allegro_exit(), allegro_init(), install_int_ex(), and remove_int().

◆ a4_timer_thread

ALLEGRO_THREAD* a4_timer_thread = NULL
static

Definition at line 168 of file n_allegro_4.c.

Referenced by allegro_exit(), and allegro_init().

◆ a4_timers

A4_TIMER a4_timers[16]
static

Definition at line 167 of file n_allegro_4.c.

Referenced by _a4_timer_proc(), allegro_init(), install_int_ex(), and remove_int().

◆ a4_trans_alpha

int a4_trans_alpha = 255
static

Definition at line 141 of file n_allegro_4.c.

Referenced by _a4_prim(), draw_trans_sprite(), and set_trans_blender().