| maug
    Quick and dirty C mini-augmentation library. | 
Abstraction layer header for retro systems. More...
#include <stdarg.h>#include <marge.h>#include <retapis.h>#include <retapii.h>#include <retapid.h>#include "retrom2d.h"
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_3DTEX | 
| struct | RETROFLAT_ARGS | 
| Struct containing configuration values for a RetroFlat program.  More... | |
| struct | RETROFLAT_VIEWPORT | 
| The viewport data struct.  More... | |
| struct | RETROFLAT_STATE | 
| Global singleton containing state for the current platform.  More... | |
| Macros | |
| #define | RETROFLAT_BITMAP_TRACE_LVL 0 | 
| #define | RETROINPUT_TRACE_LVL 0 | 
| #define | RETROFLAT_COLOR_TABLE(f) | 
| This macro defines all colors supported by RetroFlat for primative operations, particularly using retroflat_px().  More... | |
| #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() or retroflat_load_bitmap() to create or load a bitmap without transparency. | |
| #define | RETROFLAT_FLAGS_LITERAL_PATH 0x02 | 
| Flag for retroflat_load_bitmap() to not use assets path. | |
| #define | RETROFLAT_FLAGS_BITMAP_SILENT 0x04 | 
| flag for retroflat_load_bitmap() to not show an error dialog if a bitmap fails to load (on supported platforms). | |
| #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.  More... | |
| #define | RETROFLAT_FLAGS_SCREEN_BUFFER 0x80 | 
| Flag for retroflat_create_bitmap() to create a WinG-backed bitmap.  More... | |
| #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!)  More... | |
| #define | RETROFLAT_FLAGS_LOCK 0x08 | 
| #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) (instance * -1) | 
| Declare that a given instance ID is for a tile, rather than a sprite. | |
| #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_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.  More... | |
| #define | retroflat_fps_next() (1000 / RETROFLAT_FPS) | 
| #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_TITLE_MAX 255 | 
| #define | RETROFLAT_VDP_ARGS_SZ_MAX 255 | 
| #define | RETROFLAT_PATH_SEP '/' | 
| The valid path separator on the target platform. | |
| #define | RETROFLAT_BMP_COLORS_SZ_MAX 256 | 
| #define | retroflat_wait_for_frame() (g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_WAIT_FOR_FPS) | 
| #define | retroflat_is_waiting_for_frame() | 
| #define | retroflat_buffer_bksp(buffer, buffer_cur, buffer_sz) | 
| Remove a character from a text buffer before cursor position.  More... | |
| #define | retroflat_buffer_insert(c, buffer, buffer_cur, buffer_sz, buffer_mx) | 
| Insert a character into a text buffer at cursor position.  More... | |
| #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_NONE (-1) | 
| #define | RETROFLAT_DIR4_NORTH 0 | 
| #define | RETROFLAT_DIR4_EAST 1 | 
| #define | RETROFLAT_DIR4_SOUTH 2 | 
| #define | RETROFLAT_DIR4_WEST 3 | 
| #define | RETROFLAT_DIR8_NONE (-1) | 
| #define | RETROFLAT_DIR8_NORTH 0 | 
| #define | RETROFLAT_DIR8_EAST 2 | 
| #define | RETROFLAT_DIR8_SOUTH 4 | 
| #define | RETROFLAT_DIR8_WEST 6 | 
| #define | retroflat_dir4_rotate_cw(dir) ((dir + 1) % 4) | 
| #define | retroflat_dir8_reverse(dir) ((dir + 4) % 8) | 
| #define | retroflat_dir8_bounce(dir) ((dir + 2) % 8) | 
| #define | PXXY_FMT SIZE_T_FMT | 
| #define | RETRO2D_TRACE_LVL 0 | 
| #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_case_key(key, pad) case pad: case key: | 
| Specify cases for a select() on the result of retroflat_poll_input() for keyboard or game pad as available.  More... | |
| #define | retroflat_or_key(input, key, pad) (((input) == (pad)) || ((input) == (key))) | 
| #define | retroflat_system_task() | 
| Platform-specific task that should be called on every iteration of the generic loop. This prevents having to define a platform-specific loop just to add a single call. | |
| #define | retroflat_screen_colors() (g_retroflat_state->screen_colors) | 
| #define | retroflat_viewport_world_tile_x() retroflat_viewport_world_tile_x_generic() | 
| #define | retroflat_viewport_world_tile_y() retroflat_viewport_world_tile_y_generic() | 
| #define | retroflat_viewport_focus(x1, y1, range, speed) retroflat_viewport_focus_generic( 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.  More... | |
| #define | retroflat_viewport_screen_x(world_x) retroflat_viewport_screen_x_generic( 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) retroflat_viewport_screen_y_generic( world_y ) | 
| Return the screenspace Y coordinate at which something at the given world coordinate should be drawn. | |
| #define | retroflat_viewport_move_x(x) retroflat_viewport_move_x_generic( x ) | 
| #define | retroflat_viewport_move_y(y) retroflat_viewport_move_y_generic( y ) | 
| #define | retroflat_constrain_px(x, y, bmp, retact) | 
| Ensure x and y (which must be unsigned!) are inside image boundaries.  More... | |
| #define | RETROFLAT_COLOR_TABLE_CONSTS(idx, name_l, name_u, r, g, b, cgac, cgad) extern MAUG_CONST RETROFLAT_COLOR SEG_MCONST RETROFLAT_COLOR_ ## name_u; | 
| Typedefs | |
| typedef int16_t | retroflat_tile_t | 
| Value for an individual tile in a RETROTILE_LAYER.  More... | |
| 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.  More... | |
| typedef MERROR_RETVAL(* | retroflat_proc_resize_t) (uint16_t new_w, uint16_t new_h, void *data) | 
| typedef void(* | retroflat_loop_iter) (void *data) | 
| Prototype for the main loop function passed to retroflat_loop(). | |
| typedef int8_t | retroflat_dir4_t | 
| typedef int8_t | retroflat_dir8_t | 
| typedef size_t | retroflat_pxxy_t | 
| Type used for surface pixel coordinates.  More... | |
| typedef maug_ms_t | retroflat_ms_t | 
| Functions | |
| MERROR_RETVAL | retrosnd_init (struct RETROFLAT_ARGS *args) | 
| Initialize retrosnd engine.  More... | |
| 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. | |
| MERROR_RETVAL | retroflat_build_filename_path (const char *filename_in, const char *filename_ext, char *buffer_out, size_t buffer_out_sz, uint8_t flags) | 
| void | retroflat_message (uint8_t flags, const char *title, const char *format,...) | 
| Display a message in a dialog box and/or on stderr.  More... | |
| 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.  More... | |
| 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().  More... | |
| MERROR_RETVAL | retroflat_vdp_call (const char *proc_name) | 
| Call a function from the retroflat VDP. | |
| RETROFLAT_IN_KEY | retroflat_repeat_input (RETROFLAT_IN_KEY key_out, struct RETROFLAT_INPUT *input, RETROFLAT_IN_KEY *prev_input, int *prev_delay) | 
| 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.  More... | |
| 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).  More... | |
| 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.  More... | |
| 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.  More... | |
| 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.  More... | |
| 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.  More... | |
| 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.  More... | |
| 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().  More... | |
| 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.  More... | |
| 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).  More... | |
| 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.  More... | |
| 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 *SEG_MGLOBAL | 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.