Mercurial > repos > blastem
annotate menu.c @ 880:0e4e9ea2d18d
Another .hgignore fix and add the symlink to menu.bin in android/assets
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 09 Nov 2015 21:26:47 -0800 |
parents | 54ffba3768d6 |
children | 75453bf2ffac |
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; |
875
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
62 if (menu->curpath) { |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
63 menu->curpath = strdup(menu->curpath); |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
64 } else { |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
65 #ifdef __ANDROID__ |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
66 menu->curpath = strdup(SDL_AndroidGetExternalStoragePath()); |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
67 #else |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
68 menu->curpath = strdup(get_home_dir()); |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
69 #endif |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
70 } |
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
|
71 } |
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
|
72 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
|
73 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
|
74 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
|
75 { |
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 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
|
77 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
|
78 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
|
79 if (entries) { |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
80 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
|
81 } |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
82 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
|
83 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
|
84 { |
868
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
85 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
|
86 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
|
87 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
|
88 } |
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 *(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
|
90 *(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
|
91 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
|
92 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
|
93 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
|
94 { |
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 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
|
96 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
|
97 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
|
98 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
|
99 } 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
|
100 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
|
101 } |
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 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
|
103 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
|
104 //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
|
105 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
|
106 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
|
107 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
|
108 } |
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 } 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
|
110 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
|
111 } |
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
|
112 } |
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
|
113 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
|
114 *(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
|
115 *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
|
116 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
|
117 } |
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
|
118 } |
868
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
119 //terminate list |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
120 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
|
121 if (dest) { |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
122 *dest = dest[1] = 0; |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
123 free_dir_list(entries, num_entries); |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
124 } |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
125 break; |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
126 } |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
127 case 1: { |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
128 char buf[4096]; |
873
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
129 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
|
130 if (!strcmp(buf, "..")) { |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
131 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
|
132 while (len > 1) { |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
133 --len; |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
134 if (menu->curpath[len] == '/') { |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
135 menu->curpath[len] = 0; |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
136 break; |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
137 } |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
138 } |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
139 } else { |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
140 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
|
141 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
|
142 free(pieces[0]); |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
143 } |
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
|
144 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
|
145 } |
873
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
146 case 2: { |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
147 char buf[4096]; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
148 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
|
149 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
|
150 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
|
151 m68k->should_return = 1; |
7022ba865cfd
Initial work for allowing loading a ROM from menu
Michael Pavone <pavone@retrodev.com>
parents:
870
diff
changeset
|
152 break; |
873
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
153 } |
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
|
154 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
|
155 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
|
156 } |
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 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
|
158 } 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
|
159 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
|
160 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
|
161 } |
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
|
162 |
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
|
163 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
|
164 } |