annotate menu.c @ 874:b6842dfb8edf

ROM is now run after being selected in menu. Initial path for menu is read from config file.
author Michael Pavone <pavone@retrodev.com>
date Sun, 08 Nov 2015 18:38:33 -0800
parents 91bf4d905eba
children 54ffba3768d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
866
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <stdint.h>
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <stdlib.h>
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include <string.h>
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include <stdio.h>
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include "blastem.h"
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #include "menu.h"
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 #include "backend.h"
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 #include "util.h"
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 uint16_t menu_read_w(uint32_t address, void * context)
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 //This should return the status of the last request with 0
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 //meaning either the request is complete or no request is pending
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 //in the current implementation, the operations happen instantly
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 //in emulated time so we can always return 0
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 return 0;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19
868
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
20 int menu_dir_sort(const void *a, const void *b)
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
21 {
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
22 const dir_entry *da, *db;
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
23 da = a;
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
24 db = b;
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
25 if (da->is_dir != db->is_dir) {
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
26 return db->is_dir - da->is_dir;
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
27 }
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
28 return strcasecmp(((dir_entry *)a)->name, ((dir_entry *)b)->name);
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
29 }
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
30
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
31 void copy_string_from_guest(m68k_context *m68k, uint32_t guest_addr, char *buf, size_t maxchars)
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
32 {
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
33 char *cur;
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
34 char *src = NULL;
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
35 for (cur = buf; cur < buf+maxchars; cur+=2, guest_addr+=2, src+=2)
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
36 {
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
37 if (!src || !(guest_addr & 0xFFFF)) {
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
38 //we may have walked off the end of a memory block, get a fresh native pointer
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
39 src = get_native_pointer(guest_addr, (void **)m68k->mem_pointers, &m68k->options->gen);
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
40 if (!src) {
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
41 break;
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
42 }
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
43 }
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
44 *cur = src[1];
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
45 cur[1] = *src;
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
46 if (!*src || !src[1]) {
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
47 break;
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
48 }
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
49 }
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
50 //make sure we terminate the string even if we did not hit a null terminator in the source
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
51 buf[maxchars-1] = 0;
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
52 }
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
53
866
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 void * menu_write_w(uint32_t address, void * context, uint16_t value)
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 m68k_context *m68k = context;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 genesis_context *gen = m68k->system;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 menu_context *menu = gen->extra;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 if (!menu) {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 gen->extra = menu = calloc(1, sizeof(menu_context));
874
b6842dfb8edf ROM is now run after being selected in menu. Initial path for menu is read from config file.
Michael Pavone <pavone@retrodev.com>
parents: 873
diff changeset
61 menu->curpath = tern_find_path(config, "ui\0initial_path\0").ptrval;
b6842dfb8edf ROM is now run after being selected in menu. Initial path for menu is read from config file.
Michael Pavone <pavone@retrodev.com>
parents: 873
diff changeset
62 menu->curpath = menu->curpath ? strdup(menu->curpath) : strdup(get_home_dir());
866
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 if (menu->state) {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 uint32_t dst = menu->latch << 16 | value;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 switch (address >> 2)
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67 {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68 case 0: {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
69 size_t num_entries;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 dir_entry *entries = get_dir_list(menu->curpath, &num_entries);
868
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
71 if (entries) {
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
72 qsort(entries, num_entries, sizeof(dir_entry), menu_dir_sort);
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
73 }
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
74 uint8_t *dest;
866
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
75 for (size_t i = 0; i < num_entries; i++)
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
76 {
868
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
77 dest = get_native_pointer(dst, (void **)m68k->mem_pointers, &m68k->options->gen);
866
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 if (!dest) {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
79 break;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 *(dest++) = entries[i].is_dir;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 *(dest++) = 1;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 dst += 2;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84 uint8_t term = 0;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 for (char *cpos = entries[i].name; *cpos; cpos++)
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 dest[1] = *cpos;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
88 dest[0] = cpos[1];
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 if (cpos[1]) {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
90 cpos++;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91 } else {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92 term = 1;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
94 dst += 2;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95 if (!(dst & 0xFFFF)) {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 //we may have walked off the end of a memory block, get a fresh native pointer
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97 dest = get_native_pointer(dst, (void **)m68k->mem_pointers, &m68k->options->gen);
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
98 if (!dest) {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 break;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
100 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
101 } else {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
102 dest += 2;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
103 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
104 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
105 if (!term) {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
106 *(dest++) = 0;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
107 *dest = 0;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
108 dst += 2;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
109 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
110 }
868
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
111 //terminate list
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
112 dest = get_native_pointer(dst, (void **)m68k->mem_pointers, &m68k->options->gen);
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
113 if (dest) {
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
114 *dest = dest[1] = 0;
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
115 free_dir_list(entries, num_entries);
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
116 }
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
117 break;
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
118 }
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
119 case 1: {
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
120 char buf[4096];
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
121 copy_string_from_guest(m68k, dst, buf, sizeof(buf));
870
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
122 if (!strcmp(buf, "..")) {
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
123 size_t len = strlen(menu->curpath);
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
124 while (len > 1) {
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
125 --len;
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
126 if (menu->curpath[len] == '/') {
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
127 menu->curpath[len] = 0;
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
128 break;
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
129 }
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
130 }
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
131 } else {
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
132 char *pieces[] = {menu->curpath, "/", buf};
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
133 menu->curpath = alloc_concat_m(3, pieces);
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
134 free(pieces[0]);
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
135 }
866
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
136 break;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
137 }
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
138 case 2: {
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
139 char buf[4096];
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
140 copy_string_from_guest(m68k, dst, buf, sizeof(buf));
874
b6842dfb8edf ROM is now run after being selected in menu. Initial path for menu is read from config file.
Michael Pavone <pavone@retrodev.com>
parents: 873
diff changeset
141 char *pieces[] = {menu->curpath, "/", buf};
b6842dfb8edf ROM is now run after being selected in menu. Initial path for menu is read from config file.
Michael Pavone <pavone@retrodev.com>
parents: 873
diff changeset
142 gen->next_rom = alloc_concat_m(3, pieces);
872
7022ba865cfd Initial work for allowing loading a ROM from menu
Michael Pavone <pavone@retrodev.com>
parents: 870
diff changeset
143 m68k->should_return = 1;
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
144 fprintf(stderr, "MENU: Selected ROM %s\n", buf);
872
7022ba865cfd Initial work for allowing loading a ROM from menu
Michael Pavone <pavone@retrodev.com>
parents: 870
diff changeset
145 break;
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
146 }
866
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
147 default:
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
148 fprintf(stderr, "WARNING: write to undefined menu port %X\n", address);
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
149 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
150 menu->state = 0;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
151 } else {
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
152 menu->latch = value;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
153 menu->state = 1;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
154 }
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
155
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
156 return context;
69a6ec208111 Menu ROM now pulls real file names from the OS rather than using a fake list
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
157 }