maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
retroflt.h
Go to the documentation of this file.
1
2#ifndef RETROFLT_H
3#define RETROFLT_H
4
259/* === Generic Includes and Defines === */
260
261#ifndef RETROFLAT_BITMAP_TRACE_LVL
262# define RETROFLAT_BITMAP_TRACE_LVL 0
263#endif /* !RETROFLAT_BITMAP_TRACE_LVL */
264
265#ifndef RETROFLAT_KB_TRACE_LVL
266# define RETROFLAT_KB_TRACE_LVL 0
267#endif /* !RETROFLAT_KB_TRACE_LVL */
268
269#include <stdarg.h>
270
271#include <marge.h>
272
288#define RETROFLAT_COLOR_TABLE( f ) \
289 f( 0, black, BLACK, 0, 0, 0, BLACK, BLACK ) \
290 f( 1, darkblue, DARKBLUE, 0, 0, 170, CYAN, BLACK ) \
291 f( 2, darkgreen, DARKGREEN, 0, 170, 0, CYAN, BLACK ) \
292 f( 3, teal, TEAL, 0, 170, 170, CYAN, CYAN ) \
293 f( 4, darkred, DARKRED, 170, 0, 0, MAGENTA, BLACK ) \
294 f( 5, violet, VIOLET, 170, 0, 170, MAGENTA, BLACK ) \
295 f( 6, brown, BROWN, 170, 85, 0, CYAN, MAGENTA ) \
296 f( 7, gray, GRAY, 170, 170, 170, WHITE, BLACK ) \
297 f( 8, darkgray, DARKGRAY, 85, 85, 85, WHITE, BLACK ) \
298 f( 9, blue, BLUE, 85, 85, 255, CYAN, WHITE ) \
299 f( 10, green, GREEN, 85, 255, 85, CYAN, CYAN ) \
300 f( 11, cyan, CYAN, 85, 255, 255, CYAN, CYAN ) \
301 f( 12, red, RED, 255, 85, 85, MAGENTA, WHITE ) \
302 f( 13, magenta, MAGENTA, 255, 85, 255, MAGENTA, MAGENTA ) \
303 f( 14, yellow, YELLOW, 255, 255, 85, CYAN, MAGENTA ) \
304 f( 15, white, WHITE, 255, 255, 255, WHITE, WHITE )
305
307typedef int8_t RETROFLAT_COLOR;
308
309# define RETROFLAT_COLOR_NULL (-1)
310
311# define RETROFLAT_COLORS_SZ 16
312
315/* TODO: Mouse is broken under DOS/Allegro. */
316#if defined( RETROFLAT_OS_UNIX ) || defined( RETROFLAT_OS_WIN )
317#define RETROFLAT_MOUSE
318#endif /* RETROFLAT_OS_WIN || RETROFLAT_OS_WIN */
319
327#define RETROFLAT_OK 0x00
328#define RETROFLAT_ERROR_ENGINE 0x01
329#define RETROFLAT_ERROR_GRAPHICS 0x02
330#define RETROFLAT_ERROR_MOUSE 0x04
331
336#define RETROFLAT_ERROR_BITMAP 0x08
337#define RETROFLAT_ERROR_TIMER 0x0f
338
339 /* maug_retroflt_retval */
340
355#define RETROFLAT_FLAGS_FILL 0x01
356
361#define RETROFLAT_FLAGS_OPAQUE 0x01
362
369#define RETROFLAT_FLAGS_ALL_CAPS 0x02
370
374#define RETROFLAT_FLAGS_LITERAL_PATH 0x02
375
376#ifndef RETROFLAT_NO_STRING
383#define RETROFLAT_FLAGS_OUTLINE 0x04
384#endif /* !RETROFLAT_NO_STRING */
385
392#define RETROFLAT_FLAGS_SCREEN_BUFFER 0x80
393
398#define RETROFLAT_FLAGS_VIEWPORT_REFRESH 0x20
399
400 /* maug_retroflt_drawing */
401
413#define RETROFLAT_FLAGS_RUNNING 0x01
414
419#define RETROFLAT_FLAGS_UNLOCK_FPS 0x02
420
425#define RETROFLAT_FLAGS_KEY_REPEAT 0x04
426
431#define RETROFLAT_FLAGS_SCREENSAVER 0x08
432
436#define RETROFLAT_FLAGS_SCALE2X 0x10
437
441#define RETROFLAT_FLAGS_WAIT_FOR_FPS 0x20
442
443 /* maug_retroflt_flags */
444
453#define RETROFLAT_MSG_FLAG_TYPE_MASK 0x07
454
459#define RETROFLAT_MSG_FLAG_ERROR 0x01
460
466#define RETROFLAT_MSG_FLAG_INFO 0x02
467
473#define RETROFLAT_MSG_FLAG_WARNING 0x04
474
475 /* maug_retroflt_msg_flags */
476
477struct RETROFLAT_STATE;
478
498#define RETROFLAT_VDP_FLAG_PXLOCK 0x01
499
512
513 /* maug_retroflt_vdp */
514
515typedef MERROR_RETVAL (*retroflat_proc_resize_t)(
516 uint16_t new_w, uint16_t new_h, void* data );
517
523#define RETROSND_ARGS_FLAG_LIST_DEVS 0x01
524
556#define RETROFLAT_FLAGS_LOCK 0x01
557
558#define RETROFLAT_FLAGS_SCREEN_LOCK 0x02
559
560#define RETROFLAT_FLAGS_BITMAP_RO 0x04
561
567#define RETROFLAT_INSTANCE_NULL (0)
568
569#define retroflat_instance_tile( instance ) \
570 (instance * -1)
571
576#ifndef RETROFLAT_BITMAP_EXT
577# define RETROFLAT_BITMAP_EXT "bmp"
578#endif /* !RETROFLAT_BITMAP_EXT */
579
580#ifndef RETROFLAT_OPENGL_BPP
581# define RETROFLAT_OPENGL_BPP 32
582#endif /* !RETROFLAT_OPENGL_BPP */
583
584#ifndef RETROFLAT_TILE_W
585# define RETROFLAT_TILE_W 16
586#endif /* !RETROFLAT_TILE_W */
587
588#ifndef RETROFLAT_TILE_W_BITS
589# define RETROFLAT_TILE_W_BITS 4
590#endif /* !RETROFLAT_TILE_W_BITS */
591
592#ifndef RETROFLAT_TILE_H
593# define RETROFLAT_TILE_H 16
594#endif /* !RETROFLAT_TILE_H */
595
596#ifndef RETROFLAT_TILE_H_BITS
597# define RETROFLAT_TILE_H_BITS 4
598#endif /* !RETROFLAT_TILE_H_BITS */
599
600/* Transparency background color: black by default, to match Allegro. */
601#ifndef RETROFLAT_TXP_R
607# define RETROFLAT_TXP_R 0x00
608#endif /* !RETROFLAT_TXP_R */
609
610#ifndef RETROFLAT_TXP_G
616# define RETROFLAT_TXP_G 0x00
617#endif /* !RETROFLAT_TXP_G */
618
619#ifndef RETROFLAT_TXP_B
625# define RETROFLAT_TXP_B 0x00
626#endif /* !RETROFLAT_TXP_B */
627
628#ifndef RETROFLAT_TXP_PAL_IDX
629# define RETROFLAT_TXP_PAL_IDX 0
630#endif /* !RETROFLAT_TXP_PAL_IDX */
631
632 /* maug_retroflt_bitmap */
633
634#ifndef RETROFLAT_DEFAULT_SCREEN_W
635# define RETROFLAT_DEFAULT_SCREEN_W 320
636#endif /* RETROFLAT_DEFAULT_SCREEN_W */
637
638#ifndef RETROFLAT_DEFAULT_SCREEN_H
639# define RETROFLAT_DEFAULT_SCREEN_H 200
640#endif /* RETROFLAT_DEFAULT_SCREEN_H */
641
642#ifndef RETROFLAT_GL_Z
643# define RETROFLAT_GL_Z -0.001
644#endif /* !RETROFLAT_GL_Z */
645
646#define retroflat_on_resize( w, h ) \
647 g_retroflat_state->screen_w = w; \
648 g_retroflat_state->screen_h = h;
649
655#ifndef RETROFLAT_LINE_THICKNESS
660# define RETROFLAT_LINE_THICKNESS 1
661#endif /* !RETROFLAT_LINE_THICKNESS */
662
663#define RETROFLAT_PI 3.14159
664
665 /* maug_retroflt_drawing */
666
672#ifndef RETROFLAT_FPS
677# define RETROFLAT_FPS 30
678#endif /* !RETROFLAT_FPS */
679
680#define retroflat_fps_next() (1000 / RETROFLAT_FPS)
681
682#ifndef RETROFLAT_WINDOW_CLASS
687# define RETROFLAT_WINDOW_CLASS "RetroFlatWindowClass"
688#endif /* !RETROFLAT_WINDOW_CLASS */
689
690#ifndef RETROFLAT_WIN_FRAME_TIMER_ID
695# define RETROFLAT_WIN_FRAME_TIMER_ID 6001
696#endif /* !RETROFLAT_WIN_FRAME_TIMER_ID */
697
698#ifndef RETROFLAT_WIN_LOOP_TIMER_ID
703# define RETROFLAT_WIN_LOOP_TIMER_ID 6002
704#endif /* !RETROFLAT_WIN_LOOP_TIMER_ID */
705
706#ifndef RETROFLAT_MSG_MAX
711# define RETROFLAT_MSG_MAX 4096
712#endif /* !RETROFLAT_MSG_MAX */
713
714#define RETROFLAT_PATH_MAX MAUG_PATH_MAX
715
716#ifndef RETROFLAT_TITLE_MAX
717# define RETROFLAT_TITLE_MAX 255
718#endif /* !RETROFLAT_TITLE_MAX */
719
720#ifndef RETROFLAT_VDP_ARGS_SZ_MAX
724# define RETROFLAT_VDP_ARGS_SZ_MAX 255
725#endif /* !RETROFLAT_VDP_ARGS_SZ_MAX */
726
727#if defined( RETROFLAT_API_SDL2 )
728# if !defined( NO_RETROFLAT_RESIZABLE )
729# define RETROFLAT_WIN_FLAGS SDL_WINDOW_RESIZABLE
730# else
731# define RETROFLAT_WIN_FLAGS 0
732# endif /* !NO_RETROFLAT_RESIZABLE */
733#endif /* RETROFLAT_API_SDL2 */
734
735#if defined( RETROFLAT_API_SDL1 )
736# define RETROFLAT_SDL_CC_FLAGS (SDL_RLEACCEL | SDL_SRCCOLORKEY)
737#elif defined( RETROFLAT_API_SDL2 )
738# define RETROFLAT_SDL_CC_FLAGS (SDL_TRUE)
739#endif /* RETROFLAT_API_SDL1 || RETROFLAT_API_SDL2 */
740
741#ifdef RETROFLAT_OS_DOS
742# define RETROFLAT_PATH_SEP '\\'
743#else
745# define RETROFLAT_PATH_SEP '/'
746#endif /* RETROFLAT_OS_DOS */
747
749#define RETROFLAT_ASSETS_PATH_MAX (RETROFLAT_PATH_MAX >> 1)
750
751#ifndef RETROFLAT_BMP_COLORS_SZ_MAX
752# define RETROFLAT_BMP_COLORS_SZ_MAX 256
753#endif /* !RETROFLAT_BMP_COLORS_SZ_MAX */
754
755 /* maug_retroflt_compiling */
756
757#define retroflat_wait_for_frame() \
758 (g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_WAIT_FOR_FPS)
759
760#define retroflat_is_waiting_for_frame() \
761 (RETROFLAT_FLAGS_WAIT_FOR_FPS == \
762 (g_retroflat_state->retroflat_flags & RETROFLAT_FLAGS_WAIT_FOR_FPS))
763
774typedef char retroflat_asset_path[RETROFLAT_PATH_MAX];
775
779#define retroflat_cmp_asset_path( a, b ) strncmp( a, b, RETROFLAT_PATH_MAX )
780
781 /* maug_retroflt_assets */
782
786typedef void (*retroflat_loop_iter)(void* data);
787
797#define retroflat_buffer_bksp( buffer, buffer_cur, buffer_sz ) \
798 if( 0 < buffer_cur ) { \
799 if( buffer_cur < buffer_sz ) { \
800 memmove( \
801 &(buffer[(buffer_cur) - 1]), \
802 &(buffer[buffer_cur]), \
803 (buffer_sz) - (buffer_cur) ); \
804 } \
805 buffer_cur--; \
806 buffer_sz--; \
807 buffer[buffer_sz] = '\0'; \
808 }
809
813#define retroflat_buffer_insert( c, buffer, buffer_cur, buffer_sz, buffer_mx ) \
814 if( buffer_sz + 1 < buffer_mx ) { \
815 if( buffer_cur < buffer_sz ) { \
816 memmove( \
817 &(buffer[(buffer_cur) + 1]), \
818 &(buffer[buffer_cur]), \
819 (buffer_sz) - (buffer_cur) ); \
820 } \
821 buffer[buffer_cur] = c; \
822 buffer_cur++; \
823 buffer_sz++; \
824 buffer[buffer_sz] = '\0'; \
825 }
826
827#define RETROFLAT_INPUT_MOD_SHIFT 0x01
828
829#define RETROFLAT_INPUT_MOD_ALT 0x02
830
831#define RETROFLAT_INPUT_MOD_CTRL 0x04
832
833#define RETROFLAT_INPUT_FORCE_UPPER 0x08
834
847 uint8_t key_flags;
848};
849
850 /* maug_retroflt_input */
851
859#define RETROFLAT_DIR4_NORTH 0
860#define RETROFLAT_DIR4_EAST 1
861#define RETROFLAT_DIR4_SOUTH 2
862#define RETROFLAT_DIR4_WEST 3
863
864#define RETROFLAT_DIR8_NORTH 0
865#define RETROFLAT_DIR8_EAST 2
866#define RETROFLAT_DIR8_SOUTH 4
867#define RETROFLAT_DIR8_WEST 6
868
869#define retroflat_dir8_reverse( dir ) \
870 ((dir + 4) % 8)
871
872#define retroflat_dir8_bounce( dir ) \
873 ((dir + 2) % 8)
874
875 /* maug_retroflt_dir */
876
877#ifdef RETROFLAT_OPENGL
878struct RETROFLAT_GLTEX {
879 MAUG_MHANDLE bytes_h;
880 uint8_t* bytes;
881 uint32_t bpp;
882 uint32_t sz;
883 uint8_t* px;
884 uint32_t id;
885 size_t w;
886 size_t h;
887};
888#endif /* RETROFLAT_OPENGL */
889
890struct RETROFLAT_ARGS;
891
892#ifndef NO_RETROSND
893
922#ifndef RETROSND_TRACE_LVL
923# define RETROSND_TRACE_LVL 0
924#endif /* !RETROSND_TRACE_LVL */
925
926#ifndef RETROSND_REG_TRACE_LVL
927# define RETROSND_REG_TRACE_LVL 0
928#endif /* !RETROSND_REG_TRACE_LVL */
929
940#define RETROSND_FLAG_INIT 0x01
941
942 /* maug_retrosnd_flags */
943
944#define RETROSND_VOICE_BREATH 122
945
946#define RETROSND_VOICE_SEASHORE 123
947
948#define RETROSND_VOICE_BIRD_TWEET 124
949
950#define RETROSND_VOICE_PHONE_RING 125
951
952#define RETROSND_VOICE_HELICOPTER 126
953
954#define RETROSND_VOICE_APPLAUSE 127
955
960#define RETROSND_VOICE_GUNSHOT 128
961
962#define RETROSND_CHANNEL_CT 8
963
973
977void retrosnd_set_sf_bank( const char* filename_in );
978
979void retrosnd_midi_set_voice( uint8_t channel, uint8_t voice );
980
981void retrosnd_midi_set_control( uint8_t channel, uint8_t key, uint8_t val );
982
983void retrosnd_midi_note_on( uint8_t channel, uint8_t pitch, uint8_t vel );
984
985void retrosnd_midi_note_off( uint8_t channel, uint8_t pitch, uint8_t vel );
986
987MERROR_RETVAL retrosnd_midi_play_smf( const char* filename );
988
989uint8_t retrosnd_midi_is_playing_smf();
990
991void retrosnd_shutdown();
992
993 /* maug_retrosnd */
994
995#endif /* !NO_RETROSND */
996
997/* === OS-Specific Includes and Defines === */
998
999#if defined( RETROFLAT_OS_WIN ) && !defined( MAUG_WINDOWS_H )
1000# include <windows.h>
1001# define MAUG_WINDOWS_H
1002#endif /* !MAUG_WINDOWS_H */
1003
1004/* TODO: Migrate all platform-specific parts below to retapid.h. */
1005#include <retapid.h>
1006
1007typedef maug_ms_t retroflat_ms_t;
1008
1009/* === Structures === */
1010
1017 char* title;
1020 uint8_t flags;
1023# ifdef RETROFLAT_API_PC_BIOS
1025 uint8_t screen_mode;
1026# elif !defined( RETROFLAT_NO_CLI_SZ )
1027 int screen_w;
1034# endif /* RETROFLAT_API_PC_BIOS */
1035 uint8_t snd_flags;
1036# if defined( RETROSND_API_SDL1 ) || defined( RETROSND_API_SDL2 )
1037# elif defined( RETROSND_API_WINMM )
1038 UINT snd_dev_id;
1039# elif defined( RETROSND_API_PC_BIOS )
1040 uint16_t snd_io_base;
1041 uint8_t snd_driver;
1042# elif defined( RETROSND_API_ALSA )
1043 uint8_t snd_client;
1044 uint8_t snd_port;
1045# else
1046# pragma message( "warning: sound args not specified" )
1047# endif /* RETROSND_API_WINMM */
1048};
1049
1057typedef int16_t retroflat_tile_t;
1058
1061 int16_t screen_x;
1063 int16_t screen_y;
1064 int16_t world_x;
1065 int16_t world_y;
1066 int16_t world_w;
1067 int16_t world_h;
1068 int16_t screen_tile_w;
1069 int16_t screen_tile_h;
1070 MAUG_MHANDLE refresh_grid_h;
1071 retroflat_tile_t* refresh_grid;
1072};
1073
1074#ifndef DOCUMENTATION
1075
1076# define retroflat_viewport_world_x_generic() \
1077 (g_retroflat_state->viewport.world_x)
1078
1079# define retroflat_viewport_world_y_generic() \
1080 (g_retroflat_state->viewport.world_y)
1081
1082# define retroflat_viewport_world_w_generic() \
1083 (g_retroflat_state->viewport.world_w)
1084
1085# define retroflat_viewport_world_h_generic() \
1086 (g_retroflat_state->viewport.world_h)
1087
1088# define retroflat_viewport_screen_tile_w_generic() \
1089 (g_retroflat_state->viewport.screen_tile_w)
1090
1091# define retroflat_viewport_screen_tile_h_generic() \
1092 (g_retroflat_state->viewport.screen_tile_h)
1093
1094# define retroflat_viewport_set_world_generic( w, h ) \
1095 (g_retroflat_state->viewport.world_w) = w; \
1096 (g_retroflat_state->viewport.world_h) = h;
1097
1098# define retroflat_viewport_set_world_pos_generic( x, y ) \
1099 (g_retroflat_state->viewport.world_x) = x; \
1100 (g_retroflat_state->viewport.world_y) = y;
1101
1102# define retroflat_viewport_lock_refresh_generic() \
1103 if( NULL == g_retroflat_state->viewport.refresh_grid ) { \
1104 maug_mlock( \
1105 g_retroflat_state->viewport.refresh_grid_h, \
1106 g_retroflat_state->viewport.refresh_grid ); \
1107 maug_cleanup_if_null_lock( retroflat_tile_t*, \
1108 g_retroflat_state->viewport.refresh_grid ); \
1109 }
1110
1111# define retroflat_viewport_unlock_refresh_generic() \
1112 if( NULL != g_retroflat_state->viewport.refresh_grid ) { \
1113 maug_munlock( \
1114 g_retroflat_state->viewport.refresh_grid_h, \
1115 g_retroflat_state->viewport.refresh_grid ); \
1116 }
1117
1118# define _retroflat_viewport_refresh_tile_x( x_px ) \
1119 (((x_px) + RETROFLAT_TILE_W) >> RETROFLAT_TILE_W_BITS)
1120
1121# define _retroflat_viewport_refresh_tile_y( y_px ) \
1122 (((y_px) + RETROFLAT_TILE_H) >> RETROFLAT_TILE_H_BITS)
1123
1124# define retroflat_viewport_set_refresh_generic( x_px, y_px, tid ) \
1125 assert( NULL != g_retroflat_state->viewport.refresh_grid ); \
1126 if( \
1127 /* Expand the range by -1 to account for just off-screen tile. */ \
1128 -(RETROFLAT_TILE_W) <= x_px && -(RETROFLAT_TILE_H) <= y_px && \
1129 retroflat_screen_w() > x_px && \
1130 retroflat_screen_h() > y_px \
1131 ) { \
1132 assert( 0 < g_retroflat_state->viewport.screen_tile_w ); \
1133 assert( 0 <= (((y_px) + RETROFLAT_TILE_H) >> RETROFLAT_TILE_H_BITS) ); \
1134 assert( 0 <= (((x_px) + RETROFLAT_TILE_W) >> RETROFLAT_TILE_W_BITS) ); \
1135 g_retroflat_state->viewport.refresh_grid[ \
1136 /* Add +1 tile to make off-screen "-1" tile positive. */ \
1137 (_retroflat_viewport_refresh_tile_y( y_px ) * \
1138 g_retroflat_state->viewport.screen_tile_w) + \
1139 _retroflat_viewport_refresh_tile_x( x_px )] = tid; \
1140 }
1141
1142# define retroflat_viewport_tile_is_stale( x_px, y_px, tile_id ) \
1143 ((tile_id) != \
1144 g_retroflat_state->viewport.refresh_grid[ \
1145 (_retroflat_viewport_refresh_tile_y( y_px ) * \
1146 g_retroflat_state->viewport.screen_tile_w) + \
1147 _retroflat_viewport_refresh_tile_x( x_px )])
1148
1149uint8_t retroflat_viewport_move_x_generic( int16_t x );
1150
1151uint8_t retroflat_viewport_move_y_generic( int16_t y );
1152
1153uint8_t retroflat_viewport_focus_generic(
1154 size_t x1, size_t y1, size_t range, size_t speed );
1155
1156# define retroflat_viewport_screen_x_generic( world_x ) \
1157 ((world_x) - retroflat_viewport_world_x())
1158
1159# define retroflat_viewport_screen_y_generic( world_y ) \
1160 ((world_y) - retroflat_viewport_world_y())
1161
1162#endif /* !DOCUMENTATION */
1163
1164#if defined( RETROFLAT_SOFT_VIEWPORT ) || defined( DOCUMENTATION )
1165
1166# ifdef RETROFLAT_VIEWPORT_ADAPT
1167 /* Clamp world coordinates to tile borders to allow refresh grid to
1168 * function properly.
1169 */
1170# define retroflat_viewport_world_x() \
1171 ((retroflat_viewport_world_x_generic() \
1172 >> RETROFLAT_TILE_W_BITS) << RETROFLAT_TILE_W_BITS)
1173# define retroflat_viewport_world_y() \
1174 ((retroflat_viewport_world_y_generic() \
1175 >> RETROFLAT_TILE_H_BITS) << RETROFLAT_TILE_H_BITS)
1176# else
1178# define retroflat_viewport_world_x() retroflat_viewport_world_x_generic()
1179
1181# define retroflat_viewport_world_y() retroflat_viewport_world_y_generic()
1182#endif /* RETROFLAT_VIEWPORT_ADAPT */
1183
1185# define retroflat_viewport_world_w() \
1186 retroflat_viewport_world_w_generic()
1187
1189# define retroflat_viewport_world_h() \
1190 retroflat_viewport_world_h_generic()
1191
1192# define retroflat_viewport_screen_tile_w() \
1193 retroflat_viewport_screen_tile_w_generic()
1194
1195# define retroflat_viewport_screen_tile_h() \
1196 retroflat_viewport_screen_tile_h_generic()
1197
1204# define retroflat_viewport_set_world( w, h ) \
1205 retroflat_viewport_set_world_generic( w, h )
1206
1207# define retroflat_viewport_set_world_pos( x, y ) \
1208 retroflat_viewport_set_world_pos_generic( x, y )
1209
1210# define retroflat_viewport_lock_refresh() \
1211 retroflat_viewport_lock_refresh_generic()
1212
1213# define retroflat_viewport_unlock_refresh() \
1214 retroflat_viewport_unlock_refresh_generic()
1215
1216# define retroflat_viewport_set_refresh( x, y, tid ) \
1217 retroflat_viewport_set_refresh_generic( x, y, tid )
1218
1231# define retroflat_viewport_focus( x1, y1, range, speed ) \
1232 retroflat_viewport_focus_generic( x1, y1, range, speed )
1233
1238# define retroflat_viewport_screen_x( world_x ) \
1239 retroflat_viewport_screen_x_generic( world_x )
1240
1245# define retroflat_viewport_screen_y( world_y ) \
1246 retroflat_viewport_screen_y_generic( world_y )
1247
1248# ifndef RETROFLAT_VIEWPORT_OVERRIDE_MOVE
1249# define retroflat_viewport_move_x( x ) \
1250 retroflat_viewport_move_x_generic( x )
1251
1252# define retroflat_viewport_move_y( y ) \
1253 retroflat_viewport_move_y_generic( y )
1254# endif /* !RETROFLAT_VIEWPORT_OVERRIDE_MOVE */
1255
1256#endif /* RETROFLAT_SOFT_VIEWPORT || DOCUMENTATION */
1257
1262 void* loop_data;
1263 MERROR_RETVAL retval;
1266 char config_path[RETROFLAT_PATH_MAX + 1];
1267 char assets_path[RETROFLAT_ASSETS_PATH_MAX + 1];
1268 /* TODO: Make indirect palette optional per-platform. */
1270 RETROFLAT_COLOR_DEF palette[RETROFLAT_COLORS_SZ];
1273
1274# if defined( RETROFLAT_VDP ) || defined( DOCUMENTATION ) || \
1275defined( RETROVDP_C )
1281# ifdef RETROFLAT_OS_WIN
1282 HMODULE vdp_exe;
1283# else
1285 void* vdp_exe;
1286# endif /* RETROFLAT_OS_WIN */
1295 uint8_t vdp_flags;
1296# endif /* RETROFLAT_VDP || DOCUMENTATION || RETROVDP_C */
1297
1298 /* These are used by VDP so should be standardized/not put in plat-spec! */
1299
1300 struct RETROFLAT_VIEWPORT viewport;
1301
1317 size_t screen_w;
1319 size_t screen_h;
1320
1321 /* WARNING: The VDP requires the state specifier to be the same size
1322 * as the one it was compiled for! Do not modify above here!
1323 */
1324
1325 /* TODO: Put these in a platform-specific struct of some kind to maintain
1326 * consistent state struct size for VDP?
1327 */
1328
1329 retroflat_loop_iter loop_iter;
1330 retroflat_loop_iter frame_iter;
1331
1332 retroflat_proc_resize_t on_resize;
1333 void* on_resize_data;
1334
1335# if defined( RETROFLAT_OPENGL )
1336 uint8_t tex_palette[RETROFLAT_COLORS_SZ][3];
1337# endif /* RETROFLAT_OPENGL */
1338
1339 struct RETROFLAT_PLATFORM platform;
1340
1341#ifndef NO_RETROSND
1342 struct RETROFLAT_SOUND sound;
1343#endif /* !NO_RETROSND */
1344};
1345
1346/* === Translation Module === */
1347
1348/* Declare the prototypes so that internal functions can call each other. */
1349
1350# ifdef retroflat_loop
1351MERROR_RETVAL retroflat_loop_generic(
1352 retroflat_loop_iter frame_iter, retroflat_loop_iter loop_iter, void* data );
1353# else
1360 retroflat_loop_iter frame_iter, retroflat_loop_iter loop_iter, void* data );
1361# endif /* retroflat_loop */
1362
1370 uint8_t flags, const char* title, const char* format, ... );
1371
1379MERROR_RETVAL retroflat_init( int argc, char* argv[], struct RETROFLAT_ARGS* args );
1380
1387void retroflat_shutdown( int retval );
1388
1389# if defined( RETROFLAT_VDP ) || defined( DOCUMENTATION )
1398MERROR_RETVAL retroflat_vdp_call( const char* proc_name );
1399
1400 /* maug_retroflt_vdp */
1401# endif /* RETROFLAT_VDP || DOCUMENTATION */
1402
1403void retroflat_set_title( const char* format, ... );
1404
1405retroflat_ms_t retroflat_get_ms();
1406
1407uint32_t retroflat_get_rand();
1408
1409# if !defined( RETROFLAT_NO_KEYBOARD )
1410char retroflat_vk_to_ascii( RETROFLAT_IN_KEY k, uint8_t flags );
1411# endif /* !RETROFLAT_NO_KEYBOARD */
1412
1429 const char* filename, struct RETROFLAT_BITMAP* bmp_out, uint8_t flags );
1430
1431MERROR_RETVAL retroflat_create_bitmap(
1432 size_t w, size_t h, struct RETROFLAT_BITMAP* bmp_out, uint8_t flags );
1433
1440
1455 struct RETROFLAT_BITMAP* target, struct RETROFLAT_BITMAP* src,
1456 size_t s_x, size_t s_y, int16_t d_x, int16_t d_y, size_t w, size_t h,
1457 int16_t instance );
1458
1466#define retroflat_constrain_px( x, y, bmp, retact ) \
1467 if( \
1468 x >= retroflat_bitmap_w( bmp ) || y >= retroflat_bitmap_h( bmp ) \
1469 ) { retact; }
1470
1471 /* maug_retroflt_bitmap */
1472
1488
1489MERROR_RETVAL retroflat_draw_release( struct RETROFLAT_BITMAP* bmp );
1490
1491void retroflat_px(
1492 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
1493 size_t x, size_t y, uint8_t flags );
1494
1495#ifdef RETROFLAT_SOFT_SHAPES
1496# ifdef RETROFLAT_OPENGL
1497/* Make sure we're not passing NULL to openGL texture drawers... they can't
1498 * handle that!
1499 */
1500# define retroflat_rect( t, c, x, y, w, h, f ) \
1501 assert( NULL != t ); \
1502 retrosoft_rect( t, c, x, y, w, h, f );
1503# define retroflat_ellipse( t, c, x, y, w, h, f ) \
1504 assert( NULL != t ); \
1505 retrosoft_ellipse( t, c, x, y, w, h, f )
1506# else
1507# define retroflat_rect( t, c, x, y, w, h, f ) \
1508 retrosoft_rect( t, c, x, y, w, h, f )
1509# define retroflat_ellipse( t, c, x, y, w, h, f ) \
1510 retrosoft_ellipse( t, c, x, y, w, h, f )
1511# endif /* RETROFLAT_OPENGL */
1512#else
1513
1525 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
1526 int16_t x, int16_t y, int16_t w, int16_t h, uint8_t flags );
1527
1539 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
1540 int16_t x, int16_t y, int16_t w, int16_t h, uint8_t flags );
1541
1542#endif /* RETROFLAT_SOFT_SHAPES */
1543
1544#ifdef RETROFLAT_SOFT_LINES
1545# define retroflat_line( t, c, x1, y1, x2, y2, f ) \
1546 retrosoft_line( t, c, x1, y1, x2, y2, f )
1547#else
1548
1561 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
1562 int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t flags );
1563
1564#endif /* RETROFLAT_SOFT_LINES */
1565
1566void retroflat_cursor( struct RETROFLAT_BITMAP* target, uint8_t flags );
1567
1581 struct RETROFLAT_BITMAP* target, const char* str, size_t str_sz,
1582 const char* font_str, size_t* w_out, size_t* h_out, uint8_t flags );
1583
1602 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
1603 const char* str, int str_sz, const char* font_str, int16_t x_orig, int16_t y_orig,
1604 uint8_t flags );
1605
1606/* TODO: Documentation! */
1607void retroflat_get_palette( uint8_t idx, uint32_t* rgb );
1608
1609MERROR_RETVAL retroflat_set_palette( uint8_t idx, uint32_t rgb );
1610
1611 /* maug_retroflt_bitmap */
1612
1623 retroflat_proc_resize_t on_resize_in, void* data_in );
1624
1630
1641RETROFLAT_IN_KEY retroflat_poll_input( struct RETROFLAT_INPUT* input );
1642
1643 /* maug_retroflt_input */
1644
1645#ifdef RETROFLT_C
1646
1647MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets8_x[8] =
1648 { 0, 1, 1, 1, 0, -1, -1, -1 };
1649MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets8_y[8] =
1650 { -1, -1, 0, 1, 1, 1, 0, -1 };
1651
1652MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets4_x[4] =
1653 { 0, 1, 0, -1 };
1654MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets4_y[4] =
1655 { -1, 0, 1, 0 };
1656
1657MAUG_MHANDLE g_retroflat_state_h = (MAUG_MHANDLE)NULL;
1658struct RETROFLAT_STATE* g_retroflat_state = NULL;
1659
1660# define RETROFLAT_COLOR_TABLE_CONSTS( idx, name_l, name_u, r, g, b, cgac, cgad ) \
1661 MAUG_CONST RETROFLAT_COLOR RETROFLAT_COLOR_ ## name_u = idx;
1662
1663RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_CONSTS )
1664
1665# define RETROFLAT_COLOR_TABLE_NAMES( idx, name_l, name_u, r, g, b, cgac, cgad ) \
1666 #name_u,
1667
1668MAUG_CONST char* SEG_MCONST gc_retroflat_color_names[] = {
1669 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_NAMES )
1670};
1671
1672/* Callback table is down below, after the statically-defined callbacks. */
1673
1674/* === Function Definitions === */
1675
1676MERROR_RETVAL retroflat_build_filename_path(
1677 const char* filename_in,
1678 char* buffer_out, size_t buffer_out_sz, uint8_t flags
1679) {
1680 MERROR_RETVAL retval = MERROR_OK;
1681
1682 assert( 1 < buffer_out_sz );
1683
1684 /* Build the path to the bitmap. */
1685 memset( buffer_out, '\0', buffer_out_sz );
1686 if(
1689 ) {
1690 /* TODO: Error checking. */
1691 maug_snprintf( buffer_out, buffer_out_sz - 1, "%s", filename_in );
1692 } else {
1693 /* TODO: Error checking. */
1694 maug_snprintf( buffer_out, buffer_out_sz - 1, "%s%c%s.%s",
1695 g_retroflat_state->assets_path, RETROFLAT_PATH_SEP,
1696 filename_in, RETROFLAT_BITMAP_EXT );
1697 }
1698
1699 return retval;
1700}
1701
1702/* === */
1703
1704# if (defined( RETROFLAT_SOFT_SHAPES ) || defined( RETROFLAT_SOFT_LINES )) \
1705 && !defined( MAUG_NO_AUTO_C )
1706# define RETROFP_C
1707# include <retrofp.h>
1708# define RETROSFT_C
1709# include <retrosft.h>
1710# endif /* RETROFLAT_SOFT_SHAPES */
1711
1712# if defined( RETROFLAT_OPENGL ) && !defined( MAUG_NO_AUTO_C )
1713# define RETROGLU_C
1714# include <retroglu.h>
1715# define RETROFP_C
1716# include <retrofp.h>
1717# define RETROSFT_C
1718# include <retrosft.h>
1719# endif /* RETROFLAT_OPENGL */
1720
1721# if defined( RETROFLAT_VDP ) && defined( RETROFLAT_OS_UNIX )
1722# include <dlfcn.h>
1723# endif
1724
1725/* Still inside RETROFLT_C! */
1726
1727/* === */
1728
1729#ifndef RETROFLAT_NO_GENERIC_LOOP
1730
1731MERROR_RETVAL retroflat_loop_generic(
1732 retroflat_loop_iter frame_iter, retroflat_loop_iter loop_iter, void* data
1733) {
1734 MERROR_RETVAL retval = MERROR_OK;
1735 retroflat_ms_t next = 0,
1736 now = 0;
1737
1738 g_retroflat_state->loop_iter = (retroflat_loop_iter)loop_iter;
1739 g_retroflat_state->loop_data = (void*)data;
1740 g_retroflat_state->frame_iter = (retroflat_loop_iter)frame_iter;
1741
1742 if(
1744 (g_retroflat_state->retroflat_flags & RETROFLAT_FLAGS_RUNNING)
1745 ) {
1746 /* Main loop is already running, so we're just changing the iter call
1747 * and leaving!
1748 */
1749 debug_printf( 1, "main loop already running!" );
1750 goto cleanup;
1751 }
1752
1753 g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_RUNNING;
1754 do {
1755 if(
1756 /* Not waiting for the next frame? */
1758 (RETROFLAT_FLAGS_WAIT_FOR_FPS & g_retroflat_state->retroflat_flags) &&
1759 /* Inter-frame loop present? */
1760 NULL != g_retroflat_state->loop_iter
1761 ) {
1762 /* Run the loop iter as many times as possible. */
1763 g_retroflat_state->loop_iter( g_retroflat_state->loop_data );
1764 }
1765 if(
1767 (RETROFLAT_FLAGS_UNLOCK_FPS & g_retroflat_state->retroflat_flags) &&
1768 retroflat_get_ms() < next
1769 ) {
1770 /* Sleep/low power for a bit. */
1771 continue;
1772 }
1773 if( NULL != g_retroflat_state->frame_iter ) {
1774 /* Run the frame iterator once per FPS tick. */
1775 g_retroflat_state->frame_iter( g_retroflat_state->loop_data );
1776 }
1777 /* Reset wait-for-frame flag AFTER frame callback. */
1778 g_retroflat_state->retroflat_flags &= ~RETROFLAT_FLAGS_WAIT_FOR_FPS;
1779 now = retroflat_get_ms();
1780 if( now + retroflat_fps_next() > now ) {
1781 next = now + retroflat_fps_next();
1782 } else {
1783 /* Rollover protection. */
1784 /* TODO: Add difference from now/next to 0 here. */
1785 next = 0;
1786 }
1787 } while(
1789 (RETROFLAT_FLAGS_RUNNING & g_retroflat_state->retroflat_flags)
1790 );
1791 retval = g_retroflat_state->retval;
1792
1793cleanup:
1794
1795 /* This should be set by retroflat_quit(). */
1796 return retval;
1797}
1798
1799#endif /* !RETROFLAT_NO_GENERIC_LOOP */
1800
1801/* === */
1802
1803# if !defined( RETROFLAT_NO_KEYBOARD )
1804
1805char retroflat_vk_to_ascii( RETROFLAT_IN_KEY k, uint8_t flags ) {
1806 char c = 0;
1807 char offset_lower = 0;
1808
1809 if( RETROFLAT_INPUT_MOD_SHIFT != (RETROFLAT_INPUT_MOD_SHIFT & flags) ) {
1810 /* Shift is *not* being held down. */
1811
1812 if( RETROFLAT_KEY_A <= k && RETROFLAT_KEY_Z >= k ) {
1813 if(
1814 RETROFLAT_INPUT_FORCE_UPPER !=
1815 (RETROFLAT_INPUT_FORCE_UPPER & flags)
1816 ) {
1817 /* Key is alphabetical and we're not forcing uppercase. */
1818 offset_lower = 0x20;
1819 }
1820 } else {
1821 offset_lower = 1;
1822 }
1823 }
1824
1825 switch( k ) {
1826 case RETROFLAT_KEY_A: c = 0x41 + offset_lower; break;
1827 case RETROFLAT_KEY_B: c = 0x42 + offset_lower; break;
1828 case RETROFLAT_KEY_C: c = 0x43 + offset_lower; break;
1829 case RETROFLAT_KEY_D: c = 0x44 + offset_lower; break;
1830 case RETROFLAT_KEY_E: c = 0x45 + offset_lower; break;
1831 case RETROFLAT_KEY_F: c = 0x46 + offset_lower; break;
1832 case RETROFLAT_KEY_G: c = 0x47 + offset_lower; break;
1833 case RETROFLAT_KEY_H: c = 0x48 + offset_lower; break;
1834 case RETROFLAT_KEY_I: c = 0x49 + offset_lower; break;
1835 case RETROFLAT_KEY_J: c = 0x4a + offset_lower; break;
1836 case RETROFLAT_KEY_K: c = 0x4b + offset_lower; break;
1837 case RETROFLAT_KEY_L: c = 0x4c + offset_lower; break;
1838 case RETROFLAT_KEY_M: c = 0x4d + offset_lower; break;
1839 case RETROFLAT_KEY_N: c = 0x4e + offset_lower; break;
1840 case RETROFLAT_KEY_O: c = 0x4f + offset_lower; break;
1841 case RETROFLAT_KEY_P: c = 0x50 + offset_lower; break;
1842 case RETROFLAT_KEY_Q: c = 0x51 + offset_lower; break;
1843 case RETROFLAT_KEY_R: c = 0x52 + offset_lower; break;
1844 case RETROFLAT_KEY_S: c = 0x53 + offset_lower; break;
1845 case RETROFLAT_KEY_T: c = 0x54 + offset_lower; break;
1846 case RETROFLAT_KEY_U: c = 0x55 + offset_lower; break;
1847 case RETROFLAT_KEY_V: c = 0x56 + offset_lower; break;
1848 case RETROFLAT_KEY_W: c = 0x57 + offset_lower; break;
1849 case RETROFLAT_KEY_X: c = 0x58 + offset_lower; break;
1850 case RETROFLAT_KEY_Y: c = 0x59 + offset_lower; break;
1851 case RETROFLAT_KEY_Z: c = 0x60 + offset_lower; break;
1852 case RETROFLAT_KEY_0: c = offset_lower ? 0x30 : ')'; break;
1853 case RETROFLAT_KEY_1: c = offset_lower ? 0x31 : '!'; break;
1854 case RETROFLAT_KEY_2: c = offset_lower ? 0x32 : '@'; break;
1855 case RETROFLAT_KEY_3: c = offset_lower ? 0x33 : '#'; break;
1856 case RETROFLAT_KEY_4: c = offset_lower ? 0x34 : '$'; break;
1857 case RETROFLAT_KEY_5: c = offset_lower ? 0x35 : '%'; break;
1858 case RETROFLAT_KEY_6: c = offset_lower ? 0x36 : '^'; break;
1859 case RETROFLAT_KEY_7: c = offset_lower ? 0x37 : '&'; break;
1860 case RETROFLAT_KEY_8: c = offset_lower ? 0x38 : '*'; break;
1861 case RETROFLAT_KEY_9: c = offset_lower ? 0x39 : '('; break;
1862 case RETROFLAT_KEY_SPACE: c = ' '; break;
1863 case RETROFLAT_KEY_BKSP: c = 0x08; break;
1864 case RETROFLAT_KEY_ENTER: c = '\n'; break;
1865 case RETROFLAT_KEY_SEMICOLON: c = offset_lower ? ';' : ':'; break;
1866 case RETROFLAT_KEY_DASH: c = offset_lower ? '-' : '_'; break;
1867 case RETROFLAT_KEY_SLASH: c = offset_lower ? '/' : '?'; break;
1868 case RETROFLAT_KEY_PERIOD: c = offset_lower ? '.' : '>'; break;
1869 case RETROFLAT_KEY_COMMA: c = offset_lower ? ',' : '<'; break;
1870 case RETROFLAT_KEY_QUOTE: c = offset_lower ? '\'' : '"'; break;
1871 case RETROFLAT_KEY_EQUALS: c = offset_lower ? '=' : '+'; break;
1872 case RETROFLAT_KEY_BACKSLASH: c = offset_lower ? '\\' : '|'; break;
1873 case RETROFLAT_KEY_BRACKETL: c = offset_lower ? '[' : '{'; break;
1874 case RETROFLAT_KEY_BRACKETR: c = offset_lower ? ']' : '}'; break;
1875#ifndef RETROFLAT_API_PC_BIOS
1876 /* TODO: FIXME in DOS! */
1877 case RETROFLAT_KEY_GRAVE: c = offset_lower ? '`' : '~'; break;
1878#endif /* !RETROFLAT_API_PC_BIOS */
1879 }
1880
1881 debug_printf( RETROFLAT_KB_TRACE_LVL, "0x%02x", c );
1882
1883 return c;
1884}
1885
1886#endif /* !RETROFLAT_NO_KEYBOARD */
1887
1888/* === */
1889
1890/* TODO: Migrate all platform-specific parts below to retapif.h. */
1891#include <retapif.h>
1892
1893/* === */
1894
1895# ifndef RETROFLAT_NO_CLI
1896
1897# ifdef RETROSND_ARGS
1898
1899static MERROR_RETVAL retrosnd_cli_rsl(
1900 const char* arg, ssize_t arg_c, struct RETROFLAT_ARGS* args
1901) {
1902 if(
1903 0 <= arg_c &&
1904 0 == strncmp( MAUG_CLI_SIGIL "rsl", arg, MAUG_CLI_SIGIL_SZ + 4 )
1905 ) {
1906 args->snd_flags |= RETROSND_ARGS_FLAG_LIST_DEVS;
1907 }
1908 return MERROR_OK;
1909}
1910
1911static MERROR_RETVAL retrosnd_cli_rsd(
1912 const char* arg, ssize_t arg_c, struct RETROFLAT_ARGS* args
1913) {
1914 MERROR_RETVAL retval = MERROR_OK;
1915# if defined( RETROSND_API_PC_BIOS ) || defined( RETROSND_API_ALSA )
1916 char* env_var = NULL;
1917 size_t i = 0;
1918# elif defined( RETROSND_API_ALSA )
1919 char* env_var = NULL;
1920# elif defined( RETROSND_API_WINMM )
1921 char* env_var = NULL;
1922# endif /* RETROSND_API_PC_BIOS || RETROSND_API_ALSA */
1923
1924 if( 0 > arg_c ) {
1925# ifdef RETROSND_API_PC_BIOS
1926 if( NULL != env_var ) {
1927 env_var = getenv( "MAUG_MIDI_DOS" );
1928
1929 /* Return MERROR_OK since this isn't fatal and will just cause sound
1930 * init to fail later.
1931 */
1932 maug_cleanup_if_null_msg(
1933 char*, env_var, MERROR_OK, "MAUG_MIDI_DOS variable not found!" );
1934
1935 debug_printf( 2, "env: MAUG_MIDI_DOS: %s", env_var );
1936
1937 /* Turn comma separator into NULL split. */
1938 for( i = 0 ; maug_strlen( env_var ) > i ; i++ ) {
1939 if( ',' == env_var[i] ) {
1940 /* Split into two null-terminated strings. */
1941 env_var[i] = '\0';
1942 }
1943 }
1944
1945 if( 0 == strcmp( env_var, "mpu" ) ) {
1946 debug_printf( 3, "selecting MIDI driver: mpu" );
1947 args->snd_driver = 2;
1948 } else if( 0 == strcmp( env_var, "gus" ) ) {
1949 debug_printf( 3, "selecting MIDI driver: gus" );
1950 args->snd_driver = 4;
1951 } else if( 0 == strcmp( env_var, "adlib" ) ) {
1952 debug_printf( 3, "selecting MIDI driver: adlib" );
1953 args->snd_driver = 8;
1954 }
1955 /* TODO: Maug replacement for C99 crutch. */
1956 args->snd_io_base = strtoul( &(env_var[i]), NULL, 16 );
1957 debug_printf( 3, "setting MIDI I/O base: %u", args->snd_io_base );
1958 } else {
1959 /* default */
1960 debug_printf( 3, "default MIDI driver: adlib" );
1961 args->snd_driver = 8;
1962 args->snd_io_base = 0x388;
1963 }
1964
1965# elif defined( RETROSND_API_ALSA )
1966 if( 0 == args->snd_client ) {
1967 env_var = getenv( "MAUG_MIDI_ALSA" );
1968
1969 /* Return MERROR_OK since this isn't fatal and will just cause sound
1970 * init to fail later.
1971 */
1972 maug_cleanup_if_null_msg(
1973 char*, env_var, MERROR_OK, "MAUG_MIDI_ALSA variable not found!" );
1974
1975 debug_printf( 2, "env: MAUG_MIDI_ALSA: %s", env_var );
1976
1977 for( i = 0 ; maug_strlen( env_var ) > i ; i++ ) {
1978 if( ':' == env_var[i] ) {
1979 /* Split into two null-terminated strings. */
1980 env_var[i] = '\0';
1981 }
1982 }
1983
1984 args->snd_client = atoi( env_var );
1985 args->snd_port = atoi( &(env_var[i]) );
1986 debug_printf( 3, "setting MIDI device to: %u:%u",
1987 args->snd_client, args->snd_port );
1988 }
1989
1990# elif defined( RETROSND_API_WINMM )
1991 env_var = getenv( "MAUG_MIDI_WIN" );
1992
1993 /* Return MERROR_OK since this isn't fatal and will just cause sound
1994 * init to fail later.
1995 */
1996 maug_cleanup_if_null_msg(
1997 char*, env_var, MERROR_OK, "MAUG_MIDI_WIN variable not found!" );
1998
1999 debug_printf( 2, "env: MAUG_MIDI_WIN: %s", env_var );
2000
2001 if( NULL != env_var ) {
2002 args->snd_dev_id = atoi( env_var );
2003 } else {
2004 args->snd_dev_id = 0;
2005 }
2006 debug_printf( 3, "setting MIDI device to: %u", args->snd_dev_id );
2007
2008# endif /* RETROSND_API_PC_BIOS || RETROSND_API_ALSA || RETROSND_API_WINMM */
2009 } else if(
2010 0 == strncmp( MAUG_CLI_SIGIL "rsd", arg, MAUG_CLI_SIGIL_SZ + 4 )
2011 ) {
2012 /* The next arg must be the new var. */
2013 } else {
2014# ifdef RETROSND_API_PC_BIOS
2015 /* TODO: Parse device. */
2016# elif defined( RETROSND_API_ALSA )
2017 /* TODO: Parse device. */
2018# elif defined( RETROSND_API_WINMM )
2019 debug_printf( 3, "setting MIDI device to rsd arg: %s", arg );
2020 args->snd_dev_id = atoi( arg );
2021# endif /* RETROSND_API_PC_BIOS || RETROSND_API_ALSA || RETROSND_API_WINMM */
2022 }
2023
2024# if defined( RETROSND_API_PC_BIOS ) || defined( RETROSND_API_ALSA )
2025cleanup:
2026# elif defined( RETROSND_API_ALSA )
2027cleanup:
2028# elif defined( RETROSND_API_WINMM )
2029cleanup:
2030# endif /* RETROSND_API_PC_BIOS || RETROSND_API_ALSA */
2031
2032 return retval;
2033}
2034
2035# endif /* RETROSND_ARGS */
2036
2037# if !defined( RETROFLAT_API_PC_BIOS ) && !defined( RETROFLAT_NO_CLI_SZ )
2038
2039static MERROR_RETVAL retroflat_cli_rfx(
2040 const char* arg, ssize_t arg_c, struct RETROFLAT_ARGS* args
2041) {
2042 if( 0 > arg_c ) {
2043 if( 0 == args->screen_w ) {
2044 args->screen_x = 0;
2045 }
2046 } else if(
2047 0 == strncmp( MAUG_CLI_SIGIL "rfx", arg, MAUG_CLI_SIGIL_SZ + 4 )
2048 ) {
2049 /* The next arg must be the new var. */
2050 } else {
2051 args->screen_x = atoi( arg );
2052 }
2053 return MERROR_OK;
2054}
2055
2056static MERROR_RETVAL retroflat_cli_rfy(
2057 const char* arg, ssize_t arg_c, struct RETROFLAT_ARGS* args
2058) {
2059 if( 0 > arg_c ) {
2060 if( 0 == args->screen_h ) {
2061 args->screen_y = 0;
2062 }
2063 } else if(
2064 0 == strncmp( MAUG_CLI_SIGIL "rfy", arg, MAUG_CLI_SIGIL_SZ + 4 )
2065 ) {
2066 /* The next arg must be the new var. */
2067 } else {
2068 args->screen_y = atoi( arg );
2069 }
2070 return MERROR_OK;
2071}
2072
2073static MERROR_RETVAL retroflat_cli_rfw(
2074 const char* arg, ssize_t arg_c, struct RETROFLAT_ARGS* args
2075) {
2076 if( 0 > arg_c ) {
2077 if( 0 == args->screen_w ) {
2078 args->screen_w = RETROFLAT_DEFAULT_SCREEN_W;
2079 }
2080 } else if(
2081 0 == strncmp( MAUG_CLI_SIGIL "rfw", arg, MAUG_CLI_SIGIL_SZ + 4 )
2082 ) {
2083 /* The next arg must be the new var. */
2084 } else {
2085 args->screen_w = atoi( arg );
2086 }
2087 return MERROR_OK;
2088}
2089
2090static MERROR_RETVAL retroflat_cli_rfh(
2091 const char* arg, ssize_t arg_c, struct RETROFLAT_ARGS* args
2092) {
2093 if( 0 > arg_c ) {
2094 if( 0 == args->screen_h ) {
2095 args->screen_h = RETROFLAT_DEFAULT_SCREEN_H;
2096 }
2097 } else if(
2098 0 == strncmp( MAUG_CLI_SIGIL "rfh", arg, MAUG_CLI_SIGIL_SZ + 4 )
2099 ) {
2100 /* The next arg must be the new var. */
2101 } else {
2102 args->screen_h = atoi( arg );
2103 }
2104 return MERROR_OK;
2105}
2106
2107# endif /* !RETROFLAT_API_PC_BIOS && !RETROFLAT_NO_CLI_SZ */
2108
2109# ifdef RETROFLAT_VDP
2110static MERROR_RETVAL retroflat_cli_vdp(
2111 const char* arg, ssize_t arg_c, struct RETROFLAT_ARGS* args
2112) {
2113 if( 0 == strncmp( MAUG_CLI_SIGIL "vdp", arg, MAUG_CLI_SIGIL_SZ + 4 ) ) {
2114 /* Next arg is VDP args str. */
2115 } else {
2116 maug_strncpy( g_retroflat_state->vdp_args, arg, RETROFLAT_VDP_ARGS_SZ_MAX );
2117 debug_printf( 1, "VDP args: %s", g_retroflat_state->vdp_args );
2118 }
2119 return MERROR_OK;
2120}
2121# endif /* RETROFLAT_VDP */
2122
2123static MERROR_RETVAL retroflat_cli_u(
2124 const char* arg, ssize_t arg_c, struct RETROFLAT_ARGS* args
2125) {
2126 if( 0 > arg_c ) {
2127 args->flags &= ~RETROFLAT_FLAGS_UNLOCK_FPS;
2128 } else if(
2129 0 == strncmp( MAUG_CLI_SIGIL "rfu", arg, MAUG_CLI_SIGIL_SZ + 4 )
2130 ) {
2131 debug_printf( 1, "unlocking FPS..." );
2132 args->flags |= RETROFLAT_FLAGS_UNLOCK_FPS;
2133 }
2134 return MERROR_OK;
2135}
2136
2137#endif /* !RETROFLAT_NO_CLI */
2138
2139/* === */
2140
2141/* Still inside RETROFLT_C! */
2142
2143int retroflat_init( int argc, char* argv[], struct RETROFLAT_ARGS* args ) {
2144
2145 /* = Declare Init Vars = */
2146
2147 int retval = 0;
2148
2149 /* = Begin Init Procedure = */
2150
2151# ifdef RETROFLAT_COMMIT_HASH
2152 debug_printf( 1, "retroflat commit: " RETROFLAT_COMMIT_HASH );
2153# endif /* RETROFLAT_COMMIT_HASH */
2154
2155 debug_printf( 1, "retroflat: initializing..." );
2156
2157 /* System sanity checks. */
2158 assert( 4 == sizeof( uint32_t ) );
2159 assert( 4 == sizeof( int32_t ) );
2160 assert( 2 == sizeof( uint16_t ) );
2161 assert( 2 == sizeof( int16_t ) );
2162 assert( 1 == sizeof( uint8_t ) );
2163 assert( 1 == sizeof( int8_t ) );
2164 assert( NULL != args );
2165 assert( 1 << RETROFLAT_TILE_W_BITS == RETROFLAT_TILE_W );
2166 assert( 1 << RETROFLAT_TILE_H_BITS == RETROFLAT_TILE_H );
2167
2168 debug_printf( 1, "retroflat: allocating state (" SIZE_T_FMT " bytes)...",
2169 sizeof( struct RETROFLAT_STATE ) );
2170
2171 debug_printf( 1, "retroflat: size_t is (" SIZE_T_FMT " bytes)...",
2172 sizeof( size_t ) );
2173
2174 debug_printf( 1, "retroflat: ssize_t is (" SIZE_T_FMT " bytes)...",
2175 sizeof( ssize_t ) );
2176
2177 debug_printf( 1, "retroflat: off_t is (" SIZE_T_FMT " bytes)...",
2178 sizeof( off_t ) );
2179
2180 g_retroflat_state_h = maug_malloc( 1, sizeof( struct RETROFLAT_STATE ) );
2181 if( (MAUG_MHANDLE)NULL == g_retroflat_state_h ) {
2183 "Error", "Could not allocate global state!" );
2184 retval = MERROR_ALLOC;
2185 goto cleanup;
2186 }
2187
2188 maug_mlock( g_retroflat_state_h, g_retroflat_state );
2189 if( (MAUG_MHANDLE)NULL == g_retroflat_state ) {
2191 "Error", "Could not lock global state!" );
2192 retval = MERROR_ALLOC;
2193 goto cleanup;
2194 }
2195 maug_mzero( g_retroflat_state, sizeof( struct RETROFLAT_STATE ) );
2196
2197# ifndef RETROFLAT_NO_CLI
2198
2199 debug_printf( 1, "retroflat: parsing args..." );
2200
2201 /* All platforms: add command-line args based on compile definitons. */
2202
2203# ifdef RETROSND_ARGS
2204 retval = maug_add_arg( MAUG_CLI_SIGIL "rsd", MAUG_CLI_SIGIL_SZ + 4,
2205 "Select MIDI device", 0, (maug_cli_cb)retrosnd_cli_rsd, args );
2206 maug_cleanup_if_not_ok();
2207 retval = maug_add_arg( MAUG_CLI_SIGIL "rsl", MAUG_CLI_SIGIL_SZ + 4,
2208 "List MIDI devices", 0, (maug_cli_cb)retrosnd_cli_rsl, args );
2209 maug_cleanup_if_not_ok();
2210# endif /* RETROSND_ARGS */
2211
2212# ifdef RETROFLAT_SCREENSAVER
2213 retval = maug_add_arg( MAUG_CLI_SIGIL "p", MAUG_CLI_SIGIL_SZ + 2,
2214 "Preview screensaver", 0, (maug_cli_cb)retroflat_cli_p, args );
2215 maug_cleanup_if_not_ok();
2216 retval = maug_add_arg( MAUG_CLI_SIGIL "s", MAUG_CLI_SIGIL_SZ + 2,
2217 "Launch screensaver", 0, (maug_cli_cb)retroflat_cli_s, args );
2218 maug_cleanup_if_not_ok();
2219# endif /* RETROFLAT_SCREENSAVER */
2220
2221# ifdef RETROFLAT_API_PC_BIOS
2222 retval = maug_add_arg( MAUG_CLI_SIGIL "rfm", MAUG_CLI_SIGIL_SZ + 4,
2223 "Set the screen mode.", 0,
2224 (maug_cli_cb)retroflat_cli_rfm, args );
2225 maug_cleanup_if_not_ok();
2226# elif !defined( RETROFLAT_NO_CLI_SZ )
2227 retval = maug_add_arg( MAUG_CLI_SIGIL "rfx", MAUG_CLI_SIGIL_SZ + 4,
2228 "Set the screen X position.", 0,
2229 (maug_cli_cb)retroflat_cli_rfx, args );
2230 maug_cleanup_if_not_ok();
2231 retval = maug_add_arg( MAUG_CLI_SIGIL "rfy", MAUG_CLI_SIGIL_SZ + 4,
2232 "Set the screen Y position.", 0,
2233 (maug_cli_cb)retroflat_cli_rfy, args );
2234 maug_cleanup_if_not_ok();
2235 retval = maug_add_arg( MAUG_CLI_SIGIL "rfw", MAUG_CLI_SIGIL_SZ + 4,
2236 "Set the screen width.", 0,
2237 (maug_cli_cb)retroflat_cli_rfw, args );
2238 maug_cleanup_if_not_ok();
2239 retval = maug_add_arg( MAUG_CLI_SIGIL "rfh", MAUG_CLI_SIGIL_SZ + 4,
2240 "Set the screen height.", 0,
2241 (maug_cli_cb)retroflat_cli_rfh, args );
2242 maug_cleanup_if_not_ok();
2243# endif /* !RETROFLAT_NO_CLI_SZ */
2244
2245# ifdef RETROFLAT_VDP
2246 retval = maug_add_arg( MAUG_CLI_SIGIL "vdp", MAUG_CLI_SIGIL_SZ + 4,
2247 "Pass a string of args to the VDP.", 0,
2248 (maug_cli_cb)retroflat_cli_vdp, args );
2249 maug_cleanup_if_not_ok();
2250# endif /* RETROFLAT_VDP */
2251
2252 retval = maug_add_arg( MAUG_CLI_SIGIL "rfu", MAUG_CLI_SIGIL_SZ + 4,
2253 "Unlock FPS.", 0,
2254 (maug_cli_cb)retroflat_cli_u, args );
2255 maug_cleanup_if_not_ok();
2256
2257 /* Parse command line args. */
2258 retval = maug_parse_args( argc, argv );
2259 maug_cleanup_if_not_ok();
2260
2261# else
2262
2263 args->screen_w = RETROFLAT_DEFAULT_SCREEN_W;
2264 args->screen_h = RETROFLAT_DEFAULT_SCREEN_H;
2265
2266# endif /* !RETROFLAT_NO_CLI */
2267
2268 if(
2270 ) {
2271 g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_UNLOCK_FPS;
2272 }
2273
2274 debug_printf( 1, "retroflat: setting config..." );
2275
2276 /* Set the assets path. */
2277 memset( g_retroflat_state->assets_path, '\0', RETROFLAT_ASSETS_PATH_MAX );
2278 if( NULL != args->assets_path ) {
2279 maug_strncpy( g_retroflat_state->assets_path,
2281 }
2282
2283# if defined( RETROFLAT_SCREENSAVER )
2284 if(
2286 (RETROFLAT_FLAGS_SCREENSAVER & args->flags)
2287 ) {
2288 g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_SCREENSAVER;
2289 }
2290# endif /* RETROFLAT_SCREENSAVER */
2291
2292# if !defined( RETROFLAT_NO_CLI_SZ )
2293 /* Setup intended screen size. */
2294 /* TODO: Handle window resizing someday! */
2295 g_retroflat_state->screen_v_w = args->screen_w;
2296 g_retroflat_state->screen_v_h = args->screen_h;
2297 if(
2299 ) {
2300 debug_printf( 1, "setting window scale to 2x..." );
2301 g_retroflat_state->screen_w = args->screen_w * 2;
2302 g_retroflat_state->screen_h = args->screen_h * 2;
2303 } else {
2304 g_retroflat_state->screen_w = args->screen_w;
2305 g_retroflat_state->screen_h = args->screen_h;
2306 }
2307# endif /* RETROFLAT_NO_CLI_SZ */
2308
2309# ifdef RETROFLAT_OPENGL
2310 debug_printf( 1, "setting up texture palette..." );
2311# define RETROFLAT_COLOR_TABLE_TEX( idx, name_l, name_u, r, g, b, cgac, cgad ) \
2312 g_retroflat_state->tex_palette[idx][0] = r; \
2313 g_retroflat_state->tex_palette[idx][1] = g; \
2314 g_retroflat_state->tex_palette[idx][2] = b;
2315 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_TEX )
2316# endif /* RETROFLAT_OPENGL */
2317
2318 /* == Platform-Specific Init == */
2319
2320 retval = retroflat_init_platform( argc, argv, args );
2321 maug_cleanup_if_not_ok();
2322
2323 /* Setup the refresh grid, if requested, only after screen space has been
2324 * determined by the platform!
2325 */
2326 assert( 0 < retroflat_screen_w() );
2327 assert( 0 < retroflat_screen_h() );
2328 if(
2330 (RETROFLAT_FLAGS_VIEWPORT_REFRESH & args->flags)
2331 ) {
2333
2334 g_retroflat_state->viewport.screen_tile_w =
2335 /* Allocate 1 extra tile on each side for smooth scrolling. */
2336 ((retroflat_screen_w() / RETROFLAT_TILE_W) + 2);
2337 g_retroflat_state->viewport.screen_tile_h =
2338 ((retroflat_screen_h() / RETROFLAT_TILE_H) + 2);
2339
2340 debug_printf( 1, "allocating refresh grid (%d tiles...)",
2341 g_retroflat_state->viewport.screen_tile_w *
2342 g_retroflat_state->viewport.screen_tile_h );
2343 g_retroflat_state->viewport.refresh_grid_h = maug_malloc(
2344 g_retroflat_state->viewport.screen_tile_w *
2345 g_retroflat_state->viewport.screen_tile_h,
2346 sizeof( retroflat_tile_t ) );
2347 maug_cleanup_if_null_alloc( MAUG_MHANDLE,
2348 g_retroflat_state->viewport.refresh_grid_h );
2349 }
2350
2351# if defined( RETROFLAT_SOFT_SHAPES ) || defined( RETROFLAT_SOFT_LINES )
2352 retval = retrosoft_init();
2353 maug_cleanup_if_not_ok();
2354# endif /* RETROFLAT_SOFT_SHAPES || RETROFLAT_SOFT_LINES */
2355
2356# if defined( RETROFLAT_OPENGL )
2357 retval = retrosoft_init();
2358 maug_cleanup_if_not_ok();
2359# ifndef RETROFLAT_NO_STRING
2360 retval = retroglu_init_glyph_tex();
2361 maug_cleanup_if_not_ok();
2362# endif /* !RETROFLAT_NO_STRING */
2363# endif /* RETROFLAT_OPENGL */
2364
2365# ifdef RETROFLAT_VDP
2366# if defined( RETROFLAT_OS_UNIX )
2367 g_retroflat_state->vdp_exe = dlopen(
2368 "./" RETROFLAT_VDP_LIB_NAME ".so", RTLD_LAZY );
2369# elif defined( RETROFLAT_OS_WIN )
2370 g_retroflat_state->vdp_exe = LoadLibrary(
2371 "./" RETROFLAT_VDP_LIB_NAME ".dll" );
2372# else
2373# error "dlopen undefined!"
2374# endif /* RETROFLAT_OS_UNIX */
2375
2376 if( !(g_retroflat_state->vdp_exe) ) {
2377 error_printf( "not loading VDP" );
2378 /* Skip creating the buffer or trying to run the init proc. */
2379 goto skip_vdp;
2380 }
2381
2382 /* Create intermediary screen buffer. */
2383 debug_printf( 1, "creating VDP buffer, " SIZE_T_FMT " x " SIZE_T_FMT,
2384 g_retroflat_state->screen_v_w, g_retroflat_state->screen_v_h );
2385 g_retroflat_state->vdp_buffer =
2386 calloc( 1, sizeof( struct RETROFLAT_BITMAP ) );
2387 maug_cleanup_if_null_alloc(
2388 struct RETROFLAT_BITMAP*, g_retroflat_state->vdp_buffer );
2389 retval = retroflat_create_bitmap(
2390 g_retroflat_state->screen_v_w, g_retroflat_state->screen_v_h,
2391 g_retroflat_state->vdp_buffer, RETROFLAT_FLAGS_OPAQUE );
2392 maug_cleanup_if_not_ok();
2393
2394 debug_printf( 1, "initializing VDP..." );
2395 retval = retroflat_vdp_call( "retroflat_vdp_init" );
2396
2397skip_vdp:
2398
2399# endif /* RETROFLAT_VDP */
2400
2401# if !defined( RETROFLAT_NO_BLANK_INIT ) && !defined( RETROFLAT_OPENGL )
2402 retroflat_draw_lock( NULL );
2404 NULL, RETROFLAT_COLOR_BLACK, 0, 0,
2407 retroflat_draw_release( NULL );
2408# endif /* !RETROFLAT_NO_BLANK_INIT */
2409
2410cleanup:
2411
2412 return retval;
2413}
2414
2415/* === */
2416
2417void retroflat_shutdown( int retval ) {
2418
2419 debug_printf( 1, "retroflat shutdown called..." );
2420
2421 if( (MAUG_MHANDLE)NULL != g_retroflat_state->viewport.refresh_grid_h ) {
2422 maug_mfree( g_retroflat_state->viewport.refresh_grid_h );
2423 }
2424
2425# if defined( RETROFLAT_VDP )
2426 if( NULL != g_retroflat_state->vdp_exe ) {
2427 retroflat_vdp_call( "retroflat_vdp_shutdown" );
2428# ifdef RETROFLAT_OS_UNIX
2429 dlclose( g_retroflat_state->vdp_exe );
2430# elif defined( RETROFLAT_OS_WIN )
2431 FreeLibrary( g_retroflat_state->vdp_exe );
2432# else
2433# error "dlclose undefined!"
2434# endif /* RETROFLAT_OS_UNIX || RETROFLAT_OS_WIN */
2435 }
2436
2437 if( NULL != g_retroflat_state->vdp_buffer ) {
2438 debug_printf( 1, "destroying VPD buffer..." );
2439 retroflat_destroy_bitmap( g_retroflat_state->vdp_buffer );
2440 free( g_retroflat_state->vdp_buffer );
2441 }
2442# endif /* RETROFLAT_VDP */
2443
2444# if defined( RETROFLAT_SOFT_SHAPES ) || defined( RETROFLAT_SOFT_LINES ) || \
2445defined( RETROFLAT_OPENGL )
2446 debug_printf( 1, "calling retrosoft shutdown..." );
2447 retrosoft_shutdown();
2448# endif /* RETROFLAT_SOFT_SHAPES */
2449
2450# if defined( RETROFLAT_OPENGL ) && !defined( RETROFLAT_NO_STRING )
2451 debug_printf( 1, "destroying GL glyphs..." );
2452 retroglu_destroy_glyph_tex();
2453# endif /* RETROFLAT_OPENGL */
2454
2455 /* === Platform-Specific Shutdown === */
2456
2457 retroflat_shutdown_platform( retval );
2458
2459 maug_munlock( g_retroflat_state_h, g_retroflat_state );
2460 maug_mfree( g_retroflat_state );
2461
2462}
2463
2464/* === */
2465
2466# ifdef RETROFLAT_VDP
2467
2468MERROR_RETVAL retroflat_vdp_call( const char* proc_name ) {
2469 MERROR_RETVAL retval = MERROR_OK;
2471# ifdef RETROFLAT_OS_WIN
2472 char proc_name_ex[256];
2473# endif /* RETROFLAT_OS_WIN */
2474
2475 if( NULL == g_retroflat_state->vdp_exe ) {
2476 goto cleanup;
2477 }
2478
2479# ifdef RETROFLAT_OS_UNIX
2480 vdp_proc = dlsym( g_retroflat_state->vdp_exe, proc_name );
2481# elif defined( RETROFLAT_OS_WIN )
2482 /* Append a _ to the proc_name because Watcom? Windows? */
2483 maug_snprintf( proc_name_ex, 255, "%s_", proc_name );
2484 vdp_proc = (retroflat_vdp_proc_t)GetProcAddress(
2485 g_retroflat_state->vdp_exe, proc_name_ex );
2486# else
2487# error "dlsym undefined!"
2488# endif
2489 if( (retroflat_vdp_proc_t)NULL == vdp_proc ) {
2490 goto cleanup;
2491 }
2492
2493# ifdef RETROFLAT_OS_WIN
2494 retroflat_draw_lock( g_retroflat_state->vdp_buffer );
2495# endif /* RETROFLAT_OS_WIN */
2496
2497 if(
2498 /* Don't pxlock before init can set the flag! */
2499 0 == strcmp( "retroflat_vdp_flip", proc_name ) &&
2501 (RETROFLAT_VDP_FLAG_PXLOCK & g_retroflat_state->vdp_flags)
2502 ) {
2503 retroflat_vdp_lock( &(g_retroflat_state->buffer) );
2504 retroflat_vdp_lock( g_retroflat_state->vdp_buffer );
2505 }
2506
2507 retval = vdp_proc( g_retroflat_state );
2508
2509 if(
2510 0 == strcmp( "retroflat_vdp_flip", proc_name ) &&
2512 (RETROFLAT_VDP_FLAG_PXLOCK & g_retroflat_state->vdp_flags)
2513 ) {
2514 retroflat_vdp_release( &(g_retroflat_state->buffer) );
2515 retroflat_vdp_release( g_retroflat_state->vdp_buffer );
2516 }
2517
2518# ifdef RETROFLAT_OS_WIN
2519 retroflat_draw_release( g_retroflat_state->vdp_buffer );
2520# endif /* RETROFLAT_OS_WIN */
2521
2522cleanup:
2523 return retval;
2524}
2525
2526# endif /* RETROFLAT_VDP */
2527
2528/* === */
2529
2530#if 0
2531
2532void retroflat_cursor( struct RETROFLAT_BITMAP* target, uint8_t flags ) {
2533#if 0
2534 char mouse_str[11] = "";
2535
2536 maug_snprintf(
2537 mouse_str, 10, "%02d, %02d", g_retroflat_state->last_mouse_x, g_retroflat_state->last_mouse_y );
2538
2540 target, RETROFLAT_COLOR_BLACK,
2541 mouse_str, 10, NULL, 0, 0, 0 );
2543 target, RETROFLAT_COLOR_BLACK,
2544 g_retroflat_state->last_mouse_x - 5, g_retroflat_state->last_mouse_y - 5, 10, 10, 0 );
2545#endif
2546}
2547
2548#endif
2549
2550/* === */
2551
2552#ifndef RETROFLAT_NO_STRING
2553
2554# if defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
2555
2556# define retroflat_win_create_font( flags, font_str ) \
2557 CreateFont( 10, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, \
2558 DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, \
2559 DEFAULT_QUALITY, DEFAULT_PITCH, \
2560 (NULL == font_str || '\0' == font_str[0] ? "Arial" : font_str) );
2561
2562# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
2563
2565 struct RETROFLAT_BITMAP* target, const char* str, size_t str_sz,
2566 const char* font_str, size_t* w_out, size_t* h_out, uint8_t flags
2567) {
2568# if defined( RETROFLAT_OPENGL )
2569# elif defined( RETROFLAT_SOFT_SHAPES )
2570# elif defined( RETROFLAT_API_ALLEGRO )
2571 FONT* font_data = NULL;
2572 int font_loaded = 0;
2573# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
2574 SIZE sz;
2575 HFONT font;
2576 HFONT old_font;
2577# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
2578
2579 if( NULL == target ) {
2580 target = retroflat_screen_buffer();
2581 }
2582
2583# if defined( RETROFLAT_OPENGL )
2584
2585 retrosoft_string_sz( target, str, str_sz, font_str, w_out, h_out, flags );
2586
2587# elif defined( RETROFLAT_SOFT_SHAPES )
2588
2589 retrosoft_string_sz( target, str, str_sz, font_str, w_out, h_out, flags );
2590
2591# elif defined( RETROFLAT_API_ALLEGRO )
2592
2593 /* == Allegro == */
2594
2595 if( NULL == font_str || '\0' == font_str[0] ) {
2596 font_data = font;
2597 } else {
2598 /* TODO: Cache loaded fonts for later use. */
2599 font_data = load_font( font_str, NULL, NULL );
2600 }
2601 if( NULL == font_data ) {
2603 "Error", "Unable to load font: %s", font_str );
2604 goto cleanup;
2605 }
2606
2607 *w_out = text_length( font_data, str );
2608 *h_out = text_height( font_data );
2609
2610cleanup:
2611
2612 if( font_loaded && NULL != font_data ) {
2613 destroy_font( font_data );
2614 }
2615
2616# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
2617
2618 /* == Win16/Win32 == */
2619
2620 assert( (HBITMAP)NULL != target->b );
2621 assert( retroflat_bitmap_locked( target ) );
2622
2623 font = retroflat_win_create_font( flags, font_str );
2624 old_font = SelectObject( target->hdc_b, font );
2625
2626 GetTextExtentPoint( target->hdc_b, str, str_sz, &sz );
2627 *w_out = sz.cx;
2628 *h_out = sz.cy;
2629
2630/* cleanup: */
2631
2632 SelectObject( target->hdc_b, old_font );
2633
2634# else
2635# pragma message( "warning: string sz not implemented" )
2636# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
2637}
2638
2639/* === */
2640
2641void retroflat_string(
2642 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
2643 const char* str, int str_sz, const char* font_str, int16_t x_orig, int16_t y_orig,
2644 uint8_t flags
2645) {
2646# if defined( RETROFLAT_OPENGL )
2647 float aspect_ratio = 0,
2648 screen_x = 0,
2649 screen_y = 0;
2650# elif defined( RETROFLAT_SOFT_SHAPES )
2651# elif defined( RETROFLAT_API_ALLEGRO )
2652 FONT* font_data = NULL;
2653 int font_loaded = 0;
2654# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
2655 RECT rect;
2656 SIZE sz;
2657 HFONT font;
2658 HFONT old_font;
2659# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
2660
2661 if( RETROFLAT_COLOR_NULL == color ) {
2662 return;
2663 }
2664
2665# if !defined( RETROFLAT_OPENGL )
2666 if( NULL == target ) {
2667 target = retroflat_screen_buffer();
2668 }
2669# endif /* !RETROFLAT_OPENGL */
2670
2671 if( 0 == str_sz ) {
2672 str_sz = maug_strlen( str );
2673 }
2674
2675# if defined( RETROFLAT_OPENGL )
2676
2677 if( NULL == target || retroflat_screen_buffer() == target ) {
2678 /* Push new overlay projection parms before we create a new overlay. */
2679 retroglu_push_overlay( x_orig, y_orig, screen_x, screen_y, aspect_ratio );
2680
2681 retroglu_string(
2682 screen_x, screen_y, 0,
2683 g_retroflat_state->palette[color], str, str_sz, font_str, flags );
2684
2686 } else {
2687 /* Assume drawing surface is already configured inside a push_overlay()
2688 * call and draw to its texture. */
2689 retrosoft_string(
2690 target, color, str, str_sz, font_str, x_orig, y_orig, flags );
2691 }
2692
2693# elif defined( RETROFLAT_SOFT_SHAPES )
2694
2695 retrosoft_string(
2696 target, color, str, str_sz, font_str, x_orig, y_orig, flags );
2697
2698# elif defined( RETROFLAT_API_ALLEGRO )
2699
2700 /* == Allegro == */
2701
2702 if( NULL == font_str || '\0' == font_str[0] ) {
2703 font_data = font;
2704 } else {
2705 /* TODO: Cache loaded fonts for later use. */
2706 font_data = load_font( font_str, NULL, NULL );
2707 }
2708 if( NULL == font_data ) {
2710 "Error", "Unable to load font: %s", font_str );
2711 goto cleanup;
2712 }
2713
2714 textout_ex( target->b, font_data, str, x_orig, y_orig, color, -1 );
2715
2716cleanup:
2717 if( font_loaded && NULL != font_data ) {
2718 destroy_font( font_data );
2719 }
2720
2721# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
2722
2723 /* == Win16/Win32 == */
2724
2725 assert( (HBITMAP)NULL != target->b );
2726
2727 assert( retroflat_bitmap_locked( target ) );
2728
2729 /* DrawText will draw gibberish even if the string is null-terminated! */
2730 str_sz = maug_strlen( str );
2731
2732 memset( &sz, '\0', sizeof( SIZE ) );
2733
2734 font = retroflat_win_create_font( flags, font_str );
2735 old_font = SelectObject( target->hdc_b, font );
2736
2737 GetTextExtentPoint( target->hdc_b, str, str_sz, &sz );
2738 rect.left = x_orig;
2739 rect.top = y_orig;
2740 rect.right = (x_orig + sz.cx);
2741 rect.bottom = (y_orig + sz.cy);
2742
2743 SetTextColor( target->hdc_b, g_retroflat_state->palette[color] );
2744 SetBkMode( target->hdc_b, TRANSPARENT );
2745
2746 DrawText( target->hdc_b, str, str_sz, &rect, 0 );
2747
2748/* cleanup: */
2749
2750 SelectObject( target->hdc_b, old_font );
2751
2752 SetBkMode( target->hdc_b, OPAQUE );
2753 SetTextColor( target->hdc_b,
2754 g_retroflat_state->palette[RETROFLAT_COLOR_BLACK] );
2755
2756# else
2757# pragma message( "warning: string not implemented" )
2758# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
2759}
2760
2761#endif /* !RETROFLAT_NO_STRING */
2762
2763/* === */
2764
2766 retroflat_proc_resize_t on_resize_in, void* data_in
2767) {
2768 g_retroflat_state->on_resize = on_resize_in;
2769 g_retroflat_state->on_resize_data = data_in;
2770}
2771
2772/* === */
2773
2774uint8_t retroflat_viewport_move_x_generic( int16_t x ) {
2775 int16_t new_world_x = g_retroflat_state->viewport.world_x + x;
2776
2777 g_retroflat_state->viewport.screen_x += x;
2778
2779 /* Keep the viewport in the world arena. */
2780 if(
2781 0 < new_world_x &&
2782 g_retroflat_state->viewport.world_w > new_world_x + retroflat_screen_w()
2783 ) {
2784 g_retroflat_state->viewport.world_x += x;
2785 return 1;
2786 }
2787
2788 return 0;
2789}
2790
2791/* === */
2792
2793uint8_t retroflat_viewport_move_y_generic( int16_t y ) {
2794 int16_t new_world_y = g_retroflat_state->viewport.world_y + y;
2795
2796 g_retroflat_state->viewport.screen_y += y;
2797
2798 /* Keep the viewport in the world arena. */
2799 if(
2800 0 < new_world_y &&
2801 g_retroflat_state->viewport.world_h > new_world_y + retroflat_screen_h()
2802 ) {
2803 g_retroflat_state->viewport.world_y += y;
2804 return 1;
2805 }
2806
2807 return 0;
2808}
2809
2810/* === */
2811
2812uint8_t retroflat_viewport_focus_generic(
2813 size_t x1, size_t y1, size_t range, size_t speed
2814) {
2815 uint8_t moved = 0,
2816 new_moved = 0;
2817 int16_t new_pt = 0;
2818
2819# define _retroflat_viewport_focus_dir( n, xy, wh, gl, pm, dir, range, speed ) \
2820 new_pt = n - retroflat_viewport_world_ ## xy(); \
2821 if( new_pt gl (retroflat_screen_ ## wh() >> 1) pm range ) { \
2822 new_moved = retroflat_viewport_move_ ## xy( \
2823 gc_retroflat_offsets8_ ## xy[RETROFLAT_DIR8_ ## dir] * speed ); \
2824 if( !moved && new_moved ) { \
2825 moved = new_moved; \
2826 } \
2827 }
2828
2829 _retroflat_viewport_focus_dir( x1, x, w, <, -, WEST, range, speed );
2830 _retroflat_viewport_focus_dir( x1, x, w, >, +, EAST, range, speed );
2831 _retroflat_viewport_focus_dir( y1, y, h, <, -, NORTH, range, speed );
2832 _retroflat_viewport_focus_dir( y1, y, h, >, +, SOUTH, range, speed );
2833
2834 return moved;
2835}
2836
2837/* === */
2838
2839#elif !defined( RETROVDP_C ) /* End of RETROFLT_C */
2840
2846extern MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets8_x[8];
2847extern MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets8_y[8];
2848extern MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets4_x[4];
2849extern MAUG_CONST int16_t SEG_MCONST gc_retroflat_offsets4_y[4];
2850
2853#define RETROFLAT_COLOR_TABLE_CONSTS( idx, name_l, name_u, r, g, b, cgac, cgad ) \
2854 extern MAUG_CONST RETROFLAT_COLOR RETROFLAT_COLOR_ ## name_u;
2855
2856RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_CONSTS )
2857
2858extern MAUG_CONST char* SEG_MCONST gc_retroflat_color_names[];
2859
2860 extern struct RETROFLAT_STATE* g_retroflat_state;
2861# if defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
2862 extern HINSTANCE g_retroflat_instance;
2863 extern int g_retroflat_cmd_show;
2864# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
2865
2866# include <uprintf.h>
2867
2868# if (defined( RETROFLAT_SOFT_SHAPES ) || defined( RETROFLAT_SOFT_LINES)) \
2869 && !defined( MAUG_NO_AUTO_C )
2870# include <retrofp.h>
2871# include <retrosft.h>
2872# endif /* RETROFLAT_SOFT_SHAPES || RETROFLAT_SOFT_LINES */
2873
2874# if defined( RETROFLAT_OPENGL ) && !defined( MAUG_NO_AUTO_C )
2875# include <retroglu.h>
2876# include <retrofp.h>
2877# include <retrosft.h>
2878# endif /* RETROFLAT_OPENGL */
2879
2880#endif /* RETROFLT_C */
2881
2882#ifdef RETROFLAT_XPM
2883#include <retroxpm.h>
2884#endif /* RETROFLAT_XPM */
2885
2886#ifdef RETROVDP_C
2887
2888/* Declarations for VDP sources. */
2889
2890#endif /* RETROVDP_C */
2891
2892 /* maug_retroflt */
2893
2894#endif /* RETROFLT_H */
2895
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
int MERROR_RETVAL
Return type indicating function returns a value from this list.
Definition merror.h:19
#define maug_mzero(ptr, sz)
Zero the block of memory pointed to by ptr.
Definition mmem.h:62
char retroflat_asset_path[RETROFLAT_PATH_MAX]
Path/name used to load an asset from disk.
Definition retroflt.h:774
#define RETROFLAT_BITMAP_EXT
The filename suffix to be appended with a "." to filenames passed to retroflat_load_bitmap()....
Definition retroflt.h:577
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.
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 th...
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 th...
int8_t RETROFLAT_COLOR
Defines an index in the platform-specific color-table.
Definition retroflt.h:307
#define RETROFLAT_COLOR_TABLE(f)
This macro defines all colors supported by RetroFlat for primative operations, particularly using ret...
Definition retroflt.h:288
#define RETROFLAT_VDP_ARGS_SZ_MAX
Definition retroflt.h:724
#define RETROFLAT_ASSETS_PATH_MAX
Maximum size of the assets path, to allow room for appending.
Definition retroflt.h:749
#define RETROFLAT_PATH_SEP
The valid path separator on the target platform.
Definition retroflt.h:745
#define RETROFLAT_FLAGS_LITERAL_PATH
Flag for retroflat_load_bitmap() to not use assets path.
Definition retroflt.h:374
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.
#define RETROFLAT_FLAGS_OPAQUE
Flag for retroflat_create_bitmap() to create a bitmap without transparency.
Definition retroflt.h:361
#define RETROFLAT_FLAGS_VIEWPORT_REFRESH
Flag for args->flags, indicating that a viewport tile refresh grid should be allocated and used.
Definition retroflt.h:398
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_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_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.
#define RETROFLAT_FLAGS_FILL
Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
Definition retroflt.h:355
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_...
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.
#define RETROFLAT_FLAGS_SCREENSAVER
Flag indicating the current application is running as a screensaver.
Definition retroflt.h:431
#define RETROFLAT_FLAGS_UNLOCK_FPS
Flag indicating FPS should not be capped.
Definition retroflt.h:419
#define RETROFLAT_FLAGS_SCALE2X
Only supported on some platforms: Attempt to scale screen by 2X.
Definition retroflt.h:436
#define RETROFLAT_FLAGS_RUNNING
Flag indicating that retroflat_loop() should continue executing.
Definition retroflt.h:413
#define RETROFLAT_FLAGS_WAIT_FOR_FPS
Do not execute any more inter-frame loops until next frame.
Definition retroflt.h:441
RETROFLAT_IN_KEY retroflat_poll_input(struct RETROFLAT_INPUT *input)
Poll input devices (keyboard/mouse) and return the latest event.
#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:459
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:511
#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:498
void retroflat_shutdown(int retval)
Deinitialize RetroFlat and its underlying layers. This should be called once at the end of the progra...
void(* retroflat_loop_iter)(void *data)
Prototype for the main loop function passed to retroflat_loop().
Definition retroflt.h:786
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....
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 pr...
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).
#define retroglu_push_overlay(x, y, x_f, y_f, aspect_f)
Push current projection modelview and prepare useful parameters for drawing a textured overlay.
Definition retroglu.h:241
#define retroglu_pop_overlay()
Restore projection modelview previously pushed using retroglu_push().
Definition retroglu.h:274
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.
#define retroflat_screen_h()
Get the current screen height in pixels.
Definition retpltd.h:38
#define retroflat_screen_buffer()
Get the direct screen buffer or the VDP buffer if a VDP is loaded.
Definition retpltd.h:41
#define retroflat_screen_w()
Get the current screen width in pixels.
Definition retpltd.h:35
Contains functions and macros for working with fixed-point numbers.
Library of tools for working with RetroFlat and OpenGL.
Struct containing configuration values for a RetroFlat program.
Definition retroflt.h:1012
char * config_path
Relative path of local config file (if not using registry).
Definition retroflt.h:1022
char * assets_path
Relative path under which bitmap assets are stored.
Definition retroflt.h:1019
int screen_h
Desired screen or window height in pixels.
Definition retroflt.h:1029
char * title
Title to set for the main program Window if applicable on the target platform.
Definition retroflt.h:1017
int screen_y
Desired window Y position in pixels.
Definition retroflt.h:1033
int screen_x
Desired window X position in pixels.
Definition retroflt.h:1031
Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine...
Definition retpltd.h:21
Struct passed to retroflat_poll_input() to hold return data.
Definition retroflt.h:836
int mouse_y
Y-coordinate of the mouse pointer in pixels if the returned event is a mouse click.
Definition retroflt.h:846
int mouse_x
X-coordinate of the mouse pointer in pixels if the returned event is a mouse click.
Definition retroflt.h:841
Global singleton containing state for the current platform.
Definition retroflt.h:1261
char vdp_args[RETROFLAT_VDP_ARGS_SZ_MAX]
CLI args passed with -vdp to the RetroFlat VDP API.
Definition retroflt.h:1293
size_t screen_h
The screen height as seen by the system, after scaling.
Definition retroflt.h:1319
uint8_t vdp_flags
Flags set by the RetroFlat VDP API.
Definition retroflt.h:1295
size_t screen_v_w
The screen width as seen by our program, before scaling.
Definition retroflt.h:1308
uint8_t retroflat_flags
Global Flags indicating current system status.
Definition retroflt.h:1265
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:1280
size_t screen_w
The screen width as seen by the system, after scaling.
Definition retroflt.h:1317
struct RETROFLAT_BITMAP buffer
Off-screen buffer bitmap.
Definition retroflt.h:1272
void * vdp_exe
A handle for the loaded RetroFlat VDP API module.
Definition retroflt.h:1285
RETROFLAT_COLOR_DEF palette[RETROFLAT_COLORS_SZ]
Index of available colors, initialized on platform init.
Definition retroflt.h:1270
void * vdp_data
Pointer to data defined by the RetroFlat VDP API for its use.
Definition retroflt.h:1291
size_t screen_v_h
The screen height as seen by our program, before scaling.
Definition retroflt.h:1315
Definition retroflt.h:1059
int16_t screen_x
X position of the viewport in real screen memory in pixels.
Definition retroflt.h:1061
int16_t screen_y
Y position of the viewport in real screen memory in pixels.
Definition retroflt.h:1063