Mercurial > repos > blastem
comparison util.c @ 1842:49f65d240299 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 14 Apr 2019 23:38:02 -0700 |
parents | 243f3a7247f9 |
children | 30f2821ffd65 |
comparison
equal
deleted
inserted
replaced
1787:0c6d07f91346 | 1842:49f65d240299 |
---|---|
475 } | 475 } |
476 #endif | 476 #endif |
477 va_end(args); | 477 va_end(args); |
478 } | 478 } |
479 | 479 |
480 static uint8_t output_enabled = 1; | |
480 void info_message(char *format, ...) | 481 void info_message(char *format, ...) |
481 { | 482 { |
482 va_list args; | 483 va_list args; |
483 va_start(args, format); | 484 va_start(args, format); |
484 #ifndef _WIN32 | 485 #ifndef _WIN32 |
485 if (headless || (isatty(STDOUT_FILENO) && isatty(STDIN_FILENO))) { | 486 if (headless || (isatty(STDOUT_FILENO) && isatty(STDIN_FILENO))) { |
486 info_printf(format, args); | 487 if (output_enabled) { |
488 info_printf(format, args); | |
489 } | |
487 } else { | 490 } else { |
488 #endif | 491 #endif |
489 int32_t size = strlen(format) * 2; | 492 int32_t size = strlen(format) * 2; |
490 char *buf = malloc(size); | 493 char *buf = malloc(size); |
491 int32_t actual = vsnprintf(buf, size, format, args); | 494 int32_t actual = vsnprintf(buf, size, format, args); |
501 buf = malloc(actual); | 504 buf = malloc(actual); |
502 va_end(args); | 505 va_end(args); |
503 va_start(args, format); | 506 va_start(args, format); |
504 vsnprintf(buf, actual, format, args); | 507 vsnprintf(buf, actual, format, args); |
505 } | 508 } |
506 info_puts(buf); | 509 if (output_enabled) { |
510 info_puts(buf); | |
511 } | |
507 render_infobox("BlastEm Info", buf); | 512 render_infobox("BlastEm Info", buf); |
508 free(buf); | 513 free(buf); |
509 #ifndef _WIN32 | 514 #ifndef _WIN32 |
510 } | 515 } |
511 #endif | 516 #endif |
512 va_end(args); | 517 va_end(args); |
518 } | |
519 | |
520 void debug_message(char *format, ...) | |
521 { | |
522 va_list args; | |
523 va_start(args, format); | |
524 if (output_enabled) { | |
525 info_printf(format, args); | |
526 } | |
527 } | |
528 | |
529 void disable_stdout_messages(void) | |
530 { | |
531 output_enabled = 0; | |
513 } | 532 } |
514 | 533 |
515 #ifdef _WIN32 | 534 #ifdef _WIN32 |
516 #include <windows.h> | 535 #include <windows.h> |
517 #include <shlobj.h> | 536 #include <shlobj.h> |
836 } | 855 } |
837 | 856 |
838 #ifdef __ANDROID__ | 857 #ifdef __ANDROID__ |
839 | 858 |
840 #include <SDL.h> | 859 #include <SDL.h> |
860 #ifndef IS_LIB | |
841 char *read_bundled_file(char *name, uint32_t *sizeret) | 861 char *read_bundled_file(char *name, uint32_t *sizeret) |
842 { | 862 { |
843 SDL_RWops *rw = SDL_RWFromFile(name, "rb"); | 863 SDL_RWops *rw = SDL_RWFromFile(name, "rb"); |
844 if (!rw) { | 864 if (!rw) { |
845 if (sizeret) { | 865 if (sizeret) { |
863 ret = NULL; | 883 ret = NULL; |
864 } | 884 } |
865 SDL_RWclose(rw); | 885 SDL_RWclose(rw); |
866 return ret; | 886 return ret; |
867 } | 887 } |
888 #endif | |
868 | 889 |
869 char const *get_config_dir() | 890 char const *get_config_dir() |
870 { | 891 { |
871 return SDL_AndroidGetInternalStoragePath(); | 892 return SDL_AndroidGetInternalStoragePath(); |
872 } | 893 } |
876 return SDL_AndroidGetInternalStoragePath(); | 897 return SDL_AndroidGetInternalStoragePath(); |
877 } | 898 } |
878 | 899 |
879 #else | 900 #else |
880 | 901 |
902 #ifndef IS_LIB | |
881 char *read_bundled_file(char *name, uint32_t *sizeret) | 903 char *read_bundled_file(char *name, uint32_t *sizeret) |
882 { | 904 { |
883 #ifdef DATA_PATH | 905 #ifdef DATA_PATH |
884 char *data_dir = DATA_PATH; | 906 char *data_dir = DATA_PATH; |
885 #else | 907 #else |
919 ret = NULL; | 941 ret = NULL; |
920 } | 942 } |
921 fclose(f); | 943 fclose(f); |
922 return ret; | 944 return ret; |
923 } | 945 } |
924 | 946 #endif |
925 | 947 |
926 #ifdef _WIN32 | 948 #ifdef _WIN32 |
927 char const *get_userdata_dir() | 949 char const *get_userdata_dir() |
928 { | 950 { |
929 static char path[MAX_PATH]; | 951 static char path[MAX_PATH]; |