maug
Quick and dirty C mini-augmentation library.
|
Abstraction layer header for retro systems. More...
Go to the source code of this file.
Data Structures | |
struct | RETROFLAT_INPUT |
Struct passed to retroflat_poll_input() to hold return data. More... | |
struct | RETROFLAT_ARGS |
Struct containing configuration values for a RetroFlat program. More... | |
struct | RETROFLAT_VIEWPORT |
struct | RETROFLAT_STATE |
Global singleton containing state for the current platform. More... | |
Macros | |
#define | RETROFLAT_BITMAP_TRACE_LVL 0 |
#define | RETROFLAT_KB_TRACE_LVL 0 |
#define | RETROFLAT_COLOR_TABLE(f) |
This macro defines all colors supported by RetroFlat for primative operations, particularly using retroflat_px(). | |
#define | RETROFLAT_COLOR_NULL (-1) |
#define | RETROFLAT_COLORS_SZ 16 |
#define | RETROFLAT_OK 0x00 |
Certain functions return this when there was no problem. | |
#define | RETROFLAT_ERROR_ENGINE 0x01 |
#define | RETROFLAT_ERROR_GRAPHICS 0x02 |
#define | RETROFLAT_ERROR_MOUSE 0x04 |
#define | RETROFLAT_ERROR_BITMAP 0x08 |
Returned if there is a problem loading or locking a RETROFLAT_BITMAP struct. | |
#define | RETROFLAT_ERROR_TIMER 0x0f |
#define | RETROFLAT_FLAGS_FILL 0x01 |
Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled. | |
#define | RETROFLAT_FLAGS_OPAQUE 0x01 |
Flag for retroflat_create_bitmap() to create a bitmap without transparency. | |
#define | RETROFLAT_FLAGS_ALL_CAPS 0x02 |
Flag for retroflat_string() and retroflat_string_sz() to print text in all capital letters. Non-letters are unmodified. | |
#define | RETROFLAT_FLAGS_LITERAL_PATH 0x02 |
Flag for retroflat_load_bitmap() to not use assets path. | |
#define | RETROFLAT_FLAGS_OUTLINE 0x04 |
Flag for retroflat_string() and retroflat_string_sz() to print text as outline-only. | |
#define | RETROFLAT_FLAGS_SCREEN_BUFFER 0x80 |
Flag for retroflat_create_bitmap() to create a WinG-backed bitmap. | |
#define | RETROFLAT_FLAGS_VIEWPORT_REFRESH 0x20 |
Flag for args->flags, indicating that a viewport tile refresh grid should be allocated and used. | |
#define | RETROFLAT_FLAGS_RUNNING 0x01 |
Flag indicating that retroflat_loop() should continue executing. | |
#define | RETROFLAT_FLAGS_UNLOCK_FPS 0x02 |
Flag indicating FPS should not be capped. | |
#define | RETROFLAT_FLAGS_KEY_REPEAT 0x04 |
Flag indicating keyboard repeat is enabled. | |
#define | RETROFLAT_FLAGS_SCREENSAVER 0x08 |
Flag indicating the current application is running as a screensaver. | |
#define | RETROFLAT_FLAGS_SCALE2X 0x10 |
Only supported on some platforms: Attempt to scale screen by 2X. | |
#define | RETROFLAT_FLAGS_WAIT_FOR_FPS 0x20 |
Do not execute any more inter-frame loops until next frame. | |
#define | RETROFLAT_MSG_FLAG_TYPE_MASK 0x07 |
This mask covers all possible icon/type flags. | |
#define | RETROFLAT_MSG_FLAG_ERROR 0x01 |
This icon/type flag indicates an error. It will try to display messages in an urgent way with a red icon, if possible. | |
#define | RETROFLAT_MSG_FLAG_INFO 0x02 |
This icon/type flag indicates an informational notice. It will try to display messages in a definite way, with an i or speech bubble icon, if possible. | |
#define | RETROFLAT_MSG_FLAG_WARNING 0x04 |
This icon/type flag indicates a condition the user should be aware of. It will try to display messages in an urgent way with a yellow icon, if possible. | |
#define | RETROFLAT_VDP_FLAG_PXLOCK 0x01 |
Flag for RETROFLAT_STATE::vdp_flags indicating the VDP requires RetroFlat to pixel-lock the frame before passing it (almost always true!) | |
#define | RETROFLAT_FLAGS_SCREEN_LOCK 0x02 |
#define | RETROFLAT_FLAGS_BITMAP_RO 0x04 |
#define | RETROFLAT_INSTANCE_NULL (0) |
Pass to retroflat_blit_bitmap() instance arg if this is not a sprite (i.e. if it is a background tile). | |
#define | retroflat_instance_tile(instance) |
#define | RETROFLAT_BITMAP_EXT "bmp" |
The filename suffix to be appended with a "." to filenames passed to retroflat_load_bitmap(). Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_OPENGL_BPP 32 |
#define | RETROFLAT_TILE_W 16 |
#define | RETROFLAT_TILE_W_BITS 4 |
#define | RETROFLAT_TILE_H 16 |
#define | RETROFLAT_TILE_H_BITS 4 |
#define | RETROFLAT_TXP_R 0x00 |
Compiler-define-overridable constant indicating the Red value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_TXP_G 0x00 |
Compiler-define-overridable constant indicating the Green value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_TXP_B 0x00 |
Compiler-define-overridable constant indicating the Blue value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_TXP_PAL_IDX 0 |
#define | RETROFLAT_DEFAULT_SCREEN_W 320 |
#define | RETROFLAT_DEFAULT_SCREEN_H 200 |
#define | RETROFLAT_GL_Z -0.001 |
#define | retroflat_on_resize(w, h) |
#define | RETROFLAT_LINE_THICKNESS 1 |
Line drawing thickness (only works on some platforms). Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_PI 3.14159 |
#define | RETROFLAT_FPS 30 |
Target Frames Per Second. | |
#define | retroflat_fps_next() |
#define | RETROFLAT_WINDOW_CLASS "RetroFlatWindowClass" |
Unique window class to use on some platforms (e.g. Win32). Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_WIN_FRAME_TIMER_ID 6001 |
Unique ID for the timer that execute frame draws in Win16/Win32. Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_WIN_LOOP_TIMER_ID 6002 |
Unique ID for the timer that execute loop ticks in Win16/Win32. Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_MSG_MAX 4096 |
Maximum number of characters possible in a message using retroflat_message(). Is a RetroFlat Compiler Definitions. | |
#define | RETROFLAT_PATH_MAX MAUG_PATH_MAX |
#define | RETROFLAT_TITLE_MAX 255 |
#define | RETROFLAT_VDP_ARGS_SZ_MAX 255 |
#define | RETROFLAT_PATH_SEP '/' |
The valid path separator on the target platform. | |
#define | RETROFLAT_ASSETS_PATH_MAX (RETROFLAT_PATH_MAX >> 1) |
Maximum size of the assets path, to allow room for appending. | |
#define | RETROFLAT_BMP_COLORS_SZ_MAX 256 |
#define | retroflat_wait_for_frame() |
#define | retroflat_is_waiting_for_frame() |
#define | retroflat_cmp_asset_path(a, b) |
Compare two asset paths. Return 0 if they're the same. | |
#define | retroflat_buffer_bksp(buffer, buffer_cur, buffer_sz) |
Remove a character from a text buffer before cursor position. | |
#define | retroflat_buffer_insert(c, buffer, buffer_cur, buffer_sz, buffer_mx) |
Insert a character into a text buffer at cursor position. | |
#define | RETROFLAT_INPUT_MOD_SHIFT 0x01 |
#define | RETROFLAT_INPUT_MOD_ALT 0x02 |
#define | RETROFLAT_INPUT_MOD_CTRL 0x04 |
#define | RETROFLAT_INPUT_FORCE_UPPER 0x08 |
#define | RETROFLAT_DIR4_NORTH 0 |
#define | RETROFLAT_DIR4_EAST 1 |
#define | RETROFLAT_DIR4_SOUTH 2 |
#define | RETROFLAT_DIR4_WEST 3 |
#define | RETROFLAT_DIR8_NORTH 0 |
#define | RETROFLAT_DIR8_EAST 2 |
#define | RETROFLAT_DIR8_SOUTH 4 |
#define | RETROFLAT_DIR8_WEST 6 |
#define | retroflat_dir8_reverse(dir) |
#define | retroflat_dir8_bounce(dir) |
#define | RETROSND_TRACE_LVL 0 |
#define | RETROSND_REG_TRACE_LVL 0 |
#define | RETROSND_FLAG_INIT 0x01 |
Flag in RETROSND_STATE::flags indicating initialization was successful. | |
#define | RETROSND_VOICE_BREATH 122 |
#define | RETROSND_VOICE_SEASHORE 123 |
#define | RETROSND_VOICE_BIRD_TWEET 124 |
#define | RETROSND_VOICE_PHONE_RING 125 |
#define | RETROSND_VOICE_HELICOPTER 126 |
#define | RETROSND_VOICE_APPLAUSE 127 |
#define | RETROSND_VOICE_GUNSHOT 128 |
Parameter for retrosnd_midi_set_voice() indicating a gunshot sound effect. | |
#define | RETROSND_CHANNEL_CT 8 |
#define | retroflat_viewport_world_x() |
Return the current viewport X position in the world in pixels. | |
#define | retroflat_viewport_world_y() |
Return the current viewport Y position in the world in pixels. | |
#define | retroflat_viewport_world_w() |
Return the current width of the world in pixels. | |
#define | retroflat_viewport_world_h() |
Return the current height of the world in pixels. | |
#define | retroflat_viewport_screen_tile_w() |
#define | retroflat_viewport_screen_tile_h() |
#define | retroflat_viewport_set_world(w, h) |
Set the pixel width and height of the world so the viewport knows how far it may scroll. | |
#define | retroflat_viewport_set_world_pos(x, y) |
#define | retroflat_viewport_lock_refresh() |
#define | retroflat_viewport_unlock_refresh() |
#define | retroflat_viewport_set_refresh(x, y, tid) |
#define | retroflat_viewport_focus(x1, y1, range, speed) |
Move the viewport in a direction or combination thereof so that it's focusing the given x1/y1 within the given range. | |
#define | retroflat_viewport_screen_x(world_x) |
Return the screenspace X coordinate at which something at the given world coordinate should be drawn. | |
#define | retroflat_viewport_screen_y(world_y) |
Return the screenspace Y coordinate at which something at the given world coordinate should be drawn. | |
#define | retroflat_viewport_move_x(x) |
#define | retroflat_viewport_move_y(y) |
#define | retroflat_constrain_px(x, y, bmp, retact) |
Ensure x and y (which must be unsigned!) are inside image boundaries. | |
#define | RETROFLAT_COLOR_TABLE_CONSTS(idx, name_l, name_u, r, g, b, cgac, cgad) |
Typedefs | |
typedef int8_t | RETROFLAT_COLOR |
Defines an index in the platform-specific color-table. | |
typedef MERROR_RETVAL(* | retroflat_vdp_proc_t) (struct RETROFLAT_STATE *) |
VDP function called from the VDP library. | |
typedef MERROR_RETVAL(* | retroflat_proc_resize_t) (uint16_t new_w, uint16_t new_h, void *data) |
typedef char | retroflat_asset_path[RETROFLAT_PATH_MAX] |
Path/name used to load an asset from disk. | |
typedef void(* | retroflat_loop_iter) (void *data) |
Prototype for the main loop function passed to retroflat_loop(). | |
typedef maug_ms_t | retroflat_ms_t |
typedef int16_t | retroflat_tile_t |
Functions | |
MERROR_RETVAL | retrosnd_init (struct RETROFLAT_ARGS *args) |
Initialize retrosnd engine. | |
void | retrosnd_set_sf_bank (const char *filename_in) |
Set the name of the voice bank filename to use. | |
void | retrosnd_midi_set_voice (uint8_t channel, uint8_t voice) |
void | retrosnd_midi_set_control (uint8_t channel, uint8_t key, uint8_t val) |
void | retrosnd_midi_note_on (uint8_t channel, uint8_t pitch, uint8_t vel) |
void | retrosnd_midi_note_off (uint8_t channel, uint8_t pitch, uint8_t vel) |
MERROR_RETVAL | retrosnd_midi_play_smf (const char *filename) |
uint8_t | retrosnd_midi_is_playing_smf () |
void | retrosnd_shutdown () |
MERROR_RETVAL | retroflat_loop (retroflat_loop_iter frame_iter, retroflat_loop_iter loop_iter, void *data) |
This should be called once in the main body of the program in order to enter the main loop. The main loop will continuously call loop_iter with data as an argument until retroflat_quit() is called. | |
void | retroflat_message (uint8_t flags, const char *title, const char *format,...) |
Display a message in a dialog box and/or on stderr. | |
MERROR_RETVAL | retroflat_init (int argc, char *argv[], struct RETROFLAT_ARGS *args) |
Initialize RetroFlat and its underlying layers. This should be called once at the beginning of the program and should quit if the return value indicates any failures. | |
void | retroflat_shutdown (int retval) |
Deinitialize RetroFlat and its underlying layers. This should be called once at the end of the program, after retroflat_loop(). | |
MERROR_RETVAL | retroflat_vdp_call (const char *proc_name) |
Call a function from the retroflat VDP. | |
void | retroflat_set_title (const char *format,...) |
retroflat_ms_t | retroflat_get_ms () |
uint32_t | retroflat_get_rand () |
char | retroflat_vk_to_ascii (RETROFLAT_IN_KEY k, uint8_t flags) |
MERROR_RETVAL | retroflat_load_bitmap (const char *filename, struct RETROFLAT_BITMAP *bmp_out, uint8_t flags) |
Load a bitmap into the given RETROFLAT_BITMAP structure if it is available. Bitmaps are subject to the limitations enumerated in RetroFlat Bitmap API. | |
MERROR_RETVAL | retroflat_create_bitmap (size_t w, size_t h, struct RETROFLAT_BITMAP *bmp_out, uint8_t flags) |
void | retroflat_destroy_bitmap (struct RETROFLAT_BITMAP *bitmap) |
Unload a bitmap from a RETROFLAT_BITMAP struct. The struct, itself, is not freed (in case it is on the stack). | |
MERROR_RETVAL | retroflat_blit_bitmap (struct RETROFLAT_BITMAP *target, struct RETROFLAT_BITMAP *src, size_t s_x, size_t s_y, int16_t d_x, int16_t d_y, size_t w, size_t h, int16_t instance) |
Blit the contents of a RETROFLAT_BITMAP onto another RETROFLAT_BITMAP. | |
MERROR_RETVAL | retroflat_draw_lock (struct RETROFLAT_BITMAP *bmp) |
Lock a bitmap for drawing. This will be done automatically if necessary and not called explicitly, but performance should improve if done before a batch of drawing operations. | |
MERROR_RETVAL | retroflat_draw_release (struct RETROFLAT_BITMAP *bmp) |
void | retroflat_px (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, size_t x, size_t y, uint8_t flags) |
void | retroflat_rect (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t flags) |
Draw a rectangle onto the target RETROFLAT_BITMAP. | |
void | retroflat_ellipse (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int16_t x, int16_t y, int16_t w, int16_t h, uint8_t flags) |
Draw an ellipse onto the target RETROFLAT_BITMAP. | |
void | retroflat_line (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t flags) |
Draw a straight line onto the target RETROFLAT_BITMAP. | |
void | retroflat_cursor (struct RETROFLAT_BITMAP *target, uint8_t flags) |
void | retroflat_string_sz (struct RETROFLAT_BITMAP *target, const char *str, size_t str_sz, const char *font_str, size_t *w_out, size_t *h_out, uint8_t flags) |
Get the size in pixels of a text string when drawn with a given font by retroflat_string(). | |
void | retroflat_string (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, const char *str, int str_sz, const char *font_str, int16_t x_orig, int16_t y_orig, uint8_t flags) |
Draw a text string at the specified location in the specified font and color on the target RETROFLAT_BITMAP. | |
void | retroflat_get_palette (uint8_t idx, uint32_t *rgb) |
MERROR_RETVAL | retroflat_set_palette (uint8_t idx, uint32_t rgb) |
void | retroflat_set_proc_resize (retroflat_proc_resize_t on_resize_in, void *data_in) |
Set the procedure to call when the window is resized (on platforms that support resizing). | |
void | retroflat_resize_v () |
Platform-specific function to resize virtual screen to match physical window size. | |
RETROFLAT_IN_KEY | retroflat_poll_input (struct RETROFLAT_INPUT *input) |
Poll input devices (keyboard/mouse) and return the latest event. | |
Variables | |
MAUG_CONST int16_t SEG_MCONST | gc_retroflat_offsets8_x [8] |
MAUG_CONST int16_t SEG_MCONST | gc_retroflat_offsets8_y [8] |
MAUG_CONST int16_t SEG_MCONST | gc_retroflat_offsets4_x [4] |
MAUG_CONST int16_t SEG_MCONST | gc_retroflat_offsets4_y [4] |
MAUG_CONST char *SEG_MCONST | gc_retroflat_color_names [] |
struct RETROFLAT_STATE * | g_retroflat_state |
Abstraction layer header for retro systems.
RetroFlat is a compatibility layer for making graphical programs that work on Win16 (32-bit via OpenWatcom's Win386), MS-DOS (32-bit via DOS/32a or DOS4GW via Allegro), and possibly other platforms in the future.
To use, define RETROFLT_C before including this header from your main.c.
You may include this header in other .c files, as well, but RETROFLT_C should ONLY be declared ONCE in the entire program.
maug.h should also be included before this header.