6# define RETROFLAT_BMP_TEX
280#ifndef RETROFLAT_BITMAP_TRACE_LVL
281# define RETROFLAT_BITMAP_TRACE_LVL 0
284#ifndef RETROINPUT_TRACE_LVL
285# define RETROINPUT_TRACE_LVL 0
307#define RETROFLAT_COLOR_TABLE( f ) \
308 f( 0, black, BLACK, 0, 0, 0, BLACK, BLACK ) \
309 f( 1, darkblue, DARKBLUE, 0, 0, 170, CYAN, BLACK ) \
310 f( 2, darkgreen, DARKGREEN, 0, 170, 0, CYAN, BLACK ) \
311 f( 3, teal, TEAL, 0, 170, 170, CYAN, CYAN ) \
312 f( 4, darkred, DARKRED, 170, 0, 0, MAGENTA, BLACK ) \
313 f( 5, violet, VIOLET, 170, 0, 170, MAGENTA, BLACK ) \
314 f( 6, brown, BROWN, 170, 85, 0, CYAN, MAGENTA ) \
315 f( 7, gray, GRAY, 170, 170, 170, WHITE, BLACK ) \
316 f( 8, darkgray, DARKGRAY, 85, 85, 85, WHITE, BLACK ) \
317 f( 9, blue, BLUE, 85, 85, 255, CYAN, WHITE ) \
318 f( 10, green, GREEN, 85, 255, 85, CYAN, CYAN ) \
319 f( 11, cyan, CYAN, 85, 255, 255, CYAN, CYAN ) \
320 f( 12, red, RED, 255, 85, 85, MAGENTA, WHITE ) \
321 f( 13, magenta, MAGENTA, 255, 85, 255, MAGENTA, MAGENTA ) \
322 f( 14, yellow, YELLOW, 255, 255, 85, CYAN, MAGENTA ) \
323 f( 15, white, WHITE, 255, 255, 255, WHITE, WHITE )
328# define RETROFLAT_COLOR_NULL (-1)
330# define RETROFLAT_COLORS_SZ 16
335#if defined( RETROFLAT_OS_UNIX ) || defined( RETROFLAT_OS_WIN )
336#define RETROFLAT_MOUSE
346#define RETROFLAT_OK 0x00
347#define RETROFLAT_ERROR_ENGINE 0x01
348#define RETROFLAT_ERROR_GRAPHICS 0x02
349#define RETROFLAT_ERROR_MOUSE 0x04
355#define RETROFLAT_ERROR_BITMAP 0x08
356#define RETROFLAT_ERROR_TIMER 0x0f
374#define RETROFLAT_FLAGS_FILL 0x01
380#define RETROFLAT_FLAGS_OPAQUE 0x01
385#define RETROFLAT_FLAGS_LITERAL_PATH 0x02
391#define RETROFLAT_FLAGS_BITMAP_SILENT 0x04
399#define RETROFLAT_FLAGS_ALL_CAPS 0x02
407#define RETROFLAT_FLAGS_SCREEN_BUFFER 0x80
417#define RETROFLAT_FLAGS_RUNNING 0x01
424#define RETROFLAT_FLAGS_UNLOCK_FPS 0x02
431#define RETROFLAT_FLAGS_KEY_REPEAT 0x04
438#define RETROFLAT_FLAGS_SCREENSAVER 0x08
444#define RETROFLAT_FLAGS_WAIT_FOR_FPS 0x20
456#define RETROFLAT_MSG_FLAG_TYPE_MASK 0x07
462#define RETROFLAT_MSG_FLAG_ERROR 0x01
469#define RETROFLAT_MSG_FLAG_INFO 0x02
476#define RETROFLAT_MSG_FLAG_WARNING 0x04
501#define RETROFLAT_VDP_FLAG_PXLOCK 0x01
519 uint16_t new_w, uint16_t new_h,
void* data );
526#define RETROSND_ARGS_FLAG_LIST_DEVS 0x01
559#define RETROFLAT_FLAGS_LOCK 0x08
561#define RETROFLAT_FLAGS_SCREEN_LOCK 0x02
563#define RETROFLAT_FLAGS_BITMAP_RO 0x04
570#define RETROFLAT_INSTANCE_NULL (0)
576#define retroflat_instance_tile( instance ) \
583#ifndef RETROFLAT_BITMAP_EXT
584# define RETROFLAT_BITMAP_EXT "bmp"
587#ifndef RETROFLAT_OPENGL_BPP
588# define RETROFLAT_OPENGL_BPP 32
591#ifndef RETROFLAT_TILE_W
592# define RETROFLAT_TILE_W 16
595#ifndef RETROFLAT_TILE_W_BITS
596# define RETROFLAT_TILE_W_BITS 4
599#ifndef RETROFLAT_TILE_H
600# define RETROFLAT_TILE_H 16
603#ifndef RETROFLAT_TILE_H_BITS
604# define RETROFLAT_TILE_H_BITS 4
608#ifndef RETROFLAT_TXP_R
614# define RETROFLAT_TXP_R 0x00
617#ifndef RETROFLAT_TXP_G
623# define RETROFLAT_TXP_G 0x00
626#ifndef RETROFLAT_TXP_B
632# define RETROFLAT_TXP_B 0x00
635#ifndef RETROFLAT_TXP_PAL_IDX
636# define RETROFLAT_TXP_PAL_IDX 0
641#ifndef RETROFLAT_DEFAULT_SCREEN_W
642# define RETROFLAT_DEFAULT_SCREEN_W 320
645#ifndef RETROFLAT_DEFAULT_SCREEN_H
646# define RETROFLAT_DEFAULT_SCREEN_H 200
649#ifndef RETROFLAT_DEFAULT_SCREEN_SCALE
650# define RETROFLAT_DEFAULT_SCREEN_SCALE 1
653#define retroflat_on_resize( w, h ) \
654 g_retroflat_state->screen_w = w; \
655 g_retroflat_state->screen_h = h;
662#ifndef RETROFLAT_LINE_THICKNESS
667# define RETROFLAT_LINE_THICKNESS 1
670#define RETROFLAT_PI 3.14159
684# define RETROFLAT_FPS 30
687#define retroflat_fps_next() (1000 / RETROFLAT_FPS)
689#ifndef RETROFLAT_WINDOW_CLASS
694# define RETROFLAT_WINDOW_CLASS "RetroFlatWindowClass"
697#ifndef RETROFLAT_WIN_FRAME_TIMER_ID
702# define RETROFLAT_WIN_FRAME_TIMER_ID 6001
705#ifndef RETROFLAT_WIN_LOOP_TIMER_ID
710# define RETROFLAT_WIN_LOOP_TIMER_ID 6002
713#ifndef RETROFLAT_MSG_MAX
718# define RETROFLAT_MSG_MAX 4096
721#ifndef RETROFLAT_TITLE_MAX
722# define RETROFLAT_TITLE_MAX 255
725#ifndef RETROFLAT_VDP_ARGS_SZ_MAX
729# define RETROFLAT_VDP_ARGS_SZ_MAX 255
732#if defined( RETROFLAT_API_SDL2 )
733# if !defined( NO_RETROFLAT_RESIZABLE )
734# define RETROFLAT_WIN_FLAGS SDL_WINDOW_RESIZABLE
736# define RETROFLAT_WIN_FLAGS 0
740#if defined( RETROFLAT_API_SDL1 )
741# define RETROFLAT_SDL_CC_FLAGS (SDL_RLEACCEL | SDL_SRCCOLORKEY)
742#elif defined( RETROFLAT_API_SDL2 )
743# define RETROFLAT_SDL_CC_FLAGS (SDL_TRUE)
746#ifdef RETROFLAT_OS_DOS
747# define RETROFLAT_PATH_SEP '\\'
750# define RETROFLAT_PATH_SEP '/'
753#ifndef RETROFLAT_BMP_COLORS_SZ_MAX
754# define RETROFLAT_BMP_COLORS_SZ_MAX 256
757#ifndef RETROFLAT_TIMER_CT_MAX
758# define RETROFLAT_TIMER_CT_MAX 10
763#define retroflat_wait_for_frame() \
764 (g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_WAIT_FOR_FPS)
766#define retroflat_is_waiting_for_frame() \
767 (RETROFLAT_FLAGS_WAIT_FOR_FPS == \
768 (g_retroflat_state->retroflat_flags & RETROFLAT_FLAGS_WAIT_FOR_FPS))
784#define retroflat_buffer_bksp( buffer, buffer_cur, buffer_sz ) \
785 if( 0 < buffer_cur ) { \
786 if( buffer_cur < buffer_sz ) { \
788 &(buffer[(buffer_cur) - 1]), \
789 &(buffer[buffer_cur]), \
790 (buffer_sz) - (buffer_cur) ); \
794 buffer[buffer_sz] = '\0'; \
800#define retroflat_buffer_insert( c, buffer, buffer_cur, buffer_sz, buffer_mx ) \
801 if( buffer_sz + 1 < buffer_mx ) { \
802 if( buffer_cur < buffer_sz ) { \
804 &(buffer[(buffer_cur) + 1]), \
805 &(buffer[buffer_cur]), \
806 (buffer_sz) - (buffer_cur) ); \
808 buffer[buffer_cur] = c; \
811 buffer[buffer_sz] = '\0'; \
814#define RETROFLAT_INPUT_MOD_SHIFT 0x01
816#define RETROFLAT_INPUT_MOD_ALT 0x02
818#define RETROFLAT_INPUT_MOD_CTRL 0x04
820#define RETROFLAT_INPUT_FORCE_UPPER 0x08
846typedef int8_t retroflat_dir4_t;
848typedef int8_t retroflat_dir8_t;
850#define RETROFLAT_DIR4_NONE (-1)
851#define RETROFLAT_DIR4_NORTH 0
852#define RETROFLAT_DIR4_EAST 1
853#define RETROFLAT_DIR4_SOUTH 2
854#define RETROFLAT_DIR4_WEST 3
856#define RETROFLAT_DIR8_NONE (-1)
857#define RETROFLAT_DIR8_NORTH 0
858#define RETROFLAT_DIR8_EAST 2
859#define RETROFLAT_DIR8_SOUTH 4
860#define RETROFLAT_DIR8_WEST 6
862#define retroflat_dir4_rotate_cw( dir ) \
865#define retroflat_dir8_reverse( dir ) \
868#define retroflat_dir8_bounce( dir ) \
883#define PXXY_MAX INT16_MAX
887#ifndef RETRO2D_TRACE_LVL
888# define RETRO2D_TRACE_LVL 0
891#ifndef RETRO2D_DRAW_TRACE_LVL
892# define RETRO2D_DRAW_TRACE_LVL 0
895#ifndef RETRO2D_LOCK_TRACE_LVL
896# define RETRO2D_LOCK_TRACE_LVL 0
899#ifndef RETROFLAT_NO_SOUND
929#ifndef RETROSND_TRACE_LVL
930# define RETROSND_TRACE_LVL 0
933#ifndef RETROSND_REG_TRACE_LVL
934# define RETROSND_REG_TRACE_LVL 0
947#define RETROSND_FLAG_INIT 0x01
951#define RETROSND_VOICE_BREATH 122
953#define RETROSND_VOICE_SEASHORE 123
955#define RETROSND_VOICE_BIRD_TWEET 124
957#define RETROSND_VOICE_PHONE_RING 125
959#define RETROSND_VOICE_HELICOPTER 126
961#define RETROSND_VOICE_APPLAUSE 127
967#define RETROSND_VOICE_GUNSHOT 128
969#define RETROSND_CHANNEL_CT 8
986void retrosnd_midi_set_voice( uint8_t channel, uint8_t voice );
988void retrosnd_midi_set_control( uint8_t channel, uint8_t key, uint8_t val );
990void retrosnd_midi_note_on( uint8_t channel, uint8_t pitch, uint8_t vel );
992void retrosnd_midi_note_off( uint8_t channel, uint8_t pitch, uint8_t vel );
996uint8_t retrosnd_midi_is_playing_smf();
998void retrosnd_shutdown();
1009#ifndef RETROFLAT_NO_SOUND
1010# include <retapis.h>
1021# if defined( RETROFLAT_NO_KEYBOARD )
1022# define retroflat_case_key( key, pad ) case pad:
1023# define retroflat_or_key( input, key, pad ) ((input) == (pad))
1024# elif defined( RETROFLAT_NO_PAD )
1025# define retroflat_case_key( key, pad ) case key:
1026# define retroflat_or_key( input, key, pad ) ((input) == (key))
1035# define retroflat_case_key( key, pad ) case pad: case key:
1036# define retroflat_or_key( input, key, pad ) \
1037 (((input) == (pad)) || ((input) == (key)))
1044#if defined( RETROFLAT_OS_WIN ) && !defined( MAUG_WINDOWS_H )
1045# include <windows.h>
1046# define MAUG_WINDOWS_H
1049#if defined( RETROFLAT_BMP_TEX ) || defined( DOCUMENTATION )
1053 MAUG_MHANDLE bytes_h;
1068#ifndef retroflat_system_task
1074# define retroflat_system_task()
1077typedef maug_ms_t retroflat_ms_t;
1079typedef void (*retroflat_timer_cb_t)( retroflat_ms_t time,
void* data );
1081#include "retrom2d.h"
1126 struct RETROFLAT_PLATFORM_ARGS platform;
1127# ifndef RETROFLAT_NO_SOUND
1128 struct RETROFLAT_SOUND_ARGS sound;
1226 int16_t world_tile_x;
1227 int16_t world_tile_y;
1228#ifndef RETROFLAT_NO_VIEWPORT_REFRESH
1229 MAUG_MHANDLE refresh_grid_h;
1244# define retroflat_screen_colors() (g_retroflat_state->screen_colors)
1246#ifndef DOCUMENTATION
1248# define retroflat_viewport_world_x_generic() \
1249 (g_retroflat_state->viewport.world_x)
1251# define retroflat_viewport_world_y_generic() \
1252 (g_retroflat_state->viewport.world_y)
1254# define retroflat_viewport_world_tile_x_generic() \
1255 (g_retroflat_state->viewport.world_tile_x)
1257# define retroflat_viewport_world_tile_y_generic() \
1258 (g_retroflat_state->viewport.world_tile_y)
1260# define retroflat_viewport_world_w_generic() \
1261 (g_retroflat_state->viewport.world_w)
1263# define retroflat_viewport_world_h_generic() \
1264 (g_retroflat_state->viewport.world_h)
1266# define retroflat_viewport_screen_tile_w_generic() \
1267 (g_retroflat_state->viewport.screen_tile_w)
1269# define retroflat_viewport_screen_tile_h_generic() \
1270 (g_retroflat_state->viewport.screen_tile_h)
1272# define retroflat_viewport_screen_w_generic() \
1273 (g_retroflat_state->viewport.screen_w)
1275# define retroflat_viewport_screen_h_generic() \
1276 (g_retroflat_state->viewport.screen_h)
1278# define retroflat_viewport_screen_w_remainder_generic() \
1279 (g_retroflat_state->viewport.screen_w_remainder)
1281# define retroflat_viewport_screen_h_remainder_generic() \
1282 (g_retroflat_state->viewport.screen_h_remainder)
1284# define retroflat_viewport_set_world_generic( w, h ) \
1285 debug_printf( 1, "setting viewport size to %d x %d...", \
1286 (int16_t)(w), (int16_t)(h) ); \
1287 (g_retroflat_state->viewport.world_w) = w; \
1288 (g_retroflat_state->viewport.world_h) = h;
1290# define retroflat_viewport_set_world_pos_generic( x, y ) \
1291 debug_printf( 1, "setting viewport world pos to %d, %d...", x, y ); \
1292 (g_retroflat_state->viewport.world_x) = x; \
1293 (g_retroflat_state->viewport.world_y) = y; \
1294 (g_retroflat_state->viewport.world_tile_x) = (x) >> RETROFLAT_TILE_W_BITS; \
1295 (g_retroflat_state->viewport.world_tile_y) = (y) >> RETROFLAT_TILE_H_BITS;
1297# define retroflat_viewport_set_pos_size_generic( x_px, y_px, w_px, h_px ) \
1298 g_retroflat_state->viewport.screen_x = (x_px); \
1299 g_retroflat_state->viewport.screen_y = (y_px); \
1300 g_retroflat_state->viewport.screen_tile_w = \
1301 ((w_px) / RETROFLAT_TILE_W); \
1302 g_retroflat_state->viewport.screen_tile_h = \
1303 ((h_px) / RETROFLAT_TILE_H); \
1307 g_retroflat_state->viewport.screen_w = \
1308 ((w_px) / RETROFLAT_TILE_W) * RETROFLAT_TILE_W; \
1309 g_retroflat_state->viewport.screen_h = \
1310 ((h_px) / RETROFLAT_TILE_H) * RETROFLAT_TILE_H; \
1311 g_retroflat_state->viewport.screen_w_remainder = \
1312 (x_px) + (w_px) - g_retroflat_state->viewport.screen_w; \
1313 g_retroflat_state->viewport.screen_h_remainder = \
1314 (y_px) + (h_px) - g_retroflat_state->viewport.screen_h;
1316#ifndef RETROFLAT_NO_VIEWPORT_REFRESH
1318# define retroflat_viewport_lock_refresh_generic() \
1319 if( NULL == g_retroflat_state->viewport.refresh_grid ) { \
1321 g_retroflat_state->viewport.refresh_grid_h, \
1322 g_retroflat_state->viewport.refresh_grid ); \
1323 maug_cleanup_if_null_lock( retroflat_tile_t*, \
1324 g_retroflat_state->viewport.refresh_grid ); \
1327# define retroflat_viewport_unlock_refresh_generic() \
1328 if( NULL != g_retroflat_state->viewport.refresh_grid ) { \
1330 g_retroflat_state->viewport.refresh_grid_h, \
1331 g_retroflat_state->viewport.refresh_grid ); \
1334# define _retroflat_viewport_refresh_tile_x( x_px ) \
1335 (((x_px) + RETROFLAT_TILE_W) >> RETROFLAT_TILE_W_BITS)
1337# define _retroflat_viewport_refresh_tile_y( y_px ) \
1338 (((y_px) + RETROFLAT_TILE_H) >> RETROFLAT_TILE_H_BITS)
1340# define retroflat_viewport_set_refresh_generic( x_px, y_px, tid ) \
1341 assert( NULL != g_retroflat_state->viewport.refresh_grid ); \
1344 -(RETROFLAT_TILE_W) <= x_px && -(RETROFLAT_TILE_H) <= y_px && \
1345 retroflat_screen_w() > x_px && \
1346 retroflat_screen_h() > y_px \
1348 assert( 0 < g_retroflat_state->viewport.screen_tile_w ); \
1349 assert( 0 <= (((y_px) + RETROFLAT_TILE_H) >> RETROFLAT_TILE_H_BITS) ); \
1350 assert( 0 <= (((x_px) + RETROFLAT_TILE_W) >> RETROFLAT_TILE_W_BITS) ); \
1351 g_retroflat_state->viewport.refresh_grid[ \
1353 ((_retroflat_viewport_refresh_tile_y( y_px ) + 1) * \
1354 (g_retroflat_state->viewport.screen_tile_w + 2)) + \
1355 (_retroflat_viewport_refresh_tile_x( x_px ) + 1)] = tid; \
1358# define retroflat_viewport_tile_is_stale( x_px, y_px, tile_id ) \
1360 g_retroflat_state->viewport.refresh_grid[ \
1361 ((_retroflat_viewport_refresh_tile_y( y_px ) + 1) * \
1362 (g_retroflat_state->viewport.screen_tile_w + 2)) + \
1363 (_retroflat_viewport_refresh_tile_x( x_px ) + 1)])
1367uint8_t retroflat_viewport_move_x_generic( int16_t x );
1369uint8_t retroflat_viewport_move_y_generic( int16_t y );
1371uint8_t retroflat_viewport_focus_generic(
1375# define retroflat_viewport_screen_x_generic( world_x ) \
1376 (g_retroflat_state->viewport.screen_x + \
1377 ((world_x) - retroflat_viewport_world_x()))
1379# define retroflat_viewport_screen_y_generic( world_y ) \
1380 (g_retroflat_state->viewport.screen_y + \
1381 ((world_y) - retroflat_viewport_world_y()))
1383# define retroflat_viewport_screen_get_x_generic() \
1384 (g_retroflat_state->viewport.screen_x)
1386# define retroflat_viewport_screen_get_y_generic() \
1387 (g_retroflat_state->viewport.screen_y)
1391#if defined( RETROFLAT_SOFT_VIEWPORT ) || defined( DOCUMENTATION )
1393# ifndef RETROFLAT_NO_VIEWPORT_REFRESH
1402# define retroflat_viewport_world_x() \
1403 ((retroflat_viewport_world_x_generic() \
1404 >> RETROFLAT_TILE_W_BITS) << RETROFLAT_TILE_W_BITS)
1410# define retroflat_viewport_world_y() \
1411 ((retroflat_viewport_world_y_generic() \
1412 >> RETROFLAT_TILE_H_BITS) << RETROFLAT_TILE_H_BITS)
1414# define retroflat_viewport_world_x() retroflat_viewport_world_x_generic()
1415# define retroflat_viewport_world_y() retroflat_viewport_world_y_generic()
1418# define retroflat_viewport_world_tile_x() \
1419 retroflat_viewport_world_tile_x_generic()
1420# define retroflat_viewport_world_tile_y() \
1421 retroflat_viewport_world_tile_y_generic()
1427# define retroflat_viewport_world_w() \
1428 retroflat_viewport_world_w_generic()
1434# define retroflat_viewport_world_h() \
1435 retroflat_viewport_world_h_generic()
1441# define retroflat_viewport_screen_tile_w() \
1442 retroflat_viewport_screen_tile_w_generic()
1448# define retroflat_viewport_screen_tile_h() \
1449 retroflat_viewport_screen_tile_h_generic()
1455# define retroflat_viewport_screen_w() \
1456 retroflat_viewport_screen_w_generic()
1462# define retroflat_viewport_screen_h() \
1463 retroflat_viewport_screen_h_generic()
1470# define retroflat_viewport_screen_w_remainder() \
1471 retroflat_viewport_screen_w_remainder_generic()
1478# define retroflat_viewport_screen_h_remainder() \
1479 retroflat_viewport_screen_h_remainder_generic()
1488# define retroflat_viewport_set_world( w, h ) \
1489 retroflat_viewport_set_world_generic( w, h )
1495# define retroflat_viewport_set_world_pos( x, y ) \
1496 retroflat_viewport_set_world_pos_generic( x, y )
1503# define retroflat_viewport_set_pos_size( x_px, y_px, w_px, h_px ) \
1504 retroflat_viewport_set_pos_size_generic( x_px, y_px, w_px, h_px )
1506#ifndef RETROFLAT_NO_VIEWPORT_REFRESH
1515# define retroflat_viewport_lock_refresh() \
1516 retroflat_viewport_lock_refresh_generic()
1525# define retroflat_viewport_unlock_refresh() \
1526 retroflat_viewport_unlock_refresh_generic()
1539# define retroflat_viewport_set_refresh( x, y, tid ) \
1540 retroflat_viewport_set_refresh_generic( x, y, tid )
1556# define retroflat_viewport_focus( x1, y1, range, speed ) \
1557 retroflat_viewport_focus_generic( x1, y1, range, speed )
1563# define retroflat_viewport_screen_x( world_x ) \
1564 retroflat_viewport_screen_x_generic( world_x )
1570# define retroflat_viewport_screen_y( world_y ) \
1571 retroflat_viewport_screen_y_generic( world_y )
1573# define retroflat_viewport_screen_get_x() \
1574 retroflat_viewport_screen_get_x_generic()
1576# define retroflat_viewport_screen_get_y() \
1577 retroflat_viewport_screen_get_y_generic()
1579# ifndef RETROFLAT_VIEWPORT_OVERRIDE_MOVE
1580# define retroflat_viewport_move_x( x ) \
1581 retroflat_viewport_move_x_generic( x )
1583# define retroflat_viewport_move_y( y ) \
1584 retroflat_viewport_move_y_generic( y )
1597#define retroflat_heartbeat_set( len, max ) \
1598 g_retroflat_state->heartbeat_max = max; \
1599 g_retroflat_state->heartbeat_len = len;
1605#define retroflat_heartbeat() (g_retroflat_state->heartbeat_frame)
1614#define retroflat_heartbeat_update() \
1616 if( g_retroflat_state->heartbeat_next <= retroflat_get_ms() ) { \
1617 g_retroflat_state->heartbeat_frame++; \
1619 g_retroflat_state->heartbeat_frame >= \
1620 g_retroflat_state->heartbeat_max \
1622 g_retroflat_state->heartbeat_frame = 0; \
1624 g_retroflat_state->heartbeat_next = \
1625 retroflat_get_ms() + g_retroflat_state->heartbeat_len; \
1639 size_t offset_tex_pal;
1653# if defined( RETROFLAT_VDP ) || defined( DOCUMENTATION ) || \
1654defined( RETROVDP_C )
1660# ifdef RETROFLAT_OS_WIN
1710 retroflat_ms_t heartbeat_next;
1729 retroflat_proc_resize_t on_resize;
1730 void* on_resize_data;
1732#ifndef RETROFLAT_BMP_TEX
1740 struct RETROFLAT_PLATFORM platform;
1742# if defined( RETROFLAT_BMP_TEX )
1747 RETROFLAT_TEX_COLOR_DEF tex_palette[RETROFLAT_COLORS_SZ];
1750 struct RETROFLAT_INPUT_STATE input;
1757 retroflat_ms_t timers_at[RETROFLAT_TIMER_CT_MAX];
1758 void* timers_data[RETROFLAT_TIMER_CT_MAX];
1761# ifndef RETROFLAT_NO_SOUND
1762 struct RETROFLAT_SOUND_STATE sound;
1770# ifdef retroflat_loop
1783#define retroflat_get_assets_path() (g_retroflat_state->assets_path)
1786 const maug_path filename_in,
const char* filename_ext,
1787 char* buffer_out,
size_t buffer_out_sz, uint8_t flags );
1801 uint8_t flags,
const char* title,
const char* format, ... );
1822# if defined( RETROFLAT_VDP ) || defined( DOCUMENTATION )
1836RETROFLAT_IN_KEY retroflat_repeat_input(
1838 RETROFLAT_IN_KEY* prev_input,
int* prev_delay );
1840void retroflat_set_title(
const char* format, ... );
1842retroflat_ms_t retroflat_get_ms();
1844uint32_t retroflat_get_rand();
1846# if !defined( RETROFLAT_NO_KEYBOARD )
1847char retroflat_vk_to_ascii( RETROFLAT_IN_KEY k, uint8_t flags );
1866 const char* filename,
struct RETROFLAT_BITMAP* bmp_out, uint8_t flags );
1870 struct RETROFLAT_BITMAP* bmp_out, uint8_t flags );
1895 struct RETROFLAT_BITMAP* target,
struct RETROFLAT_BITMAP* src,
1901#ifdef RETROFLAT_TRACE_CONSTRAIN
1902# define retroflat_constrain_px( x, y, bmp, retact ) \
1904 x >= retroflat_bitmap_w( bmp ) || y >= retroflat_bitmap_h( bmp ) || \
1907 error_printf( "attempted draw at %d, %d, out of bounds %d x %d", \
1908 x, y, retroflat_bitmap_w( bmp ), retroflat_bitmap_h( bmp ) ); \
1919# define retroflat_constrain_px( x, y, bmp, retact ) \
1921 x >= retroflat_bitmap_w( bmp ) || y >= retroflat_bitmap_h( bmp ) || \
1932 struct RETROFLAT_BITMAP* bitmap,
1956MERROR_RETVAL retroflat_draw_release(
struct RETROFLAT_BITMAP* bmp );
1962#ifdef RETROFLAT_SOFT_SHAPES
1963# ifdef RETROFLAT_OPENGL
1967# define retroflat_rect( t, c, x, y, w, h, f ) \
1968 assert( NULL != t ); \
1969 retrosoft_rect( t, c, x, y, w, h, f );
1970# define retroflat_ellipse( t, c, x, y, w, h, f ) \
1971 assert( NULL != t ); \
1972 retrosoft_ellipse( t, c, x, y, w, h, f )
1974# define retroflat_rect( t, c, x, y, w, h, f ) \
1975 retrosoft_rect( t, c, x, y, w, h, f )
1976# define retroflat_ellipse( t, c, x, y, w, h, f ) \
1977 retrosoft_ellipse( t, c, x, y, w, h, f )
2013#ifdef RETROFLAT_SOFT_LINES
2014# define retroflat_line( t, c, x1, y1, x2, y2, f ) \
2015 retrosoft_line( t, c, x1, y1, x2, y2, f )
2036void retroflat_cursor(
struct RETROFLAT_BITMAP* target, uint8_t flags );
2051 struct RETROFLAT_BITMAP* target,
const char* str,
size_t str_sz,
2052 const char* font_str,
2074 const char* str,
int str_sz,
const char* font_str,
2079void retroflat_get_palette( uint8_t idx, uint32_t* rgb );
2081MERROR_RETVAL retroflat_set_palette( uint8_t idx, uint32_t rgb );
2095 retroflat_proc_resize_t on_resize_in,
void* data_in );
2108 retroflat_ms_t time, retroflat_timer_cb_t cb,
void* data );
2132MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets8_x[8] =
2133 { 0, 1, 1, 1, 0, -1, -1, -1 };
2134MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets8_y[8] =
2135 { -1, -1, 0, 1, 1, 1, 0, -1 };
2137MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets4_x[4] =
2139MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets4_y[4] =
2142# ifdef RETROFLAT_STATE_ON_STACK
2145MAUG_MHANDLE SEG_MGLOBAL g_retroflat_state_h = (MAUG_MHANDLE)NULL;
2149# define RETROFLAT_COLOR_TABLE_CONSTS( idx, name_l, name_u, r, g, b, cgac, cgad ) \
2150 MAUG_CONST RETROFLAT_COLOR SEG_MCONST RETROFLAT_COLOR_ ## name_u = idx;
2154# define RETROFLAT_COLOR_TABLE_NAMES( idx, name_l, name_u, r, g, b, cgac, cgad ) \
2157MAUG_CONST
char* SEG_MCONST gc_retroflat_color_names[] = {
2166 const maug_path filename_in,
const char* filename_ext,
2167 char* buffer_out,
size_t buffer_out_sz, uint8_t flags
2171 assert( 1 < buffer_out_sz );
2174 maug_mzero( buffer_out, buffer_out_sz );
2180 maug_snprintf( buffer_out, buffer_out_sz - 1,
"%s", filename_in );
2181 }
else if( NULL != filename_ext ) {
2183 maug_snprintf( buffer_out, buffer_out_sz - 1,
"%s%c%s.%s",
2185 filename_in, filename_ext );
2187 maug_snprintf( buffer_out, buffer_out_sz - 1,
"%s%c%s",
2197# if (defined( RETROFLAT_SOFT_SHAPES ) || defined( RETROFLAT_SOFT_LINES ) || \
2198 defined( RETROFLAT_3D ))
2203# define RETROSOFT_PRESENT
2206# if defined( RETROFLAT_3D )
2207# if !defined( MAUG_NO_AUTO_C )
2212# include <retro3dp.h>
2214# include <retro3du.h>
2215# include <retapi3.h>
2218# ifdef RETROSOFT_PRESENT
2219# if !defined( MAUG_NO_AUTO_C )
2222# define RETROSOFT_PRESENT
2226# ifndef RETROFLAT_NO_SOUND
2227# include <retapis.h>
2230# include <retapii.h>
2232# if defined( RETROFLAT_VDP ) && defined( RETROFLAT_OS_UNIX )
2240#ifndef RETROFLAT_NO_GENERIC_LOOP
2246 retroflat_ms_t next = 0,
2250 g_retroflat_state->loop_data = (
void*)data;
2260 debug_printf( 1,
"main loop already running!" );
2273 NULL != g_retroflat_state->loop_iter
2276 g_retroflat_state->loop_iter( g_retroflat_state->loop_data );
2281 retroflat_get_ms() < next
2291 if( NULL != g_retroflat_state->frame_iter ) {
2293 g_retroflat_state->frame_iter( g_retroflat_state->loop_data );
2297 now = retroflat_get_ms();
2298 if( now + retroflat_fps_next() > now ) {
2299 next = now + retroflat_fps_next();
2309 retval = g_retroflat_state->retval;
2321# if !defined( RETROFLAT_NO_KEYBOARD )
2323char retroflat_vk_to_ascii( RETROFLAT_IN_KEY k, uint8_t flags ) {
2325 char offset_lower = 0;
2327 if( RETROFLAT_INPUT_MOD_SHIFT != (RETROFLAT_INPUT_MOD_SHIFT & flags) ) {
2330 if( RETROFLAT_KEY_A <= k && RETROFLAT_KEY_Z >= k ) {
2332 RETROFLAT_INPUT_FORCE_UPPER !=
2333 (RETROFLAT_INPUT_FORCE_UPPER & flags)
2336 offset_lower = 0x20;
2344 case RETROFLAT_KEY_A: c = 0x41 + offset_lower;
break;
2345 case RETROFLAT_KEY_B: c = 0x42 + offset_lower;
break;
2346 case RETROFLAT_KEY_C: c = 0x43 + offset_lower;
break;
2347 case RETROFLAT_KEY_D: c = 0x44 + offset_lower;
break;
2348 case RETROFLAT_KEY_E: c = 0x45 + offset_lower;
break;
2349 case RETROFLAT_KEY_F: c = 0x46 + offset_lower;
break;
2350 case RETROFLAT_KEY_G: c = 0x47 + offset_lower;
break;
2351 case RETROFLAT_KEY_H: c = 0x48 + offset_lower;
break;
2352 case RETROFLAT_KEY_I: c = 0x49 + offset_lower;
break;
2353 case RETROFLAT_KEY_J: c = 0x4a + offset_lower;
break;
2354 case RETROFLAT_KEY_K: c = 0x4b + offset_lower;
break;
2355 case RETROFLAT_KEY_L: c = 0x4c + offset_lower;
break;
2356 case RETROFLAT_KEY_M: c = 0x4d + offset_lower;
break;
2357 case RETROFLAT_KEY_N: c = 0x4e + offset_lower;
break;
2358 case RETROFLAT_KEY_O: c = 0x4f + offset_lower;
break;
2359 case RETROFLAT_KEY_P: c = 0x50 + offset_lower;
break;
2360 case RETROFLAT_KEY_Q: c = 0x51 + offset_lower;
break;
2361 case RETROFLAT_KEY_R: c = 0x52 + offset_lower;
break;
2362 case RETROFLAT_KEY_S: c = 0x53 + offset_lower;
break;
2363 case RETROFLAT_KEY_T: c = 0x54 + offset_lower;
break;
2364 case RETROFLAT_KEY_U: c = 0x55 + offset_lower;
break;
2365 case RETROFLAT_KEY_V: c = 0x56 + offset_lower;
break;
2366 case RETROFLAT_KEY_W: c = 0x57 + offset_lower;
break;
2367 case RETROFLAT_KEY_X: c = 0x58 + offset_lower;
break;
2368 case RETROFLAT_KEY_Y: c = 0x59 + offset_lower;
break;
2369 case RETROFLAT_KEY_Z: c = 0x60 + offset_lower;
break;
2370 case RETROFLAT_KEY_0: c = offset_lower ? 0x30 :
')';
break;
2371 case RETROFLAT_KEY_1: c = offset_lower ? 0x31 :
'!';
break;
2372 case RETROFLAT_KEY_2: c = offset_lower ? 0x32 :
'@';
break;
2373 case RETROFLAT_KEY_3: c = offset_lower ? 0x33 :
'#';
break;
2374 case RETROFLAT_KEY_4: c = offset_lower ? 0x34 :
'$';
break;
2375 case RETROFLAT_KEY_5: c = offset_lower ? 0x35 :
'%';
break;
2376 case RETROFLAT_KEY_6: c = offset_lower ? 0x36 :
'^';
break;
2377 case RETROFLAT_KEY_7: c = offset_lower ? 0x37 :
'&';
break;
2378 case RETROFLAT_KEY_8: c = offset_lower ? 0x38 :
'*';
break;
2379 case RETROFLAT_KEY_9: c = offset_lower ? 0x39 :
'(';
break;
2380 case RETROFLAT_KEY_SPACE: c =
' ';
break;
2381 case RETROFLAT_KEY_BKSP: c = 0x08;
break;
2382 case RETROFLAT_KEY_ENTER: c =
'\n';
break;
2383 case RETROFLAT_KEY_SEMICOLON: c = offset_lower ?
';' :
':';
break;
2384 case RETROFLAT_KEY_DASH: c = offset_lower ?
'-' :
'_';
break;
2385 case RETROFLAT_KEY_SLASH: c = offset_lower ?
'/' :
'?';
break;
2386 case RETROFLAT_KEY_PERIOD: c = offset_lower ?
'.' :
'>';
break;
2387 case RETROFLAT_KEY_COMMA: c = offset_lower ?
',' :
'<';
break;
2388 case RETROFLAT_KEY_QUOTE: c = offset_lower ?
'\'' :
'"';
break;
2389 case RETROFLAT_KEY_EQUALS: c = offset_lower ?
'=' :
'+';
break;
2390 case RETROFLAT_KEY_BACKSLASH: c = offset_lower ?
'\\' :
'|';
break;
2391 case RETROFLAT_KEY_BRACKETL: c = offset_lower ?
'[' :
'{';
break;
2392 case RETROFLAT_KEY_BRACKETR: c = offset_lower ?
']' :
'}';
break;
2393#ifndef RETROFLAT_API_PC_BIOS
2395 case RETROFLAT_KEY_GRAVE: c = offset_lower ?
'`' :
'~';
break;
2399 debug_printf( RETROINPUT_TRACE_LVL,
"0x%02x", c );
2413# ifndef RETROFLAT_NO_CLI
2415# if !defined( RETROFLAT_NO_SOUND ) && defined( RETROSND_ARGS )
2422 0 == maug_strncmp(
MAUG_CLI_SIGIL "rsl", arg, MAUG_CLI_SIGIL_SZ + 4 )
2424 args->sound.flags |= RETROSND_ARGS_FLAG_LIST_DEVS;
2431# if !defined( RETROFLAT_API_PC_BIOS ) && !defined( RETROFLAT_NO_CLI_SZ )
2437 args->screen_scale = atoi( arg );
2438 debug_printf( 3,
"screen scale arg set to: %d", args->screen_scale );
2451 0 == maug_strncmp(
MAUG_CLI_SIGIL "rfx", arg, MAUG_CLI_SIGIL_SZ + 4 )
2468 0 == maug_strncmp(
MAUG_CLI_SIGIL "rfy", arg, MAUG_CLI_SIGIL_SZ + 4 )
2482 args->
screen_w = RETROFLAT_DEFAULT_SCREEN_W;
2483 debug_printf( 1,
"setting arg screen_w to default %d:",
2487 0 == maug_strncmp(
MAUG_CLI_SIGIL "rfw", arg, MAUG_CLI_SIGIL_SZ + 4 )
2492 debug_printf( 1,
"setting arg screen_w to: %d",
2503 args->
screen_h = RETROFLAT_DEFAULT_SCREEN_H;
2504 debug_printf( 1,
"setting arg screen_h to default: %d",
2508 0 == maug_strncmp(
MAUG_CLI_SIGIL "rfh", arg, MAUG_CLI_SIGIL_SZ + 4 )
2513 debug_printf( 1,
"setting arg screen_h to: %d",
2521# ifdef RETROFLAT_VDP
2525 if( 0 == maug_strncmp(
MAUG_CLI_SIGIL "vdp", arg, MAUG_CLI_SIGIL_SZ + 4 ) ) {
2529 debug_printf( 1,
"VDP args: %s", g_retroflat_state->
vdp_args );
2539 args->flags &= ~RETROFLAT_FLAGS_UNLOCK_FPS;
2541 0 == maug_strncmp(
MAUG_CLI_SIGIL "rfu", arg, MAUG_CLI_SIGIL_SZ + 4 )
2543 debug_printf( 1,
"unlocking FPS..." );
2549# ifndef RETROFLAT_NO_PAD
2555 args->joystick_id = -1;
2556 debug_printf( 1,
"setting arg joystick_id to default: %d",
2557 args->joystick_id );
2559 0 == maug_strncmp(
MAUG_CLI_SIGIL "rfj", arg, MAUG_CLI_SIGIL_SZ + 4 )
2563 args->joystick_id = atoi( arg );
2564 debug_printf( 1,
"setting arg joystick_id to: %d",
2565 args->joystick_id );
2588# ifdef RETROFLAT_COMMIT_HASH
2589 debug_printf( 1,
"retroflat commit: " RETROFLAT_COMMIT_HASH );
2592 debug_printf( 1,
"retroflat: initializing..." );
2596 assert( 4 ==
sizeof( uint32_t ) );
2597 assert( 4 ==
sizeof( int32_t ) );
2598 assert( 2 ==
sizeof( uint16_t ) );
2599 assert( 2 ==
sizeof( int16_t ) );
2600 assert( 1 ==
sizeof( uint8_t ) );
2601 assert( 1 ==
sizeof( int8_t ) );
2602 assert( NULL != args );
2603 assert( 1 << RETROFLAT_TILE_W_BITS == RETROFLAT_TILE_W );
2604 assert( 1 << RETROFLAT_TILE_H_BITS == RETROFLAT_TILE_H );
2606 debug_printf( 1,
"initializing drawing routines..." );
2611# if defined( RETROFLAT_BMP_TEX )
2612 retroflat_2d_px = (retroflat_px_cb)retro3d_texture_px;
2616 retroflat_2d_blit_bitmap = (retroflat_blit_bitmap_cb)retro3d_texture_blit;
2617 retroflat_2d_load_bitmap =
2618 (retroflat_load_bitmap_cb)retro3d_texture_load_bitmap;
2619 retroflat_2d_create_bitmap =
2620 (retroflat_create_bitmap_cb)retro3d_texture_create;
2622 retroflat_2d_px = (retroflat_px_cb)retroflat_px;
2623# ifdef RETROFLAT_SOFT_SHAPES
2635 retroflat_2d_create_bitmap =
2636 (retroflat_create_bitmap_cb)retroflat_create_bitmap;
2639 debug_printf( 1,
"retroflat: MFIX_PRECISION: %f", MFIX_PRECISION );
2641 debug_printf( 1,
"retroflat: allocating state (" SIZE_T_FMT
" bytes)...",
2644 debug_printf( 1,
"retroflat: size_t is (" SIZE_T_FMT
" bytes)...",
2647 debug_printf( 1,
"retroflat: ssize_t is (" SIZE_T_FMT
" bytes)...",
2648 sizeof( ssize_t ) );
2650 debug_printf( 1,
"retroflat: off_t is (" SIZE_T_FMT
" bytes)...",
2653 debug_printf( 1,
"initializing global state..." );
2655# ifdef RETROFLAT_STATE_ON_STACK
2656 g_retroflat_state = &g_retroflat_state_stack;
2658 maug_malloc_test( g_retroflat_state_h, 1,
sizeof(
struct RETROFLAT_STATE ) );
2660 maug_mlock( g_retroflat_state_h, g_retroflat_state );
2661 if( NULL == g_retroflat_state ) {
2663 "Error",
"Could not lock global state!" );
2664 retval = MERROR_ALLOC;
2673 debug_printf( 1,
"initializing platform filesystem..." );
2674 retval = mfile_plt_init();
2675 maug_cleanup_if_not_ok();
2677# ifndef RETROFLAT_NO_CLI
2679 debug_printf( 1,
"retroflat: parsing args..." );
2684 MAUG_CLI_SIGIL "h", MAUG_CLI_SIGIL_SZ + 2,
"Display command-line help",
2685 26, maug_cli_h, NULL );
2687# if !defined( RETROFLAT_NO_SOUND ) && defined( RETROSND_ARGS )
2689 "Select MIDI device", 0, (maug_cli_cb)retrosnd_cli_rsd, args );
2690 maug_cleanup_if_not_ok();
2692 "List MIDI devices", 0, (maug_cli_cb)retrosnd_cli_rsl, args );
2693 maug_cleanup_if_not_ok();
2696# ifdef RETROFLAT_SCREENSAVER
2698 "Preview screensaver", 0, (maug_cli_cb)retroflat_cli_p, args );
2699 maug_cleanup_if_not_ok();
2701 "Launch screensaver", 0, (maug_cli_cb)retroflat_cli_s, args );
2702 maug_cleanup_if_not_ok();
2705# ifdef RETROFLAT_API_PC_BIOS
2707 "Set the screen mode.", 0,
2708 (maug_cli_cb)retroflat_cli_rfm, args );
2709 maug_cleanup_if_not_ok();
2710# elif !defined( RETROFLAT_NO_CLI_SZ )
2712 "Set screen scale factor.", 0,
2713 (maug_cli_cb)retroflat_cli_rfs, args );
2714 maug_cleanup_if_not_ok();
2716 "Set the screen X position.", 0,
2717 (maug_cli_cb)retroflat_cli_rfx, args );
2718 maug_cleanup_if_not_ok();
2720 "Set the screen Y position.", 0,
2721 (maug_cli_cb)retroflat_cli_rfy, args );
2722 maug_cleanup_if_not_ok();
2724 "Set the screen width.", 0,
2725 (maug_cli_cb)retroflat_cli_rfw, args );
2726 maug_cleanup_if_not_ok();
2728 "Set the screen height.", 0,
2729 (maug_cli_cb)retroflat_cli_rfh, args );
2730 maug_cleanup_if_not_ok();
2733# ifdef RETROFLAT_VDP
2735 "Pass a string of args to the VDP.", 0,
2736 (maug_cli_cb)retroflat_cli_vdp, args );
2737 maug_cleanup_if_not_ok();
2742 (maug_cli_cb)retroflat_cli_u, args );
2743 maug_cleanup_if_not_ok();
2745# ifndef RETROFLAT_NO_PAD
2747 "Specify joystick ID to use.", 0,
2748 (maug_cli_cb)retroflat_cli_rfj, args );
2749 maug_cleanup_if_not_ok();
2753 retval = maug_parse_args( argc, argv );
2754 maug_cleanup_if_not_ok();
2759 args->
screen_w = RETROFLAT_DEFAULT_SCREEN_W;
2760 debug_printf( 1,
"setting arg screen_w to default: %d",
2764 args->
screen_h = RETROFLAT_DEFAULT_SCREEN_H;
2765 debug_printf( 1,
"setting arg screen_h to default: %d",
2768 if( 0 == args->screen_scale ) {
2769 args->screen_scale = RETROFLAT_DEFAULT_SCREEN_SCALE;
2770 debug_printf( 1,
"setting arg screen_scale to default: %d",
2771 args->screen_scale );
2775 debug_printf( 1,
"setting arg screen_colors to default: %d",
2778 args->joystick_id = -1;
2786 debug_printf( 1,
"retroflat: setting config..." );
2791 maug_strncpy( g_retroflat_state->assets_path,
2795# if defined( RETROFLAT_SCREENSAVER )
2804# if !defined( RETROFLAT_NO_CLI_SZ )
2815 debug_printf( 3,
"attempting to initialize platform with: "
2816 SIZE_T_FMT
"x" SIZE_T_FMT
" pixels (scaled to " SIZE_T_FMT
"x" SIZE_T_FMT
2817 ") and " SIZE_T_FMT
" colors",
2825 retval = retroflat_init_platform( argc, argv, args );
2826 maug_cleanup_if_not_ok();
2828# if defined( RETROFLAT_NO_CLI_SZ )
2838 debug_printf( 3,
"initialized platform with: "
2839 SIZE_T_FMT
"x" SIZE_T_FMT
" pixels (scaled to " SIZE_T_FMT
"x" SIZE_T_FMT
2840 ") and " SIZE_T_FMT
" colors",
2846 retval = retroflat_init_input( args );
2847 maug_cleanup_if_not_ok();
2849 debug_printf( 3,
"screen initialized with: " SIZE_T_FMT
"x" SIZE_T_FMT
2850 " pixels (scaled to " SIZE_T_FMT
"x" SIZE_T_FMT
2851 ") with " SIZE_T_FMT
" colors",
2854 retroflat_screen_colors() );
2860 (
size_t)0, retroflat_screen_w(), SIZE_T_FMT, MERROR_GUI );
2862 (
size_t)0, retroflat_screen_h(), SIZE_T_FMT, MERROR_GUI );
2864 (
size_t)0, retroflat_screen_colors(), SIZE_T_FMT, MERROR_GUI );
2870 0, 0, retroflat_screen_w(), retroflat_screen_h() );
2872#ifndef RETROFLAT_NO_VIEWPORT_REFRESH
2873 debug_printf( 1,
"allocating refresh grid (%d tiles...)",
2877 g_retroflat_state->viewport.refresh_grid_h,
2883# ifdef RETROFLAT_VDP
2884# if defined( RETROFLAT_OS_UNIX )
2885 g_retroflat_state->
vdp_exe = dlopen(
2886 "./" RETROFLAT_VDP_LIB_NAME
".so", RTLD_LAZY );
2887# elif defined( RETROFLAT_OS_WIN )
2888 g_retroflat_state->
vdp_exe = LoadLibrary(
2889 "./" RETROFLAT_VDP_LIB_NAME
".dll" );
2891# error "dlopen undefined!"
2894 if( !(g_retroflat_state->
vdp_exe) ) {
2895 error_printf(
"not loading VDP" );
2901 debug_printf( 1,
"creating VDP buffer, " SIZE_T_FMT
" x " SIZE_T_FMT,
2904 calloc( 1,
sizeof(
struct RETROFLAT_BITMAP ) );
2905 maug_cleanup_if_null_alloc(
2906 struct RETROFLAT_BITMAP*, g_retroflat_state->
vdp_buffer );
2907 retval = retroflat_create_bitmap(
2910 maug_cleanup_if_not_ok();
2912 debug_printf( 1,
"initializing VDP..." );
2920 retro3d_platform_init();
2923# if !defined( RETROFLAT_NO_BLANK_INIT ) && !defined( RETROFLAT_3D )
2926 NULL, RETROFLAT_COLOR_BLACK, 0, 0,
2927 retroflat_screen_w(), retroflat_screen_h(),
2929 retroflat_draw_release( NULL );
2941 debug_printf( 1,
"retroflat shutdown called..." );
2943#ifndef RETROFLAT_NO_VIEWPORT_REFRESH
2945 NULL != g_retroflat_state &&
2946 (MAUG_MHANDLE)NULL != g_retroflat_state->viewport.refresh_grid_h
2948 maug_mfree( g_retroflat_state->viewport.refresh_grid_h );
2952# if defined( RETROFLAT_VDP )
2953 if( NULL != g_retroflat_state->
vdp_exe ) {
2955# ifdef RETROFLAT_OS_UNIX
2956 dlclose( g_retroflat_state->
vdp_exe );
2957# elif defined( RETROFLAT_OS_WIN )
2958 FreeLibrary( g_retroflat_state->
vdp_exe );
2960# error "dlclose undefined!"
2964 if( NULL != g_retroflat_state->
vdp_buffer ) {
2965 debug_printf( 1,
"destroying VPD buffer..." );
2974 retro3d_platform_shutdown();
2977 retroflat_shutdown_platform( retval );
2979#ifndef RETROFLAT_STATE_ON_STACK
2980 maug_munlock( g_retroflat_state_h, g_retroflat_state );
2981 maug_mfree( g_retroflat_state_h );
2988RETROFLAT_IN_KEY retroflat_repeat_input(
2990 RETROFLAT_IN_KEY* prev_input,
int* prev_delay
2994 if( 0 < (*prev_delay) ) {
2996 RETROINPUT_TRACE_LVL,
2997 "repeat delay: %d", (*prev_delay) );
3013 key_out = *prev_input;
3015 debug_printf( RETROINPUT_TRACE_LVL,
"repeat: %d", key_out );
3024 retroflat_ms_t at_time, retroflat_timer_cb_t cb,
void* data
3026 if( retroflat_get_ms() > at_time ) {
3027 error_printf(
"timer time is in the past!" );
3028 return merror_retval_to_sz( MERROR_EXEC );
3031 if( g_retroflat_state->timers_ct + 1 < RETROFLAT_TIMER_CT_MAX ) {
3032 g_retroflat_state->
timers_cb[g_retroflat_state->timers_ct] = cb;
3033 g_retroflat_state->timers_at[g_retroflat_state->timers_ct] = at_time;
3034 g_retroflat_state->timers_ct++;
3035 return g_retroflat_state->timers_ct - 1;
3038 error_printf(
"too many timers!" );
3039 return merror_retval_to_sz( MERROR_OVERFLOW );
3046 retroflat_ms_t time_now = 0;
3048 time_now = retroflat_get_ms();
3050 for( i = 0 ; g_retroflat_state->timers_ct > i ; i++ ) {
3051 if( g_retroflat_state->timers_at[i] <= time_now ) {
3053 time_now, g_retroflat_state->timers_data[i] );
3057 sizeof( retroflat_timer_cb_t ) *
3058 ((g_retroflat_state->timers_ct - i) - 1)
3061 &(g_retroflat_state->timers_at[i]),
3062 &(g_retroflat_state->timers_at[i + 1]),
3063 sizeof( retroflat_ms_t ) * ((g_retroflat_state->timers_ct - i) - 1)
3066 &(g_retroflat_state->timers_data[i]),
3067 &(g_retroflat_state->timers_data[i + 1]),
3068 sizeof(
void* ) * ((g_retroflat_state->timers_ct - i) - 1)
3070 g_retroflat_state->timers_ct--;
3079 struct RETROFLAT_BITMAP* bitmap,
3094 retroflat_screen_buffer() == bitmap &&
3098 viewport_left = retroflat_viewport_screen_get_x();
3099 viewport_top = retroflat_viewport_screen_get_y();
3107 viewport_bottom = retroflat_bitmap_h( bitmap );
3108 viewport_right = retroflat_bitmap_w( bitmap );
3111 if( viewport_bottom < *d_y || trim_bottom < viewport_top ) {
3112#ifdef RETROFLAT_TRACE_CONSTRAIN
3113 error_printf(
"attempted to blit bitmap way out of bounds at %d, %d!",
3118 }
else if( viewport_bottom <= trim_bottom ) {
3119#ifdef RETROFLAT_TRACE_CONSTRAIN
3121 "trimming " SIZE_T_FMT
" pixels to get " SIZE_T_FMT
" under "
3123 trim_bottom - viewport_bottom, trim_bottom, viewport_bottom );
3125 *h -= (trim_bottom - viewport_bottom);
3127 }
else if( viewport_top > *d_y ) {
3128#ifdef RETROFLAT_TRACE_CONSTRAIN
3130 "trimming " SIZE_T_FMT
" pixels to get " SIZE_T_FMT
" under "
3132 trim_bottom - viewport_bottom, trim_bottom, viewport_bottom );
3134 *h -= (viewport_top - *d_y);
3136 *s_y += (viewport_top - *d_y);
3138 *d_y += (viewport_top - *d_y);
3139 assert( viewport_top == *d_y );
3142 if( viewport_right < *d_x || trim_right < viewport_left ) {
3143#ifdef RETROFLAT_TRACE_CONSTRAIN
3144 error_printf(
"attempted to blit bitmap way out of bounds at %d, %d!",
3149 }
else if( viewport_right <= trim_right ) {
3150#ifdef RETROFLAT_TRACE_CONSTRAIN
3152 "trimming " SIZE_T_FMT
" pixels to get " SIZE_T_FMT
" under "
3154 trim_right - viewport_right, trim_right, viewport_right );
3156 *w -= (trim_right - viewport_right);
3158 }
else if( viewport_left > *d_x ) {
3159#ifdef RETROFLAT_TRACE_CONSTRAIN
3161 "trimming " SIZE_T_FMT
" pixels to get " SIZE_T_FMT
" under "
3163 trim_bottom - viewport_bottom, trim_bottom, viewport_bottom );
3165 *w -= (viewport_left - *d_x);
3167 *s_x += (viewport_left - *d_x);
3169 *d_x += (viewport_left - *d_x);
3170 assert( viewport_left == *d_x );
3173 if( 0 == w && 0 == h ) {
3182# ifdef RETROFLAT_VDP
3187# ifdef RETROFLAT_OS_WIN
3188 char proc_name_ex[256];
3191 if( NULL == g_retroflat_state->
vdp_exe ) {
3195# ifdef RETROFLAT_OS_UNIX
3196 vdp_proc = dlsym( g_retroflat_state->
vdp_exe, proc_name );
3197# elif defined( RETROFLAT_OS_WIN )
3199 maug_snprintf( proc_name_ex, 255,
"%s_", proc_name );
3201 g_retroflat_state->
vdp_exe, proc_name_ex );
3203# error "dlsym undefined!"
3209# ifdef RETROFLAT_OS_WIN
3215 0 == strcmp(
"retroflat_vdp_flip", proc_name ) &&
3219 retroflat_vdp_lock( &(g_retroflat_state->platform.buffer) );
3220 retroflat_vdp_lock( g_retroflat_state->
vdp_buffer );
3223 retval = vdp_proc( g_retroflat_state );
3226 0 == strcmp(
"retroflat_vdp_flip", proc_name ) &&
3230 retroflat_vdp_release( &(g_retroflat_state->platform.buffer) );
3231 retroflat_vdp_release( g_retroflat_state->
vdp_buffer );
3234# ifdef RETROFLAT_OS_WIN
3235 retroflat_draw_release( g_retroflat_state->
vdp_buffer );
3248void retroflat_cursor(
struct RETROFLAT_BITMAP* target, uint8_t flags ) {
3250 char mouse_str[11] =
"";
3253 mouse_str, 10,
"%02d, %02d", g_retroflat_state->last_mouse_x, g_retroflat_state->last_mouse_y );
3256 target, RETROFLAT_COLOR_BLACK,
3257 mouse_str, 10, NULL, 0, 0, 0 );
3259 target, RETROFLAT_COLOR_BLACK,
3260 g_retroflat_state->last_mouse_x - 5, g_retroflat_state->last_mouse_y - 5, 10, 10, 0 );
3275 retroflat_proc_resize_t on_resize_in,
void* data_in
3277 g_retroflat_state->on_resize = on_resize_in;
3278 g_retroflat_state->on_resize_data = data_in;
3283uint8_t retroflat_viewport_move_x_generic( int16_t x ) {
3284 int16_t new_world_x = g_retroflat_state->viewport.
world_x + x;
3289 g_retroflat_state->viewport.
world_w >= new_world_x +
3290 g_retroflat_state->viewport.
screen_w
3292 g_retroflat_state->viewport.
world_x += x;
3293 g_retroflat_state->viewport.world_tile_x += x >> RETROFLAT_TILE_W_BITS;
3302uint8_t retroflat_viewport_move_y_generic( int16_t y ) {
3303 int16_t new_world_y = g_retroflat_state->viewport.
world_y + y;
3308 g_retroflat_state->viewport.
world_h >= new_world_y +
3309 g_retroflat_state->viewport.
screen_h
3311 g_retroflat_state->viewport.
world_y += y;
3312 g_retroflat_state->viewport.world_tile_y += y >> RETROFLAT_TILE_H_BITS;
3321uint8_t retroflat_viewport_focus_generic(
3329# define _retroflat_viewport_focus_dir( n, xy, wh, gl, pm, dir, range, speed ) \
3330 new_pt = n - retroflat_viewport_world_ ## xy(); \
3331 if( new_pt gl (retroflat_screen_ ## wh() >> 1) pm range ) { \
3332 new_moved = retroflat_viewport_move_ ## xy( \
3333 gc_retroflat_offsets8_ ## xy[RETROFLAT_DIR8_ ## dir] * speed ); \
3334 if( !moved && new_moved ) { \
3335 moved = new_moved; \
3339 _retroflat_viewport_focus_dir( x1, x, w, <, -, WEST, range, speed );
3340 _retroflat_viewport_focus_dir( x1, x, w, >, +, EAST, range, speed );
3341 _retroflat_viewport_focus_dir( y1, y, h, <, -, NORTH, range, speed );
3342 _retroflat_viewport_focus_dir( y1, y, h, >, +, SOUTH, range, speed );
3349#ifdef RETROFLAT_LOAD_BITMAP_GENERIC
3357 const char* filename,
struct RETROFLAT_BITMAP* bmp_out, uint8_t flags
3363 uint8_t bmp_flags = 0;
3365 assert( NULL != bmp_out );
3366 maug_mzero( bmp_out,
sizeof(
struct RETROFLAT_BITMAP ) );
3367 retval = retroflat_build_filename_path(
3370 maug_cleanup_if_not_ok();
3371 debug_printf( 1,
"retroflat: loading bitmap: %s", filename_path );
3373 bmp_out->flags = flags;
3377 maug_cleanup_if_not_ok();
3381 header_bmp.magic[0] =
'B';
3382 header_bmp.magic[1] =
'M';
3383 header_bmp.info.sz = 40;
3385 retval = mfmt_read_bmp_header(
3387 &bmp_file, 0, mfile_get_sz( &bmp_file ), &bmp_flags );
3388 maug_cleanup_if_not_ok();
3390 retval = retroflat_create_bitmap(
3391 header_bmp.info.width, header_bmp.info.height, bmp_out, flags );
3392 maug_cleanup_if_not_ok();
3399 header_bmp.px_offset,
3400 mfile_get_sz( &bmp_file ) - header_bmp.px_offset,
3402 retroflat_load_bitmap_px_cb,
3404 maug_cleanup_if_not_ok();
3406 retroflat_draw_release( bmp_out );
3417#elif !defined( RETROVDP_C )
3424extern MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets8_x[8];
3425extern MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets8_y[8];
3426extern MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets4_x[4];
3427extern MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets4_y[4];
3431#define RETROFLAT_COLOR_TABLE_CONSTS( idx, name_l, name_u, r, g, b, cgac, cgad ) \
3432 extern MAUG_CONST RETROFLAT_COLOR SEG_MCONST RETROFLAT_COLOR_ ## name_u;
3436extern MAUG_CONST
char* SEG_MCONST gc_retroflat_color_names[];
3440# if (defined( RETROFLAT_SOFT_SHAPES ) || defined( RETROFLAT_SOFT_LINES ) || \
3441 defined( RETROFLAT_3D ))
3442# define RETROSOFT_PRESENT
3446# include <retro3dp.h>
3448# include <retro3du.h>
3451# ifdef RETROSOFT_PRESENT
3462#include <retroxpm.h>
MERROR_RETVAL maug_add_arg(const char *arg, int arg_sz, const char *help, int help_sz, maug_cli_cb arg_cb, void *data)
Add a command-line argument to the built-in parser.
#define MAUG_CLI_SIGIL
Default flag to prepend to CLI arguments. Is "/" on Windows/DOS and "-" on other platforms....
Definition: marge.h:39
uint16_t MERROR_RETVAL
Return type indicating function returns a value from this list.
Definition: merror.h:28
void maug_critical_error(const char *msg)
Display an error dialog. This is a minimal function that can be called early on (e....
MERROR_RETVAL mfmt_read_bmp_px_cb(struct MFMT_STRUCT *header, mfile_t *p_file_in, uint32_t px_offset, off_t file_sz, uint8_t flags, mfmt_read_1px_cb px_cb, void *px_cb_data)
Read mfmt_bitmap pixels and process them using a callback.
MERROR_RETVAL mfile_open_read(const maug_path filename, mfile_t *p_file)
Open a file and read it into memory or memory-map it.
#define MAUG_PATH_SZ_MAX
Maximum size allocated for asset paths.
Definition: mfile.h:41
void mfile_close(mfile_t *p_file)
Close a file opened with mfile_open_read().
char maug_path[MAUG_PATH_SZ_MAX]
Path/name used to load an asset from disk or access other files.
Definition: mfile.h:141
#define RETROFLAT_BITMAP_EXT
The filename suffix to be appended with a "." to filenames passed to retroflat_load_bitmap()....
Definition: retroflt.h:584
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 ...
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 ...
#define RETROFLAT_INSTANCE_NULL
Pass to retroflat_blit_bitmap() instance arg if this is not a sprite (i.e. if it is a background tile...
Definition: retroflt.h:570
MERROR_RETVAL retroflat_trim_px(struct RETROFLAT_BITMAP *bitmap, int16_t instance, retroflat_pxxy_t *s_x, retroflat_pxxy_t *s_y, retroflat_pxxy_t *d_x, retroflat_pxxy_t *d_y, retroflat_pxxy_t *w, retroflat_pxxy_t *h)
Chop w/h down to fit inside viewport or just fail if it's impossible.
MERROR_RETVAL retroflat_blit_bitmap(struct RETROFLAT_BITMAP *target, struct RETROFLAT_BITMAP *src, retroflat_pxxy_t s_x, retroflat_pxxy_t s_y, retroflat_pxxy_t d_x, retroflat_pxxy_t d_y, retroflat_pxxy_t w, retroflat_pxxy_t h, int16_t instance)
Blit the contents of a ::RETROFLAT_BITMAP onto another ::RETROFLAT_BITMAP.
int8_t RETROFLAT_COLOR
Defines an index in the platform-specific color-table.
Definition: retroflt.h:326
#define RETROFLAT_COLOR_TABLE(f)
This macro defines all colors supported by RetroFlat for primative operations, particularly using ret...
Definition: retroflt.h:307
#define RETROFLAT_VDP_ARGS_SZ_MAX
Definition: retroflt.h:729
#define RETROFLAT_PATH_SEP
The valid path separator on the target platform.
Definition: retroflt.h:750
#define RETROFLAT_FLAGS_LITERAL_PATH
Flag for retroflat_load_bitmap() to not use assets path.
Definition: retroflt.h:385
#define RETROFLAT_FLAGS_OPAQUE
Flag for retroflat_create_bitmap() or retroflat_load_bitmap() to create or load a bitmap without tran...
Definition: retroflt.h:380
void retroflat_ellipse(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, retroflat_pxxy_t x, retroflat_pxxy_t y, retroflat_pxxy_t w, retroflat_pxxy_t h, uint8_t flags)
Draw an ellipse onto the target ::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,...
void retroflat_line(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, retroflat_pxxy_t x1, retroflat_pxxy_t y1, retroflat_pxxy_t x2, retroflat_pxxy_t y2, uint8_t flags)
Draw a straight line onto the target ::RETROFLAT_BITMAP.
void retroflat_string(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, const char *str, int str_sz, const char *font_str, retroflat_pxxy_t x_orig, retroflat_pxxy_t y_orig, uint8_t flags)
Draw a text string at the specified location in the specified font and color on the target ::RETROFLA...
void retroflat_rect(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, retroflat_pxxy_t x, retroflat_pxxy_t y, retroflat_pxxy_t w, retroflat_pxxy_t h, uint8_t flags)
Draw a rectangle onto the target ::RETROFLAT_BITMAP.
#define RETROFLAT_FLAGS_FILL
Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
Definition: retroflt.h:374
void retroflat_string_sz(struct RETROFLAT_BITMAP *target, const char *str, size_t str_sz, const char *font_str, retroflat_pxxy_t *w_out, retroflat_pxxy_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_message(uint8_t flags, const char *title, const char *format,...)
Display a message in a dialog box and/or on stderr.
#define RETROFLAT_MSG_FLAG_ERROR
This icon/type flag indicates an error. It will try to display messages in an urgent way with a red i...
Definition: retroflt.h:462
MERROR_RETVAL retroflat_vdp_call(const char *proc_name)
Call a function from the retroflat VDP.
MERROR_RETVAL(* retroflat_vdp_proc_t)(struct RETROFLAT_STATE *)
VDP function called from the VDP library.
Definition: retroflt.h:514
#define RETROFLAT_VDP_FLAG_PXLOCK
Flag for RETROFLAT_STATE::vdp_flags indicating the VDP requires RetroFlat to pixel-lock the frame bef...
Definition: retroflt.h:501
void retroflat_shutdown(int retval)
Deinitialize RetroFlat and its underlying layers. This should be called once at the end of the progra...
void retroflat_timer_handle()
int16_t retroflat_pxxy_t
Type used for surface pixel coordinates.
Definition: retroflt.h:879
#define retroflat_system_task()
Platform-specific task that should be called on every iteration of the generic loop....
Definition: retroflt.h:1074
void(* retroflat_loop_iter)(void *data)
Prototype for the main loop function passed to retroflat_loop().
Definition: retroflt.h:773
void retroflat_resize_v()
Platform-specific function to resize virtual screen to match physical window size.
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....
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 pr...
ssize_t retroflat_timer_add(retroflat_ms_t time, retroflat_timer_cb_t cb, void *data)
Add a timer callback to be executed at the given time.
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 retrosoft_rect(retroflat_blit_t *target, const RETROFLAT_COLOR color_idx, int x, int y, int w, int h, uint8_t flags)
Draw a rectangle at the given coordinates, with the given dimensions.
void retrosoft_ellipse(retroflat_blit_t *target, RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
Draw an ellipsoid at the given coordinates, with the given dimensions.
void retrosoft_line(retroflat_blit_t *target, RETROFLAT_COLOR color, int x1, int y1, int x2, int y2, uint8_t flags)
Draw a line from x1, y1 to x2, y2.
void retrosnd_set_sf_bank(const char *filename_in)
Set the name of the voice bank filename to use.
MERROR_RETVAL retrosnd_init(struct RETROFLAT_ARGS *args)
Initialize retrosnd engine.
int16_t retroflat_tile_t
Value for an individual tile in a RETROTILE_LAYER.
Definition: retroflt.h:19
Lower-level retargetable 3D engine wrapper.
Tools for drawing shape primatives.
Generic image description struct.
Definition: mfmt.h:69
Definition: retroflt.h:1051
Struct containing configuration values for a RetroFlat program.
Definition: retroflt.h:1088
char * config_path
Relative path of local config file (if not using registry).
Definition: retroflt.h:1098
char * assets_path
Relative path under which bitmap assets are stored.
Definition: retroflt.h:1096
int screen_w
Desired screen or window width in pixels.
Definition: retroflt.h:1105
int screen_h
Desired screen or window height in pixels.
Definition: retroflt.h:1112
int screen_colors
Desired colors (2, 4, or 16, for now). \TODO Implement command-line argument for this....
Definition: retroflt.h:1124
char * title
Title to set for the main program Window if applicable on the target platform.
Definition: retroflt.h:1094
int screen_y
Desired window Y position in pixels.
Definition: retroflt.h:1116
int screen_x
Desired window X position in pixels.
Definition: retroflt.h:1114
Global singleton containing state for the current platform.
Definition: retroflt.h:1634
#define RETROFLAT_FLAGS_SCREENSAVER
Flag indicating the current application is running as a screensaver.
Definition: retroflt.h:438
char vdp_args[RETROFLAT_VDP_ARGS_SZ_MAX]
CLI args passed with -vdp to the RetroFlat VDP API.
Definition: retroflt.h:1672
size_t screen_h
The screen height as seen by the system, after scaling.
Definition: retroflt.h:1698
uint8_t vdp_flags
Flags set by the RetroFlat VDP API.
Definition: retroflt.h:1674
#define retroflat_heartbeat_update()
Check and update RETROFLAT_STATE::heartbeat_frame.
Definition: retroflt.h:1614
size_t screen_v_w
The screen width as seen by our program, before scaling.
Definition: retroflt.h:1687
size_t screen_colors
The number of colors the screen is capable of displaying.
Definition: retroflt.h:1700
uint8_t retroflat_flags
maug_retroflt_flags indicating current system status.
Definition: retroflt.h:1644
#define RETROFLAT_FLAGS_UNLOCK_FPS
Flag indicating FPS should not be capped.
Definition: retroflt.h:424
uint8_t heartbeat_max
When RETROFLAT_STATE::heartbeat_frame reaches this value, it will reset to 0.
Definition: retroflt.h:1727
retroflat_timer_cb_t timers_cb[RETROFLAT_TIMER_CT_MAX]
List of installable timers that should be tended every frame with retroflat_handle_timers().
Definition: retroflt.h:1756
struct RETROFLAT_BITMAP * vdp_buffer
A buffer assembled and passed to the RetroFlat VDP API for it to modify, or NULL if no VDP is loaded.
Definition: retroflt.h:1659
uint8_t heartbeat_frame
Simple iteration loop that can be used to time e.g. perpetual sprite animations. Modify parameters wi...
Definition: retroflt.h:1722
size_t screen_w
The screen width as seen by the system, after scaling.
Definition: retroflt.h:1696
#define retroflat_heartbeat_set(len, max)
Set parameters for the RETROFLAT_STATE::heartbeat_frame.
Definition: retroflt.h:1597
void * vdp_exe
A handle for the loaded RetroFlat VDP API module.
Definition: retroflt.h:1664
RETROFLAT_COLOR_DEF palette[RETROFLAT_COLORS_SZ]
Index of available colors, initialized on platform init.
Definition: retroflt.h:1734
uint16_t heartbeat_len
Number of ms to stay on current value of RETROFLAT_STATE::heartbeat_frame before incrementing....
Definition: retroflt.h:1716
void * vdp_data
Pointer to data defined by the RetroFlat VDP API for its use.
Definition: retroflt.h:1670
size_t screen_v_h
The screen height as seen by our program, before scaling.
Definition: retroflt.h:1694
int screen_scale
Off-screen buffer bitmap.
Definition: retroflt.h:1651
#define RETROFLAT_FLAGS_RUNNING
Flag indicating that retroflat_loop() should continue executing.
Definition: retroflt.h:417
#define RETROFLAT_FLAGS_WAIT_FOR_FPS
Do not execute any more inter-frame loops until next frame.
Definition: retroflt.h:444
#define RETROFLAT_FLAGS_KEY_REPEAT
Flag indicating keyboard repeat is enabled.
Definition: retroflt.h:431
The viewport data struct.
Definition: retroflt.h:1149
retroflat_pxxy_t world_x
The X offset, in pixels, of the viewport on the world tilemap. Should only be retrieved through retro...
Definition: retroflt.h:1167
#define retroflat_viewport_screen_h()
Return the height of the viewport in pixels.
Definition: retroflt.h:1462
retroflat_tile_t * refresh_grid
A grid of tile values representing the last-drawn values on-screen.
Definition: retroflt.h:1240
retroflat_pxxy_t screen_h
Viewport height in pixels. Should only be retrieved through retroflat_viewport_screen_w() and set thr...
Definition: retroflt.h:1197
#define retroflat_viewport_screen_w()
Return the width of the viewport in pixels.
Definition: retroflt.h:1455
retroflat_pxxy_t screen_h_remainder
Difference between viewport height and screen height in pixels. Should only be retrieved through retr...
Definition: retroflt.h:1211
retroflat_pxxy_t screen_y
Y position of the viewport in real screen memory in pixels. Should only be retrieved through retrofla...
Definition: retroflt.h:1161
retroflat_pxxy_t screen_x
X position of the viewport in real screen memory in pixels. Should only be retrieved through retrofla...
Definition: retroflt.h:1155
int16_t screen_tile_w
The number of tiles across that fit in the viewport. Should only be retrieved through retroflat_viewp...
Definition: retroflt.h:1218
retroflat_pxxy_t world_w
The width of the entire world tilemap in pixels. Should only be retrieved through retroflat_viewport_...
Definition: retroflt.h:1179
#define retroflat_viewport_set_pos_size(x_px, y_px, w_px, h_px)
Set the pixel width and height of the viewport, as well as some other dependent values frequently use...
Definition: retroflt.h:1503
retroflat_pxxy_t world_y
The Y offset, in pixels, of the viewport on the world tilemap. Should only be retrieved through retro...
Definition: retroflt.h:1173
retroflat_pxxy_t screen_w_remainder
Difference between viewport width and screen width in pixels. Should only be retrieved through retrof...
Definition: retroflt.h:1204
retroflat_pxxy_t screen_w
Viewport width in pixels. Should only be retrieved through retroflat_viewport_screen_w() and set thro...
Definition: retroflt.h:1191
int16_t screen_tile_h
The number of tiles high that fit in the viewport. Should only be retrieved through retroflat_viewpor...
Definition: retroflt.h:1225
retroflat_pxxy_t world_h
The height of the entire world tilemap in pixels. Should only be retrieved through retroflat_viewport...
Definition: retroflt.h:1185