comparison menu.c @ 875:54ffba3768d6

Make menu stuff work on Android (theoretically)
author Michael Pavone <pavone@retrodev.com>
date Sun, 08 Nov 2015 22:03:34 -0800
parents b6842dfb8edf
children 75453bf2ffac
comparison
equal deleted inserted replaced
874:b6842dfb8edf 875:54ffba3768d6
57 genesis_context *gen = m68k->system; 57 genesis_context *gen = m68k->system;
58 menu_context *menu = gen->extra; 58 menu_context *menu = gen->extra;
59 if (!menu) { 59 if (!menu) {
60 gen->extra = menu = calloc(1, sizeof(menu_context)); 60 gen->extra = menu = calloc(1, sizeof(menu_context));
61 menu->curpath = tern_find_path(config, "ui\0initial_path\0").ptrval; 61 menu->curpath = tern_find_path(config, "ui\0initial_path\0").ptrval;
62 menu->curpath = menu->curpath ? strdup(menu->curpath) : strdup(get_home_dir()); 62 if (menu->curpath) {
63 menu->curpath = strdup(menu->curpath);
64 } else {
65 #ifdef __ANDROID__
66 menu->curpath = strdup(SDL_AndroidGetExternalStoragePath());
67 #else
68 menu->curpath = strdup(get_home_dir());
69 #endif
70 }
63 } 71 }
64 if (menu->state) { 72 if (menu->state) {
65 uint32_t dst = menu->latch << 16 | value; 73 uint32_t dst = menu->latch << 16 | value;
66 switch (address >> 2) 74 switch (address >> 2)
67 { 75 {
139 char buf[4096]; 147 char buf[4096];
140 copy_string_from_guest(m68k, dst, buf, sizeof(buf)); 148 copy_string_from_guest(m68k, dst, buf, sizeof(buf));
141 char *pieces[] = {menu->curpath, "/", buf}; 149 char *pieces[] = {menu->curpath, "/", buf};
142 gen->next_rom = alloc_concat_m(3, pieces); 150 gen->next_rom = alloc_concat_m(3, pieces);
143 m68k->should_return = 1; 151 m68k->should_return = 1;
144 fprintf(stderr, "MENU: Selected ROM %s\n", buf);
145 break; 152 break;
146 } 153 }
147 default: 154 default:
148 fprintf(stderr, "WARNING: write to undefined menu port %X\n", address); 155 fprintf(stderr, "WARNING: write to undefined menu port %X\n", address);
149 } 156 }