annotate menu.c @ 873:91bf4d905eba

Retrieve ROM filename from menu port write
author Michael Pavone <pavone@retrodev.com>
date Sun, 08 Nov 2015 15:58:36 -0800
parents 7022ba865cfd
children b6842dfb8edf
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));
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
61 menu->curpath = strdup(get_home_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
62 }
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 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
64 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
65 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
66 {
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 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
68 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
69 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
70 if (entries) {
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
71 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
72 }
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
73 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
74 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
75 {
868
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
76 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
77 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
78 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
79 }
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 *(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
81 *(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
82 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
83 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
84 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
85 {
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 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
87 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
88 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
89 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
90 } 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
91 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
92 }
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 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
94 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
95 //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
96 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
97 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
98 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
99 }
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 } 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
101 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
102 }
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 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
105 *(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
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 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
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 }
868
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
110 //terminate list
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
111 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
112 if (dest) {
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
113 *dest = dest[1] = 0;
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
114 free_dir_list(entries, num_entries);
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
115 }
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
116 break;
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
117 }
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
118 case 1: {
1bab7e01ae98 Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents: 866
diff changeset
119 char buf[4096];
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
120 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
121 if (!strcmp(buf, "..")) {
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
122 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
123 while (len > 1) {
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
124 --len;
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
125 if (menu->curpath[len] == '/') {
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
126 menu->curpath[len] = 0;
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
127 break;
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
128 }
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 } else {
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
131 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
132 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
133 free(pieces[0]);
f173317ecdb4 More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents: 868
diff changeset
134 }
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
135 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
136 }
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
137 case 2: {
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
138 char buf[4096];
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
139 copy_string_from_guest(m68k, dst, buf, sizeof(buf));
872
7022ba865cfd Initial work for allowing loading a ROM from menu
Michael Pavone <pavone@retrodev.com>
parents: 870
diff changeset
140 m68k->should_return = 1;
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
diff changeset
141 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
142 break;
873
91bf4d905eba Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents: 872
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 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
145 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
146 }
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 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
148 } 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
149 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
150 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
151 }
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
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 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
154 }