Mercurial > repos > blastem
comparison libblastem.c @ 2546:6aa3025bbf5f
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 02 Jan 2025 23:03:50 -0800 |
parents | c076a96f1668 |
children | e3575bb1273a |
comparison
equal
deleted
inserted
replaced
2544:99e59fdddbc3 | 2546:6aa3025bbf5f |
---|---|
6 #include "vdp.h" | 6 #include "vdp.h" |
7 #include "render.h" | 7 #include "render.h" |
8 #include "io.h" | 8 #include "io.h" |
9 #include "genesis.h" | 9 #include "genesis.h" |
10 #include "sms.h" | 10 #include "sms.h" |
11 | 11 #include "cdimage.h" |
12 | |
13 tern_node *config; | |
12 static retro_environment_t retro_environment; | 14 static retro_environment_t retro_environment; |
13 RETRO_API void retro_set_environment(retro_environment_t re) | 15 RETRO_API void retro_set_environment(retro_environment_t re) |
14 { | 16 { |
15 retro_environment = re; | 17 retro_environment = re; |
16 # define input_descriptor_macro(pad_num) \ | 18 # define input_descriptor_macro(pad_num) \ |
34 input_descriptor_macro(3) | 36 input_descriptor_macro(3) |
35 input_descriptor_macro(4) | 37 input_descriptor_macro(4) |
36 input_descriptor_macro(5) | 38 input_descriptor_macro(5) |
37 input_descriptor_macro(6) | 39 input_descriptor_macro(6) |
38 input_descriptor_macro(7) | 40 input_descriptor_macro(7) |
39 { 0 }, | 41 {0}, |
40 }; | 42 }; |
41 | 43 |
42 re(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, (void *)desc); | 44 re(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, (void *)desc); |
45 | |
46 static const struct retro_system_content_info_override scio[] = { | |
47 { | |
48 .extensions = "md|gen|sms|gg|sg|sc|col|vgm|flac|wav|bin|rom", | |
49 .need_fullpath = 0, | |
50 .persistent_data = 0 | |
51 }, | |
52 {0} | |
53 }; | |
54 re(RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE, (void *)scio); | |
55 | |
56 const char *system_dir = NULL; | |
57 re(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_dir); | |
58 if (system_dir) { | |
59 config = tern_insert_path(config, "system\0scd_bios_us\0", (tern_val){.ptrval = alloc_concat(system_dir, "/bios_CD_U.bin")}, TVAL_PTR); | |
60 config = tern_insert_path(config, "system\0scd_bios_eu\0", (tern_val){.ptrval = alloc_concat(system_dir, "/bios_CD_E.bin")}, TVAL_PTR); | |
61 config = tern_insert_path(config, "system\0scd_bios_jp\0", (tern_val){.ptrval = alloc_concat(system_dir, "/bios_CD_J.bin")}, TVAL_PTR); | |
62 } | |
43 } | 63 } |
44 | 64 |
45 static retro_video_refresh_t retro_video_refresh; | 65 static retro_video_refresh_t retro_video_refresh; |
46 RETRO_API void retro_set_video_refresh(retro_video_refresh_t rvf) | 66 RETRO_API void retro_set_video_refresh(retro_video_refresh_t rvf) |
47 { | 67 { |
72 | 92 |
73 int headless = 0; | 93 int headless = 0; |
74 int exit_after = 0; | 94 int exit_after = 0; |
75 int z80_enabled = 1; | 95 int z80_enabled = 1; |
76 char *save_filename; | 96 char *save_filename; |
77 tern_node *config; | |
78 uint8_t use_native_states = 1; | 97 uint8_t use_native_states = 1; |
79 system_header *current_system; | 98 system_header *current_system; |
80 static system_media media; | 99 static system_media media; |
81 const system_media *current_media(void) | 100 const system_media *current_media(void) |
82 { | 101 { |
98 RETRO_API unsigned retro_api_version(void) | 117 RETRO_API unsigned retro_api_version(void) |
99 { | 118 { |
100 return RETRO_API_VERSION; | 119 return RETRO_API_VERSION; |
101 } | 120 } |
102 | 121 |
122 #include "version.inc" | |
123 | |
103 RETRO_API void retro_get_system_info(struct retro_system_info *info) | 124 RETRO_API void retro_get_system_info(struct retro_system_info *info) |
104 { | 125 { |
105 info->library_name = "BlastEm"; | 126 info->library_name = "BlastEm"; |
106 info->library_version = "0.6.3-pre"; //TODO: share this with blastem.c | 127 info->library_version = BLASTEM_VERSION; |
107 info->valid_extensions = "md|gen|sms|gg|bin|rom"; | 128 info->valid_extensions = "md|gen|sms|gg|sg|sc|col|cue|toc|iso|vgm|flac|wav|bin|rom"; |
108 info->need_fullpath = 0; | 129 info->need_fullpath = 1; |
109 info->block_extract = 0; | 130 info->block_extract = 0; |
110 } | 131 } |
111 | 132 |
112 static vid_std video_standard; | 133 static vid_std video_standard; |
113 static uint32_t last_width, last_height; | 134 static uint32_t last_width, last_height; |
237 /* Loads a game. */ | 258 /* Loads a game. */ |
238 static system_type stype; | 259 static system_type stype; |
239 RETRO_API bool retro_load_game(const struct retro_game_info *game) | 260 RETRO_API bool retro_load_game(const struct retro_game_info *game) |
240 { | 261 { |
241 serialize_size_cache = 0; | 262 serialize_size_cache = 0; |
242 if (game->path) { | 263 stype = SYSTEM_UNKNOWN; |
243 media.dir = path_dirname(game->path); | 264 if (game->data) { |
244 media.name = basename_no_extension(game->path); | 265 if (game->path) { |
245 media.extension = path_extension(game->path); | 266 media.dir = path_dirname(game->path); |
246 } | 267 media.name = basename_no_extension(game->path); |
247 media.buffer = malloc(nearest_pow2(game->size)); | 268 media.extension = path_extension(game->path); |
248 memcpy(media.buffer, game->data, game->size); | 269 } |
249 media.size = game->size; | 270 media.buffer = malloc(nearest_pow2(game->size)); |
250 stype = detect_system_type(&media); | 271 memcpy(media.buffer, game->data, game->size); |
272 media.size = game->size; | |
273 } else { | |
274 load_media((char *)game->path, &media, &stype); | |
275 } | |
276 if (stype == SYSTEM_UNKNOWN) { | |
277 stype = detect_system_type(&media); | |
278 } | |
251 current_system = alloc_config_system(stype, &media, 0, 0); | 279 current_system = alloc_config_system(stype, &media, 0, 0); |
252 | 280 |
253 unsigned format = RETRO_PIXEL_FORMAT_XRGB8888; | 281 unsigned format = RETRO_PIXEL_FORMAT_XRGB8888; |
254 retro_environment(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &format); | 282 retro_environment(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &format); |
255 | 283 |