comparison blastem.c @ 1326:071e761bcdcf

Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
author Michael Pavone <pavone@retrodev.com>
date Fri, 21 Apr 2017 23:35:32 -0700
parents 96ad1b9bbb3a
children 990a26391933
comparison
equal deleted inserted replaced
1325:58bfbed6cdb5 1326:071e761bcdcf
138 } 138 }
139 139
140 void setup_saves(char *fname, rom_info *info, system_header *context) 140 void setup_saves(char *fname, rom_info *info, system_header *context)
141 { 141 {
142 static uint8_t persist_save_registered; 142 static uint8_t persist_save_registered;
143 char *savedir_template = tern_find_path(config, "ui\0save_path\0").ptrval; 143 char *savedir_template = tern_find_path(config, "ui\0save_path\0", TVAL_PTR).ptrval;
144 if (!savedir_template) { 144 if (!savedir_template) {
145 savedir_template = "$USERDATA/blastem/$ROMNAME"; 145 savedir_template = "$USERDATA/blastem/$ROMNAME";
146 } 146 }
147 char * barename = basename_no_extension(fname); 147 char * barename = basename_no_extension(fname);
148 tern_node *vars = tern_insert_ptr(NULL, "ROMNAME", barename); 148 tern_node *vars = tern_insert_ptr(NULL, "ROMNAME", barename);
320 } 320 }
321 } 321 }
322 uint8_t menu = !loaded; 322 uint8_t menu = !loaded;
323 if (!loaded) { 323 if (!loaded) {
324 //load menu 324 //load menu
325 romfname = tern_find_path(config, "ui\0rom\0").ptrval; 325 romfname = tern_find_path(config, "ui\0rom\0", TVAL_PTR).ptrval;
326 if (!romfname) { 326 if (!romfname) {
327 romfname = "menu.bin"; 327 romfname = "menu.bin";
328 } 328 }
329 if (is_absolute_path(romfname)) { 329 if (is_absolute_path(romfname)) {
330 if (!(cart.size = load_rom(romfname, &cart.buffer, &stype))) { 330 if (!(cart.size = load_rom(romfname, &cart.buffer, &stype))) {
347 cart.extension = path_extension(romfname); 347 cart.extension = path_extension(romfname);
348 loaded = 1; 348 loaded = 1;
349 } 349 }
350 350
351 int def_width = 0; 351 int def_width = 0;
352 char *config_width = tern_find_path(config, "video\0width\0").ptrval; 352 char *config_width = tern_find_path(config, "video\0width\0", TVAL_PTR).ptrval;
353 if (config_width) { 353 if (config_width) {
354 def_width = atoi(config_width); 354 def_width = atoi(config_width);
355 } 355 }
356 if (!def_width) { 356 if (!def_width) {
357 def_width = 640; 357 def_width = 640;
358 } 358 }
359 width = width < 320 ? def_width : width; 359 width = width < 320 ? def_width : width;
360 height = height < 240 ? (width/320) * 240 : height; 360 height = height < 240 ? (width/320) * 240 : height;
361 361
362 char *config_fullscreen = tern_find_path(config, "video\0fullscreen\0").ptrval; 362 char *config_fullscreen = tern_find_path(config, "video\0fullscreen\0", TVAL_PTR).ptrval;
363 if (config_fullscreen && !strcmp("on", config_fullscreen)) { 363 if (config_fullscreen && !strcmp("on", config_fullscreen)) {
364 fullscreen = !fullscreen; 364 fullscreen = !fullscreen;
365 } 365 }
366 if (!headless) { 366 if (!headless) {
367 render_init(width, height, "BlastEm", fullscreen); 367 render_init(width, height, "BlastEm", fullscreen);