Mercurial > repos > blastem
annotate menu.c @ 970:e2d7067ea2d8
Got mouse working right in main and about menus
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 21 Apr 2016 18:48:15 -0700 |
parents | 750995b587a0 |
children | 4899d3ae37b3 |
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> |
934
05b0a0d4fa40
Add strerror output to menu dir open failure message
Michael Pavone <pavone@retrodev.com>
parents:
933
diff
changeset
|
5 #include <errno.h> |
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
|
6 #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
|
7 #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
|
8 #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
|
9 #include "util.h" |
961
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
10 #include "gst.h" |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
11 #include "m68k_internal.h" //needed for get_native_address_trans, should be eliminated once handling of PC is cleaned up |
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
|
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 |
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 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
|
15 { |
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 //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
|
17 //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
|
18 //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
|
19 //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
|
20 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
|
21 } |
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
|
22 |
868
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
23 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
|
24 { |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
25 const dir_entry *da, *db; |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
26 da = a; |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
27 db = b; |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
28 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
|
29 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
|
30 } |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
31 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
|
32 } |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
33 |
873
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
34 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
|
35 { |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
36 char *cur; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
37 char *src = NULL; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
38 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
|
39 { |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
40 if (!src || !(guest_addr & 0xFFFF)) { |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
41 //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
|
42 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
|
43 if (!src) { |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
44 break; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
45 } |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
46 } |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
47 *cur = src[1]; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
48 cur[1] = *src; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
49 if (!*src || !src[1]) { |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
50 break; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
51 } |
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 //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
|
54 buf[maxchars-1] = 0; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
55 } |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
56 |
957 | 57 void copy_to_guest(m68k_context *m68k, uint32_t guest_addr, char *src, size_t tocopy) |
58 { | |
59 char *dst = NULL; | |
60 for (char *cur = src; cur < src+tocopy; cur+=2, guest_addr+=2, dst+=2) | |
61 { | |
62 if (!dst || !(guest_addr & 0xFFFF)) { | |
63 //we may have walked off the end of a memory block, get a fresh native pointer | |
64 dst = get_native_pointer(guest_addr, (void **)m68k->mem_pointers, &m68k->options->gen); | |
65 if (!dst) { | |
66 break; | |
67 } | |
68 } | |
958
83532f944e3b
Get slot list displaying in "Save State" and "Load State" menu items
Michael Pavone <pavone@retrodev.com>
parents:
957
diff
changeset
|
69 dst[1] = *cur; |
83532f944e3b
Get slot list displaying in "Save State" and "Load State" menu items
Michael Pavone <pavone@retrodev.com>
parents:
957
diff
changeset
|
70 *dst = cur[1]; |
957 | 71 } |
72 } | |
73 | |
74 #define SAVE_INFO_BUFFER_SIZE (11*40) | |
75 | |
882
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
76 #ifdef __ANDROID__ |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
77 #include <SDL.h> |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
78 #include <jni.h> |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
79 char *get_external_storage_path() |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
80 { |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
81 static char *ret; |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
82 if (ret) { |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
83 return ret; |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
84 } |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
85 JNIEnv *env = SDL_AndroidGetJNIEnv(); |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
86 if ((*env)->PushLocalFrame(env, 8) < 0) { |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
87 return NULL; |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
88 } |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
89 |
882
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
90 jclass Environment = (*env)->FindClass(env, "android/os/Environment"); |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
91 jmethodID getExternalStorageDirectory = |
882
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
92 (*env)->GetStaticMethodID(env, Environment, "getExternalStorageDirectory", "()Ljava/io/File;"); |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
93 jobject file = (*env)->CallStaticObjectMethod(env, Environment, getExternalStorageDirectory); |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
94 if (!file) { |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
95 goto cleanup; |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
96 } |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
97 |
882
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
98 jmethodID getAbsolutePath = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, file), |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
99 "getAbsolutePath", "()Ljava/lang/String;"); |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
100 jstring path = (*env)->CallObjectMethod(env, file, getAbsolutePath); |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
101 |
882
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
102 char const *tmp = (*env)->GetStringUTFChars(env, path, NULL); |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
103 ret = strdup(tmp); |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
104 (*env)->ReleaseStringUTFChars(env, path, tmp); |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
105 |
882
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
106 cleanup: |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
107 (*env)->PopLocalFrame(env, NULL); |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
108 return ret; |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
109 } |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
110 #endif |
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
111 |
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
|
112 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
|
113 { |
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 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 if (menu->curpath) { |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
121 menu->curpath = strdup(menu->curpath); |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
122 } else { |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
123 #ifdef __ANDROID__ |
882
75453bf2ffac
SDL_AndroidGetExternalStoragePath did not do what I thought. Use JNI directly to call Environment.getExternalStorageDirectory
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
124 menu->curpath = strdup(get_external_storage_path()); |
875
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
125 #else |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
126 menu->curpath = strdup(get_home_dir()); |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
127 #endif |
54ffba3768d6
Make menu stuff work on Android (theoretically)
Michael Pavone <pavone@retrodev.com>
parents:
874
diff
changeset
|
128 } |
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
|
129 } |
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
|
130 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
|
131 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
|
132 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
|
133 { |
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
|
134 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
|
135 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
|
136 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
|
137 if (entries) { |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
138 qsort(entries, num_entries, sizeof(dir_entry), menu_dir_sort); |
933
f7da9b4df0e7
Log errors opening directories in the menu code
Michael Pavone <pavone@retrodev.com>
parents:
884
diff
changeset
|
139 } else { |
934
05b0a0d4fa40
Add strerror output to menu dir open failure message
Michael Pavone <pavone@retrodev.com>
parents:
933
diff
changeset
|
140 warning("Failed to open directory %s: %s\n", menu->curpath, strerror(errno)); |
868
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
141 } |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
142 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
|
143 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
|
144 { |
868
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 } |
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 *(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
|
150 *(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
|
151 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
|
152 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
|
153 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
|
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 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
|
156 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
|
157 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
|
158 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
|
159 } 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
|
160 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
|
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 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
|
163 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
|
164 //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
|
165 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
|
166 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
|
167 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
|
168 } |
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
|
169 } 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
|
170 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
|
171 } |
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
|
172 } |
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
|
173 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
|
174 *(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
|
175 *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
|
176 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
|
177 } |
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
|
178 } |
868
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
179 //terminate list |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
180 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
|
181 if (dest) { |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
182 *dest = dest[1] = 0; |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
183 free_dir_list(entries, num_entries); |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
184 } |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
185 break; |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
186 } |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
187 case 1: { |
1bab7e01ae98
Allow directory navigation in menu. Sort directory entries
Michael Pavone <pavone@retrodev.com>
parents:
866
diff
changeset
|
188 char buf[4096]; |
873
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
189 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
|
190 if (!strcmp(buf, "..")) { |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
191 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
|
192 while (len > 1) { |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
193 --len; |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
194 if (menu->curpath[len] == '/') { |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
195 menu->curpath[len] = 0; |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
196 break; |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
197 } |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
198 } |
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
199 } else { |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
200 char *tmp = menu->curpath; |
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
201 char const *pieces[] = {menu->curpath, "/", buf}; |
870
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
202 menu->curpath = alloc_concat_m(3, pieces); |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
203 free(tmp); |
870
f173317ecdb4
More efficient handling of going up one directory in menu
Michael Pavone <pavone@retrodev.com>
parents:
868
diff
changeset
|
204 } |
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
|
205 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
|
206 } |
873
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
207 case 2: { |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
208 char buf[4096]; |
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
209 copy_string_from_guest(m68k, dst, buf, sizeof(buf)); |
884
252dfd29831d
Selecting a second game from the menu now works
Michael Pavone <pavone@retrodev.com>
parents:
882
diff
changeset
|
210 char const *pieces[] = {menu->curpath, "/", 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
|
211 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
|
212 m68k->should_return = 1; |
7022ba865cfd
Initial work for allowing loading a ROM from menu
Michael Pavone <pavone@retrodev.com>
parents:
870
diff
changeset
|
213 break; |
957 | 214 } |
949
5e4fb650de58
Make Exit option in menu work
Michael Pavone <pavone@retrodev.com>
parents:
934
diff
changeset
|
215 case 3: { |
954
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
216 switch (dst) |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
217 { |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
218 case 1: |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
219 m68k->should_return = 1; |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
220 gen->should_exit = 1; |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
221 break; |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
222 case 2: |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
223 m68k->should_return = 1; |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
224 break; |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
225 } |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
226 |
949
5e4fb650de58
Make Exit option in menu work
Michael Pavone <pavone@retrodev.com>
parents:
934
diff
changeset
|
227 break; |
5e4fb650de58
Make Exit option in menu work
Michael Pavone <pavone@retrodev.com>
parents:
934
diff
changeset
|
228 } |
957 | 229 case 4: { |
230 char *buffer = malloc(SAVE_INFO_BUFFER_SIZE); | |
231 char *cur = buffer; | |
232 if (gen->next_context && gen->next_context->save_dir) { | |
233 char *end = buffer + SAVE_INFO_BUFFER_SIZE; | |
234 char slotfile[] = "slot_0.gst"; | |
235 char const * parts[3] = {gen->next_context->save_dir, "/", slotfile}; | |
236 struct tm ltime; | |
237 char *fname; | |
238 time_t modtime; | |
239 for (int i = 0; i < 10 && cur < end; i++) | |
240 { | |
241 slotfile[5] = i + '0'; | |
242 fname = alloc_concat_m(3, parts); | |
243 modtime = get_modification_time(fname); | |
244 free(fname); | |
245 if (modtime) { | |
246 cur += snprintf(cur, end-cur, "Slot %d - ", i); | |
247 cur += strftime(cur, end-cur, "%c", localtime_r(&modtime, <ime)); | |
248 | |
249 } else { | |
250 cur += snprintf(cur, end-cur, "Slot %d - EMPTY", i); | |
251 } | |
252 //advance past the null terminator for this entry | |
253 cur++; | |
254 } | |
255 if (cur < end) { | |
256 parts[2] = "quicksave.gst"; | |
257 fname = alloc_concat_m(3, parts); | |
258 modtime = get_modification_time(fname); | |
259 free(fname); | |
260 if (modtime) { | |
958
83532f944e3b
Get slot list displaying in "Save State" and "Load State" menu items
Michael Pavone <pavone@retrodev.com>
parents:
957
diff
changeset
|
261 cur += strftime(cur, end-cur, "Quick - %c", localtime_r(&modtime, <ime)); |
83532f944e3b
Get slot list displaying in "Save State" and "Load State" menu items
Michael Pavone <pavone@retrodev.com>
parents:
957
diff
changeset
|
262 } else if ((end-cur) > strlen("Quick - EMPTY")){ |
83532f944e3b
Get slot list displaying in "Save State" and "Load State" menu items
Michael Pavone <pavone@retrodev.com>
parents:
957
diff
changeset
|
263 cur += strlen(strcpy(cur, "Quick - EMPTY")); |
957 | 264 } |
265 //advance past the null terminator for this entry | |
266 cur++; | |
267 if (cur < end) { | |
268 //terminate the list | |
958
83532f944e3b
Get slot list displaying in "Save State" and "Load State" menu items
Michael Pavone <pavone@retrodev.com>
parents:
957
diff
changeset
|
269 *(cur++) = 0; |
957 | 270 } |
271 } | |
272 } else { | |
273 *(cur++) = 0; | |
274 *(cur++) = 0; | |
275 } | |
276 copy_to_guest(m68k, dst, buffer, cur-buffer); | |
277 break; | |
961
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
278 case 5: |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
279 //save state |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
280 if (gen->next_context) { |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
281 gen->next_context->save_state = dst + 1; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
282 } |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
283 m68k->should_return = 1; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
284 break; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
285 case 6: |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
286 //load state |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
287 if (gen->next_context && gen->next_context->save_dir) { |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
288 char numslotname[] = "slot_0.gst"; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
289 char *slotname; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
290 if (dst == QUICK_SAVE_SLOT) { |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
291 slotname = "quicksave.gst"; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
292 } else { |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
293 numslotname[5] = '0' + dst; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
294 slotname = numslotname; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
295 } |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
296 char const *parts[] = {gen->next_context->save_dir, "/", slotname}; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
297 char *gstpath = alloc_concat_m(3, parts); |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
298 uint32_t pc = load_gst(gen->next_context, gstpath); |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
299 free(gstpath); |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
300 gen->next_context->m68k->resume_pc = get_native_address_trans(gen->next_context->m68k, pc); |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
301 } |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
302 m68k->should_return = 1; |
750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Michael Pavone <pavone@retrodev.com>
parents:
958
diff
changeset
|
303 break; |
873
91bf4d905eba
Retrieve ROM filename from menu port write
Michael Pavone <pavone@retrodev.com>
parents:
872
diff
changeset
|
304 } |
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
|
305 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
|
306 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
|
307 } |
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
|
308 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
|
309 } 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
|
310 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
|
311 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
|
312 } |
954
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
313 if (m68k->should_return) { |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
314 m68k->target_cycle = m68k->current_cycle; |
cbc5b39e5518
Implement "Resume" button in pause menu
Michael Pavone <pavone@retrodev.com>
parents:
949
diff
changeset
|
315 } |
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
|
316 |
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
|
317 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
|
318 } |