Mercurial > repos > blastem
annotate blastem.c @ 2487:2ea2f3aa5aa8
Remove dis.exe and zdis.exe from Windows builds due to silly antivirus false positives
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 15 Apr 2024 23:00:02 -0700 |
parents | cb62730d5c99 |
children | d74d3998482c |
rev | line source |
---|---|
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
464
diff
changeset
|
1 /* |
1018
dba8c630bdbf
Update changelog and version number for 0.4.0 release
Michael Pavone <pavone@retrodev.com>
parents:
1017
diff
changeset
|
2 Copyright 2013-2016 Michael Pavone |
469
5f3344d0d42f
Fix argument handling so that the rom filename does not need to be specified first
Mike Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
3 This file is part of BlastEm. |
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
464
diff
changeset
|
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
464
diff
changeset
|
5 */ |
883
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
6 #include <stdio.h> |
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
7 #include <stdlib.h> |
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
8 #include <string.h> |
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
9 #include <ctype.h> |
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
10 |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
11 #include "system.h" |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 #include "68kinst.h" |
569
9b7fcf748be0
Rename x86_68k_options and m68k_to_x86.h to m68k_options and m68k_core.h respectively
Michael Pavone <pavone@retrodev.com>
parents:
565
diff
changeset
|
13 #include "m68k_core.h" |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1685
diff
changeset
|
14 #ifdef NEW_CORE |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1685
diff
changeset
|
15 #include "z80.h" |
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1685
diff
changeset
|
16 #else |
260
625f8e4d5fd2
Initial stab at integartiong Z80 core
Mike Pavone <pavone@retrodev.com>
parents:
215
diff
changeset
|
17 #include "z80_to_x86.h" |
1752
d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents:
1685
diff
changeset
|
18 #endif |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 #include "mem.h" |
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 #include "vdp.h" |
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 #include "render.h" |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1097
diff
changeset
|
22 #include "genesis.h" |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
510
diff
changeset
|
23 #include "gdb_remote.h" |
451
b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
Mike Pavone <pavone@retrodev.com>
parents:
447
diff
changeset
|
24 #include "gst.h" |
496
6fc71114d145
Extract function to determine executable directory from load_config so it can be used elsewhere
Mike Pavone <pavone@retrodev.com>
parents:
488
diff
changeset
|
25 #include "util.h" |
2262
bc68560b4a04
Fix bug when loading cue sheet without leading path
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
26 #include "paths.h" |
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
753
diff
changeset
|
27 #include "romdb.h" |
832
0433fdd9ba66
Added a command line option to force BlastEm to not open a new terminal even if it detects that stdin/out are not terminals
Michael Pavone <pavone@retrodev.com>
parents:
819
diff
changeset
|
28 #include "terminal.h" |
883
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
29 #include "arena.h" |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1097
diff
changeset
|
30 #include "config.h" |
1583
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1582
diff
changeset
|
31 #include "bindings.h" |
1423
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
32 #include "menu.h" |
1531
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
33 #include "zip.h" |
2114
2449c88cea36
Enhance support for CUE files and add initial support for cdrdao TOC files
Michael Pavone <pavone@retrodev.com>
parents:
2083
diff
changeset
|
34 #include "cdimage.h" |
1946 | 35 #include "event_log.h" |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
36 #ifndef DISABLE_NUKLEAR |
1474
c5c022c7aa54
Initial work on Nuklear-based UI
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
37 #include "nuklear_ui/blastem_nuklear.h" |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
38 #endif |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 |
1815
7f4fac75b484
Update version number for nightly builds
Mike Pavone <pavone@retrodev.com>
parents:
1812
diff
changeset
|
40 #define BLASTEM_VERSION "0.6.3-pre" |
464 | 41 |
860
213c3b5160d0
Default to fullscreen on Android since windowed mode does not make sense there
Michael Pavone <pavone@retrodev.com>
parents:
846
diff
changeset
|
42 #ifdef __ANDROID__ |
213c3b5160d0
Default to fullscreen on Android since windowed mode does not make sense there
Michael Pavone <pavone@retrodev.com>
parents:
846
diff
changeset
|
43 #define FULLSCREEN_DEFAULT 1 |
213c3b5160d0
Default to fullscreen on Android since windowed mode does not make sense there
Michael Pavone <pavone@retrodev.com>
parents:
846
diff
changeset
|
44 #else |
213c3b5160d0
Default to fullscreen on Android since windowed mode does not make sense there
Michael Pavone <pavone@retrodev.com>
parents:
846
diff
changeset
|
45 #define FULLSCREEN_DEFAULT 0 |
213c3b5160d0
Default to fullscreen on Android since windowed mode does not make sense there
Michael Pavone <pavone@retrodev.com>
parents:
846
diff
changeset
|
46 #endif |
213c3b5160d0
Default to fullscreen on Android since windowed mode does not make sense there
Michael Pavone <pavone@retrodev.com>
parents:
846
diff
changeset
|
47 |
215
2b1c2c28b261
Added headless flag to avoid initializing SDL and opening a window when running tests.
Mike Pavone <pavone@retrodev.com>
parents:
211
diff
changeset
|
48 int headless = 0; |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
501
diff
changeset
|
49 int exit_after = 0; |
265
c6d12878ea93
Add -n flag for disabling the Z80 core
Mike Pavone <pavone@retrodev.com>
parents:
264
diff
changeset
|
50 int z80_enabled = 1; |
356
79e4b466e7d0
Get rid of debug puts and limit based on audio rather than frame rate by default.
Mike Pavone <pavone@retrodev.com>
parents:
354
diff
changeset
|
51 int frame_limit = 0; |
1428
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
52 uint8_t use_native_states = 1; |
215
2b1c2c28b261
Added headless flag to avoid initializing SDL and opening a window when running tests.
Mike Pavone <pavone@retrodev.com>
parents:
211
diff
changeset
|
53 |
430
7f84090ab1cd
Add config file parser and default config file
Mike Pavone <pavone@retrodev.com>
parents:
425
diff
changeset
|
54 tern_node * config; |
7f84090ab1cd
Add config file parser and default config file
Mike Pavone <pavone@retrodev.com>
parents:
425
diff
changeset
|
55 |
166 | 56 #define SMD_HEADER_SIZE 512 |
57 #define SMD_MAGIC1 0x03 | |
58 #define SMD_MAGIC2 0xAA | |
59 #define SMD_MAGIC3 0xBB | |
60 #define SMD_BLOCK_SIZE 0x4000 | |
61 | |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
62 #ifdef DISABLE_ZLIB |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
63 #define ROMFILE FILE* |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
64 #define romopen fopen |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
65 #define romread fread |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
66 #define romseek fseek |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
67 #define romgetc fgetc |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
68 #define romclose fclose |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
69 #else |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
70 #include "zlib/zlib.h" |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
71 #define ROMFILE gzFile |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
72 #define romopen gzopen |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
73 #define romread gzfread |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
74 #define romseek gzseek |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
75 #define romgetc gzgetc |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
76 #define romclose gzclose |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
77 #endif |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
78 |
1683
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
79 uint16_t *process_smd_block(uint16_t *dst, uint8_t *src, size_t bytes) |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
80 { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
81 for (uint8_t *low = src, *high = (src+bytes/2), *end = src+bytes; high < end; high++, low++) { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
82 *(dst++) = *low << 8 | *high; |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
83 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
84 return dst; |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
85 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
86 |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
87 int load_smd_rom(ROMFILE f, void **buffer) |
166 | 88 { |
89 uint8_t block[SMD_BLOCK_SIZE]; | |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
90 romseek(f, SMD_HEADER_SIZE, SEEK_SET); |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
91 |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
92 size_t filesize = 512 * 1024; |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
93 size_t readsize = 0; |
1682 | 94 uint16_t *dst, *buf; |
95 dst = buf = malloc(filesize); | |
2053 | 96 |
488
32f053ad9b02
Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
487
diff
changeset
|
97 |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
98 size_t read; |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
99 do { |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
100 if ((readsize + SMD_BLOCK_SIZE > filesize)) { |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
101 filesize *= 2; |
1682 | 102 buf = realloc(buf, filesize); |
103 dst = buf + readsize/sizeof(uint16_t); | |
166 | 104 } |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
105 read = romread(block, 1, SMD_BLOCK_SIZE, f); |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
106 if (read > 0) { |
1683
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
107 dst = process_smd_block(dst, block, read); |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
108 readsize += read; |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
109 } |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
110 } while(read > 0); |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
111 romclose(f); |
2053 | 112 |
1682 | 113 *buffer = buf; |
2053 | 114 |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
115 return readsize; |
166 | 116 } |
117 | |
1683
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
118 uint8_t is_smd_format(const char *filename, uint8_t *header) |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
119 { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
120 if (header[1] == SMD_MAGIC1 && header[8] == SMD_MAGIC2 && header[9] == SMD_MAGIC3) { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
121 int i; |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
122 for (i = 3; i < 8; i++) { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
123 if (header[i] != 0) { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
124 return 0; |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
125 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
126 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
127 if (i == 8) { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
128 if (header[2]) { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
129 fatal_error("%s is a split SMD ROM which is not currently supported", filename); |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
130 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
131 return 1; |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
132 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
133 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
134 return 0; |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
135 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
136 |
1692 | 137 uint32_t load_media_zip(const char *filename, system_media *dst) |
1531
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
138 { |
2257
1e626d0ecf9c
WIP SG-1000/TMS9918A mode support
Michael Pavone <pavone@retrodev.com>
parents:
2211
diff
changeset
|
139 static const char *valid_exts[] = {"bin", "md", "gen", "sms", "gg", "rom", "smd", "sg"}; |
1531
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
140 const uint32_t num_exts = sizeof(valid_exts)/sizeof(*valid_exts); |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
141 zip_file *z = zip_open(filename); |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
142 if (!z) { |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
143 return 0; |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
144 } |
2053 | 145 |
1531
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
146 for (uint32_t i = 0; i < z->num_entries; i++) |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
147 { |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
148 char *ext = path_extension(z->entries[i].name); |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
149 if (!ext) { |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
150 continue; |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
151 } |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
152 for (uint32_t j = 0; j < num_exts; j++) |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
153 { |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
154 if (!strcasecmp(ext, valid_exts[j])) { |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
155 size_t out_size = nearest_pow2(z->entries[i].size); |
1692 | 156 dst->buffer = zip_read(z, i, &out_size); |
157 if (dst->buffer) { | |
2053 | 158 if (is_smd_format(z->entries[i].name, dst->buffer)) { |
1683
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
159 size_t offset; |
1788
154c7b348cf1
Fix off-by-one error in code for loading an SMD format ROM from a ZIP archive
Michael Pavone <pavone@retrodev.com>
parents:
1752
diff
changeset
|
160 for (offset = 0; offset + SMD_BLOCK_SIZE + SMD_HEADER_SIZE <= out_size; offset += SMD_BLOCK_SIZE) |
1683
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
161 { |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
162 uint8_t tmp[SMD_BLOCK_SIZE]; |
2053 | 163 uint8_t *u8dst = dst->buffer; |
1952
42c12d141f6e
Remove usage of GCC pointer arithmetic on void * extension
Michael Pavone <pavone@retrodev.com>
parents:
1946
diff
changeset
|
164 memcpy(tmp, u8dst + offset + SMD_HEADER_SIZE, SMD_BLOCK_SIZE); |
42c12d141f6e
Remove usage of GCC pointer arithmetic on void * extension
Michael Pavone <pavone@retrodev.com>
parents:
1946
diff
changeset
|
165 process_smd_block((void *)(u8dst + offset), tmp, SMD_BLOCK_SIZE); |
1683
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
166 } |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
167 out_size = offset; |
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
168 } |
1692 | 169 dst->extension = ext; |
170 dst->dir = path_dirname(filename); | |
2262
bc68560b4a04
Fix bug when loading cue sheet without leading path
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
171 if (!dst->dir) { |
bc68560b4a04
Fix bug when loading cue sheet without leading path
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
172 dst->dir = path_current_dir(); |
bc68560b4a04
Fix bug when loading cue sheet without leading path
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
173 } |
1692 | 174 dst->name = basename_no_extension(filename); |
175 dst->size = out_size; | |
2438
bed4d3db8a3f
More flexible loading of Pico storyware assets
Michael Pavone <pavone@retrodev.com>
parents:
2430
diff
changeset
|
176 dst->zip = z; |
1531
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
177 return out_size; |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
178 } |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
179 } |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
180 } |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
181 free(ext); |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
182 } |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
183 zip_close(z); |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
184 return 0; |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
185 } |
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
186 |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
187 uint32_t load_media(char * filename, system_media *dst, system_type *stype) |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 { |
166 | 189 uint8_t header[10]; |
2438
bed4d3db8a3f
More flexible loading of Pico storyware assets
Michael Pavone <pavone@retrodev.com>
parents:
2430
diff
changeset
|
190 if (dst->zip) { |
bed4d3db8a3f
More flexible loading of Pico storyware assets
Michael Pavone <pavone@retrodev.com>
parents:
2430
diff
changeset
|
191 zip_close(dst->zip); |
bed4d3db8a3f
More flexible loading of Pico storyware assets
Michael Pavone <pavone@retrodev.com>
parents:
2430
diff
changeset
|
192 } |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
193 dst->orig_path = filename; |
1531
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
194 char *ext = path_extension(filename); |
1663
f00fec236d56
Fix crash when passed a filename with no extension
Mike Pavone <pavone@retrodev.com>
parents:
1651
diff
changeset
|
195 if (ext && !strcasecmp(ext, "zip")) { |
1531
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
196 free(ext); |
1692 | 197 return load_media_zip(filename, dst); |
1531
092675db4f37
Add support for loading ROMs from zip files
Michael Pavone <pavone@retrodev.com>
parents:
1529
diff
changeset
|
198 } |
2076
3f29e2726522
Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents:
2061
diff
changeset
|
199 if (ext && !strcasecmp(ext, "iso")) { |
3f29e2726522
Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents:
2061
diff
changeset
|
200 if (stype) { |
3f29e2726522
Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents:
2061
diff
changeset
|
201 *stype = SYSTEM_SEGACD; |
3f29e2726522
Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents:
2061
diff
changeset
|
202 } |
3f29e2726522
Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents:
2061
diff
changeset
|
203 return make_iso_media(dst, filename); |
3f29e2726522
Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents:
2061
diff
changeset
|
204 } |
2211
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
205 |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
206 ROMFILE f = romopen(filename, "rb"); |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 if (!f) { |
2211
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
208 free(ext); |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 return 0; |
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 } |
2211
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
211 #ifndef DISABLE_ZLIB |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
212 char *to_free = NULL; |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
213 if (!gzdirect(f) && ext && !strcasecmp(ext, "gz")) { |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
214 size_t without_gz = strlen(filename) - 2; |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
215 to_free = calloc(1, without_gz); |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
216 memcpy(to_free, filename, without_gz - 1); |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
217 to_free[without_gz - 1] = 0; |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
218 free(ext); |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
219 filename = to_free; |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
220 ext = path_extension(filename); |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
221 } |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
222 #endif //DISABLE_ZLIB |
2076
3f29e2726522
Added basic support for ISO images for games that only have a data track
Michael Pavone <pavone@retrodev.com>
parents:
2061
diff
changeset
|
223 |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
224 if (sizeof(header) != romread(header, 1, sizeof(header), f)) { |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
787
diff
changeset
|
225 fatal_error("Error reading from %s\n", filename); |
776
cbf97d335444
Full support for Sega mapper when it comes to data. Code in remapped sections may not work reliably. SSF2 now works.
Michael Pavone <pavone@retrodev.com>
parents:
774
diff
changeset
|
226 } |
2053 | 227 |
1472
d2d637dbacfb
Change load_rom into load_media with some interface changes in preparation for CD support
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
228 uint32_t ret = 0; |
1683
7e044a84268d
Add support for SMD format ROMs in ZIP files
Michael Pavone <pavone@retrodev.com>
parents:
1682
diff
changeset
|
229 if (is_smd_format(filename, header)) { |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
230 if (stype) { |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
231 *stype = SYSTEM_GENESIS; |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
232 } |
1692 | 233 ret = load_smd_rom(f, &dst->buffer); |
166 | 234 } |
2053 | 235 |
1472
d2d637dbacfb
Change load_rom into load_media with some interface changes in preparation for CD support
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
236 if (!ret) { |
1692 | 237 size_t filesize = 512 * 1024; |
238 size_t readsize = sizeof(header); | |
2053 | 239 |
1692 | 240 char *buf = malloc(filesize); |
241 memcpy(buf, header, readsize); | |
2053 | 242 |
1692 | 243 size_t read; |
244 do { | |
245 read = romread(buf + readsize, 1, filesize - readsize, f); | |
246 if (read > 0) { | |
247 readsize += read; | |
248 if (readsize == filesize) { | |
249 int one_more = romgetc(f); | |
250 if (one_more >= 0) { | |
251 filesize *= 2; | |
252 buf = realloc(buf, filesize); | |
253 buf[readsize++] = one_more; | |
254 } else { | |
255 read = 0; | |
256 } | |
1529
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
257 } |
f7fe240a7da6
Updated fibonacci benchmark code to work with current test harness
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
258 } |
1692 | 259 } while (read > 0); |
260 dst->buffer = buf; | |
261 ret = (uint32_t)readsize; | |
776
cbf97d335444
Full support for Sega mapper when it comes to data. Code in remapped sections may not work reliably. SSF2 now works.
Michael Pavone <pavone@retrodev.com>
parents:
774
diff
changeset
|
262 } |
1472
d2d637dbacfb
Change load_rom into load_media with some interface changes in preparation for CD support
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
263 dst->dir = path_dirname(filename); |
2262
bc68560b4a04
Fix bug when loading cue sheet without leading path
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
264 if (!dst->dir) { |
bc68560b4a04
Fix bug when loading cue sheet without leading path
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
265 dst->dir = path_current_dir(); |
bc68560b4a04
Fix bug when loading cue sheet without leading path
Michael Pavone <pavone@retrodev.com>
parents:
2257
diff
changeset
|
266 } |
1472
d2d637dbacfb
Change load_rom into load_media with some interface changes in preparation for CD support
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
267 dst->name = basename_no_extension(filename); |
2211
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
268 dst->extension = ext; |
1472
d2d637dbacfb
Change load_rom into load_media with some interface changes in preparation for CD support
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
269 dst->size = ret; |
2059
6399a776e981
Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
2053
diff
changeset
|
270 romclose(f); |
6399a776e981
Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
2053
diff
changeset
|
271 if (!strcasecmp(dst->extension, "cue")) { |
6399a776e981
Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
2053
diff
changeset
|
272 if (parse_cue(dst)) { |
2061
7c1760b5b3e5
Implemented basic TOC functionality of CDD MCU
Michael Pavone <pavone@retrodev.com>
parents:
2059
diff
changeset
|
273 if (stype) { |
7c1760b5b3e5
Implemented basic TOC functionality of CDD MCU
Michael Pavone <pavone@retrodev.com>
parents:
2059
diff
changeset
|
274 *stype = SYSTEM_SEGACD; |
7c1760b5b3e5
Implemented basic TOC functionality of CDD MCU
Michael Pavone <pavone@retrodev.com>
parents:
2059
diff
changeset
|
275 } |
2059
6399a776e981
Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
2053
diff
changeset
|
276 } |
2114
2449c88cea36
Enhance support for CUE files and add initial support for cdrdao TOC files
Michael Pavone <pavone@retrodev.com>
parents:
2083
diff
changeset
|
277 } else if (!strcasecmp(dst->extension, "toc")) { |
2449c88cea36
Enhance support for CUE files and add initial support for cdrdao TOC files
Michael Pavone <pavone@retrodev.com>
parents:
2083
diff
changeset
|
278 if (parse_toc(dst)) { |
2449c88cea36
Enhance support for CUE files and add initial support for cdrdao TOC files
Michael Pavone <pavone@retrodev.com>
parents:
2083
diff
changeset
|
279 if (stype) { |
2449c88cea36
Enhance support for CUE files and add initial support for cdrdao TOC files
Michael Pavone <pavone@retrodev.com>
parents:
2083
diff
changeset
|
280 *stype = SYSTEM_SEGACD; |
2449c88cea36
Enhance support for CUE files and add initial support for cdrdao TOC files
Michael Pavone <pavone@retrodev.com>
parents:
2083
diff
changeset
|
281 } |
2449c88cea36
Enhance support for CUE files and add initial support for cdrdao TOC files
Michael Pavone <pavone@retrodev.com>
parents:
2083
diff
changeset
|
282 } |
2059
6399a776e981
Add basic support for BIN/CUE images
Michael Pavone <pavone@retrodev.com>
parents:
2053
diff
changeset
|
283 } |
2211
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
284 #ifndef DISABLE_ZLIB |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
285 if (to_free) { |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
286 free(to_free); |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
287 } |
5e6e589efbad
Strip off .gz extension for gzipped ROMs in load_media so system detection based on filename works with such files
Michael Pavone <pavone@retrodev.com>
parents:
2203
diff
changeset
|
288 #endif |
2053 | 289 |
1472
d2d637dbacfb
Change load_rom into load_media with some interface changes in preparation for CD support
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
290 return ret; |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 } |
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 |
198
209a37eed3e7
Add support for breaking into the debugger while game is running
Mike Pavone <pavone@retrodev.com>
parents:
197
diff
changeset
|
293 int break_on_sync = 0; |
955
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
294 char *save_state_path; |
767
ea525f600b1d
SRAM detection from ROM header is no working correctly again
Michael Pavone <pavone@retrodev.com>
parents:
766
diff
changeset
|
295 char * save_filename; |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
296 system_header *current_system; |
1423
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
297 system_header *menu_system; |
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
298 system_header *game_system; |
767
ea525f600b1d
SRAM detection from ROM header is no working correctly again
Michael Pavone <pavone@retrodev.com>
parents:
766
diff
changeset
|
299 void persist_save() |
351
2f264d2a60c2
Support for SRAM with SEGA mapper. Half-finished support for SRAM without SEGA mapper.
Mike Pavone <pavone@retrodev.com>
parents:
346
diff
changeset
|
300 { |
2289
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
301 if (!game_system || !game_system->persist_save) { |
1009
883fe974f72b
Fix bug in which save RAM/EEPROM was not persisted correctly if the emulator is exited via the menu rather than the X button in the title bar
Michael Pavone <pavone@retrodev.com>
parents:
1008
diff
changeset
|
302 return; |
883fe974f72b
Fix bug in which save RAM/EEPROM was not persisted correctly if the emulator is exited via the menu rather than the X button in the title bar
Michael Pavone <pavone@retrodev.com>
parents:
1008
diff
changeset
|
303 } |
1423
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
304 game_system->persist_save(game_system); |
351
2f264d2a60c2
Support for SRAM with SEGA mapper. Half-finished support for SRAM without SEGA mapper.
Mike Pavone <pavone@retrodev.com>
parents:
346
diff
changeset
|
305 } |
2f264d2a60c2
Support for SRAM with SEGA mapper. Half-finished support for SRAM without SEGA mapper.
Mike Pavone <pavone@retrodev.com>
parents:
346
diff
changeset
|
306 |
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
753
diff
changeset
|
307 char *title; |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
753
diff
changeset
|
308 void update_title(char *rom_name) |
340
58a085cfc6bd
Set window title based on ROM header name
Mike Pavone <pavone@retrodev.com>
parents:
338
diff
changeset
|
309 { |
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
753
diff
changeset
|
310 if (title) { |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
753
diff
changeset
|
311 free(title); |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
753
diff
changeset
|
312 title = NULL; |
340
58a085cfc6bd
Set window title based on ROM header name
Mike Pavone <pavone@retrodev.com>
parents:
338
diff
changeset
|
313 } |
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
753
diff
changeset
|
314 title = alloc_concat(rom_name, " - BlastEm"); |
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:
872
diff
changeset
|
315 render_update_caption(title); |
340
58a085cfc6bd
Set window title based on ROM header name
Mike Pavone <pavone@retrodev.com>
parents:
338
diff
changeset
|
316 } |
58a085cfc6bd
Set window title based on ROM header name
Mike Pavone <pavone@retrodev.com>
parents:
338
diff
changeset
|
317 |
1412
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
318 static char *get_save_dir(system_media *media) |
955
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
319 { |
1326
071e761bcdcf
Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents:
1295
diff
changeset
|
320 char *savedir_template = tern_find_path(config, "ui\0save_path\0", TVAL_PTR).ptrval; |
1295
96ad1b9bbb3a
Make save directory configurable. Satisfies ticket:4
Michael Pavone <pavone@retrodev.com>
parents:
1223
diff
changeset
|
321 if (!savedir_template) { |
96ad1b9bbb3a
Make save directory configurable. Satisfies ticket:4
Michael Pavone <pavone@retrodev.com>
parents:
1223
diff
changeset
|
322 savedir_template = "$USERDATA/blastem/$ROMNAME"; |
96ad1b9bbb3a
Make save directory configurable. Satisfies ticket:4
Michael Pavone <pavone@retrodev.com>
parents:
1223
diff
changeset
|
323 } |
1412
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
324 tern_node *vars = tern_insert_ptr(NULL, "ROMNAME", media->name); |
1850
30f2821ffd65
Allow rom directory and rom name in screenshot path. Allow rom name in screenshot name. Remove ability for path variables to contain underscores
Michael Pavone <pavone@retrodev.com>
parents:
1815
diff
changeset
|
325 vars = tern_insert_ptr(vars, "ROMDIR", media->dir); |
1295
96ad1b9bbb3a
Make save directory configurable. Satisfies ticket:4
Michael Pavone <pavone@retrodev.com>
parents:
1223
diff
changeset
|
326 vars = tern_insert_ptr(vars, "HOME", get_home_dir()); |
96ad1b9bbb3a
Make save directory configurable. Satisfies ticket:4
Michael Pavone <pavone@retrodev.com>
parents:
1223
diff
changeset
|
327 vars = tern_insert_ptr(vars, "EXEDIR", get_exe_dir()); |
96ad1b9bbb3a
Make save directory configurable. Satisfies ticket:4
Michael Pavone <pavone@retrodev.com>
parents:
1223
diff
changeset
|
328 vars = tern_insert_ptr(vars, "USERDATA", (char *)get_userdata_dir()); |
96ad1b9bbb3a
Make save directory configurable. Satisfies ticket:4
Michael Pavone <pavone@retrodev.com>
parents:
1223
diff
changeset
|
329 char *save_dir = replace_vars(savedir_template, vars, 1); |
96ad1b9bbb3a
Make save directory configurable. Satisfies ticket:4
Michael Pavone <pavone@retrodev.com>
parents:
1223
diff
changeset
|
330 tern_free(vars); |
955
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
331 if (!ensure_dir_exists(save_dir)) { |
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
332 warning("Failed to create save directory %s\n", save_dir); |
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
333 } |
1412
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
334 return save_dir; |
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
335 } |
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
336 |
2027
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
337 const char *get_save_fname(uint8_t save_type) |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
338 { |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
339 switch(save_type) |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
340 { |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
341 case SAVE_I2C: return "save.eeprom"; |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
342 case SAVE_NOR: return "save.nor"; |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
343 case SAVE_HBPT: return "save.hbpt"; |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
344 default: return "save.sram"; |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
345 } |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
346 } |
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
347 |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
348 void setup_saves(system_media *media, system_header *context) |
1412
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
349 { |
2289
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
350 if (!context->load_save) { |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
351 // system doesn't support saves |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
352 return; |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
353 } |
1412
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
354 static uint8_t persist_save_registered; |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
355 rom_info *info = &context->info; |
1412
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
356 char *save_dir = get_save_dir(info->is_save_lock_on ? media->chain : media); |
2027
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1980
diff
changeset
|
357 char const *parts[] = {save_dir, PATH_SEP, get_save_fname(info->save_type)}; |
955
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
358 free(save_filename); |
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
359 save_filename = alloc_concat_m(3, parts); |
1412
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
360 if (info->is_save_lock_on) { |
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
361 //initial save dir was calculated based on lock-on cartridge because that's where the save device is |
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
362 //save directory used for save states should still be located in the normal place |
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
363 free(save_dir); |
1592
31effaadf877
Fix some memory errors (mostly leaks) identified by valgrind
Michael Pavone <pavone@retrodev.com>
parents:
1583
diff
changeset
|
364 parts[0] = save_dir = get_save_dir(media); |
1412
909c72c4e5a1
Load SRAM/EEPROM from lock-on cart directory if the lock-on cart is the one with the save device
Michael Pavone <pavone@retrodev.com>
parents:
1402
diff
changeset
|
365 } |
1428
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
366 if (use_native_states || context->type != SYSTEM_GENESIS) { |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
367 parts[2] = "quicksave.state"; |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
368 } else { |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
369 parts[2] = "quicksave.gst"; |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
370 } |
955
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
371 free(save_state_path); |
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
372 save_state_path = alloc_concat_m(3, parts); |
956
f5550cdffe49
Saving the save directory in the rom_info struct didn't make sense. It should be in the console context.
Michael Pavone <pavone@retrodev.com>
parents:
955
diff
changeset
|
373 context->save_dir = save_dir; |
2083
372625dd9590
Persist BRAM to file. Load BIOS relative to blastem directory
Michael Pavone <pavone@retrodev.com>
parents:
2076
diff
changeset
|
374 if (info->save_type != SAVE_NONE || context->type == SYSTEM_SEGACD |
372625dd9590
Persist BRAM to file. Load BIOS relative to blastem directory
Michael Pavone <pavone@retrodev.com>
parents:
2076
diff
changeset
|
375 || (context->type == SYSTEM_GENESIS && info->wants_cd) |
372625dd9590
Persist BRAM to file. Load BIOS relative to blastem directory
Michael Pavone <pavone@retrodev.com>
parents:
2076
diff
changeset
|
376 ) { |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
377 context->load_save(context); |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
378 if (!persist_save_registered) { |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
379 atexit(persist_save); |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
380 persist_save_registered = 1; |
956
f5550cdffe49
Saving the save directory in the rom_info struct didn't make sense. It should be in the console context.
Michael Pavone <pavone@retrodev.com>
parents:
955
diff
changeset
|
381 } |
f5550cdffe49
Saving the save directory in the rom_info struct didn't make sense. It should be in the console context.
Michael Pavone <pavone@retrodev.com>
parents:
955
diff
changeset
|
382 } |
955
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
383 } |
229c23b3ab73
Switch to storing SRAM/EEPROM and save states in a per-game directory rather than next to the ROM (for SRAM/EEPROM) or in the current working directory (for save states)
Michael Pavone <pavone@retrodev.com>
parents:
953
diff
changeset
|
384 |
1573
a051d8ee4528
Only save config file if something has changed. Re-initialize audio and video with new settings if config has changed
Michael Pavone <pavone@retrodev.com>
parents:
1550
diff
changeset
|
385 void apply_updated_config(void) |
a051d8ee4528
Only save config file if something has changed. Re-initialize audio and video with new settings if config has changed
Michael Pavone <pavone@retrodev.com>
parents:
1550
diff
changeset
|
386 { |
a051d8ee4528
Only save config file if something has changed. Re-initialize audio and video with new settings if config has changed
Michael Pavone <pavone@retrodev.com>
parents:
1550
diff
changeset
|
387 render_config_updated(); |
2314
59fd8aa352e2
Apply binding changes after a config change in UI
Michael Pavone <pavone@retrodev.com>
parents:
2289
diff
changeset
|
388 set_bindings(); |
59fd8aa352e2
Apply binding changes after a config change in UI
Michael Pavone <pavone@retrodev.com>
parents:
2289
diff
changeset
|
389 update_pad_bindings(); |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
390 if (current_system && current_system->config_updated) { |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
391 current_system->config_updated(current_system); |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
392 } |
1573
a051d8ee4528
Only save config file if something has changed. Re-initialize audio and video with new settings if config has changed
Michael Pavone <pavone@retrodev.com>
parents:
1550
diff
changeset
|
393 } |
a051d8ee4528
Only save config file if something has changed. Re-initialize audio and video with new settings if config has changed
Michael Pavone <pavone@retrodev.com>
parents:
1550
diff
changeset
|
394 |
2430
fb8d6ebf9d5f
Fix crash when loading new ROM via drag/drop when existing ROM has lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2428
diff
changeset
|
395 static system_media cart, lock_on; |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
396 static void on_drag_drop(char *filename) |
1397
89eb967fed72
Initial support for drag and drop. Some work needed for proper menu integration.
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
397 { |
1581
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
398 if (current_system) { |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
399 if (current_system->next_rom) { |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
400 free(current_system->next_rom); |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
401 } |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
402 current_system->next_rom = strdup(filename); |
1980
81df9aa2de9b
Less hacky run on audio thread mode
Michael Pavone <pavone@retrodev.com>
parents:
1975
diff
changeset
|
403 system_request_exit(current_system, 1); |
1581
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
404 if (menu_system && menu_system->type == SYSTEM_GENESIS) { |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
405 genesis_context *gen = (genesis_context *)menu_system; |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
406 if (gen->extra) { |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
407 menu_context *menu = gen->extra; |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
408 menu->external_game_load = 1; |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
409 } |
1423
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
410 } |
2430
fb8d6ebf9d5f
Fix crash when loading new ROM via drag/drop when existing ROM has lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2428
diff
changeset
|
411 cart.chain = NULL; |
1423
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
412 } else { |
1581
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
413 init_system_with_media(filename, SYSTEM_UNKNOWN); |
1423
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
414 } |
1581
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
415 #ifndef DISABLE_NUKLEAR |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
416 if (is_nuklear_active()) { |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
417 show_play_view(); |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
418 } |
7121daaa48c2
Fix drag and drop when using Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1573
diff
changeset
|
419 #endif |
1397
89eb967fed72
Initial support for drag and drop. Some work needed for proper menu integration.
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
420 } |
89eb967fed72
Initial support for drag and drop. Some work needed for proper menu integration.
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
421 |
1850
30f2821ffd65
Allow rom directory and rom name in screenshot path. Allow rom name in screenshot name. Remove ability for path variables to contain underscores
Michael Pavone <pavone@retrodev.com>
parents:
1815
diff
changeset
|
422 const system_media *current_media(void) |
30f2821ffd65
Allow rom directory and rom name in screenshot path. Allow rom name in screenshot name. Remove ability for path variables to contain underscores
Michael Pavone <pavone@retrodev.com>
parents:
1815
diff
changeset
|
423 { |
30f2821ffd65
Allow rom directory and rom name in screenshot path. Allow rom name in screenshot name. Remove ability for path variables to contain underscores
Michael Pavone <pavone@retrodev.com>
parents:
1815
diff
changeset
|
424 return &cart; |
30f2821ffd65
Allow rom directory and rom name in screenshot path. Allow rom name in screenshot name. Remove ability for path variables to contain underscores
Michael Pavone <pavone@retrodev.com>
parents:
1815
diff
changeset
|
425 } |
30f2821ffd65
Allow rom directory and rom name in screenshot path. Allow rom name in screenshot name. Remove ability for path variables to contain underscores
Michael Pavone <pavone@retrodev.com>
parents:
1815
diff
changeset
|
426 |
1438
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
427 void reload_media(void) |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
428 { |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
429 if (!current_system || !cart.orig_path) { |
1582
a74db49fa6b1
Added null check to reload_media
Michael Pavone <pavone@retrodev.com>
parents:
1581
diff
changeset
|
430 return; |
a74db49fa6b1
Added null check to reload_media
Michael Pavone <pavone@retrodev.com>
parents:
1581
diff
changeset
|
431 } |
1438
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
432 if (current_system->next_rom) { |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
433 free(current_system->next_rom); |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
434 } |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
435 current_system->next_rom = cart.orig_path; |
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
436 cart.orig_path = NULL; |
2401
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
437 if (cart.chain) { |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
438 load_media(cart.chain->orig_path, cart.chain, NULL); |
2401
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
439 } |
1980
81df9aa2de9b
Less hacky run on audio thread mode
Michael Pavone <pavone@retrodev.com>
parents:
1975
diff
changeset
|
440 system_request_exit(current_system, 1); |
1438
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
441 } |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
442 |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
443 void lockon_media(char *lock_on_path) |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
444 { |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
445 free(lock_on.dir); |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
446 free(lock_on.name); |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
447 free(lock_on.extension); |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
448 free(lock_on.orig_path); |
2401
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
449 if (lock_on_path) { |
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
450 reload_media(); |
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
451 cart.chain = &lock_on; |
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
452 load_media(lock_on_path, &lock_on, NULL); |
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
453 } else { |
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
454 lock_on.dir = NULL; |
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
455 lock_on.name = NULL; |
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
456 lock_on.extension = NULL; |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
457 lock_on.orig_path = NULL; |
2401
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
458 cart.chain = NULL; |
34b4ff091891
Fix crash when loading a subsequent ROM after lock-on
Michael Pavone <pavone@retrodev.com>
parents:
2314
diff
changeset
|
459 } |
1438
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
460 } |
e2bd03ed3190
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Michael Pavone <pavone@retrodev.com>
parents:
1428
diff
changeset
|
461 |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
462 static uint32_t opts = 0; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
463 static uint8_t force_region = 0; |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
464 void init_system_with_media(char *path, system_type force_stype) |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
465 { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
466 if (game_system) { |
2289
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
467 if (game_system->persist_save) { |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
468 game_system->persist_save(game_system); |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
469 } |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
470 //swap to game context arena and mark all allocated pages in it free |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
471 if (current_system == menu_system) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
472 current_system->arena = set_current_arena(game_system->arena); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
473 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
474 mark_all_free(); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
475 game_system->free_context(game_system); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
476 } else if(current_system) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
477 //start a new arena and save old one in suspended system context |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
478 current_system->arena = start_new_arena(); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
479 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
480 free(cart.dir); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
481 free(cart.name); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
482 free(cart.extension); |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
483 free(cart.orig_path); |
1692 | 484 system_type stype = SYSTEM_UNKNOWN; |
485 if (!(cart.size = load_media(path, &cart, &stype))) { | |
486 fatal_error("Failed to open %s for reading\n", path); | |
487 } | |
2053 | 488 |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
489 if (force_stype != SYSTEM_UNKNOWN) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
490 stype = force_stype; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
491 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
492 if (stype == SYSTEM_UNKNOWN) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
493 stype = detect_system_type(&cart); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
494 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
495 if (stype == SYSTEM_UNKNOWN) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
496 fatal_error("Failed to detect system type for %s\n", path); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
497 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
498 //allocate new system context |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
499 game_system = alloc_config_system(stype, &cart, opts, force_region); |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
500 if (!game_system) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
501 fatal_error("Failed to configure emulated machine for %s\n", path); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
502 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
503 if (menu_system) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
504 menu_system->next_context = game_system; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
505 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
506 game_system->next_context = menu_system; |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
507 setup_saves(&cart, game_system); |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
508 update_title(game_system->info.name); |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
509 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
510 |
1946 | 511 char *parse_addr_port(char *arg) |
512 { | |
513 while (*arg && *arg != ':') { | |
514 ++arg; | |
515 } | |
516 if (!*arg) { | |
517 return NULL; | |
518 } | |
519 char *end; | |
520 int port = strtol(arg + 1, &end, 10); | |
521 if (port && !*end) { | |
522 *arg = 0; | |
523 return arg + 1; | |
524 } | |
525 return NULL; | |
526 } | |
527 | |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
528 int main(int argc, char ** argv) |
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
529 { |
496
6fc71114d145
Extract function to determine executable directory from load_config so it can be used elsewhere
Mike Pavone <pavone@retrodev.com>
parents:
488
diff
changeset
|
530 set_exe_str(argv[0]); |
6fc71114d145
Extract function to determine executable directory from load_config so it can be used elsewhere
Mike Pavone <pavone@retrodev.com>
parents:
488
diff
changeset
|
531 config = load_config(); |
184
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
532 int width = -1; |
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
533 int height = -1; |
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
534 int debug = 0; |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
535 int loaded = 0; |
1140
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
536 system_type stype = SYSTEM_UNKNOWN, force_stype = SYSTEM_UNKNOWN; |
469
5f3344d0d42f
Fix argument handling so that the rom filename does not need to be specified first
Mike Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
537 char * romfname = NULL; |
425
8b3ae850d1c4
Forgot to null initialize the statfile pointer
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
538 char * statefile = NULL; |
1955
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
539 char *reader_addr = NULL, *reader_port = NULL; |
1946 | 540 event_reader reader = {0}; |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
541 debugger_type dtype = DEBUGGER_NATIVE; |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
542 uint8_t start_in_debugger = 0; |
860
213c3b5160d0
Default to fullscreen on Android since windowed mode does not make sense there
Michael Pavone <pavone@retrodev.com>
parents:
846
diff
changeset
|
543 uint8_t fullscreen = FULLSCREEN_DEFAULT, use_gl = 1; |
885
e3f5ec336432
Allow menu ROM to be debugged
Michael Pavone <pavone@retrodev.com>
parents:
884
diff
changeset
|
544 uint8_t debug_target = 0; |
1946 | 545 char *port; |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
546 for (int i = 1; i < argc; i++) { |
184
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
547 if (argv[i][0] == '-') { |
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
548 switch(argv[i][1]) { |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
501
diff
changeset
|
549 case 'b': |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
501
diff
changeset
|
550 i++; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
501
diff
changeset
|
551 if (i >= argc) { |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
787
diff
changeset
|
552 fatal_error("-b must be followed by a frame count\n"); |
505
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
501
diff
changeset
|
553 } |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
501
diff
changeset
|
554 headless = 1; |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
501
diff
changeset
|
555 exit_after = atoi(argv[i]); |
b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
Michael Pavone <pavone@retrodev.com>
parents:
501
diff
changeset
|
556 break; |
184
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
557 case 'd': |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
558 start_in_debugger = 1; |
885
e3f5ec336432
Allow menu ROM to be debugged
Michael Pavone <pavone@retrodev.com>
parents:
884
diff
changeset
|
559 //allow debugging the menu |
e3f5ec336432
Allow menu ROM to be debugged
Michael Pavone <pavone@retrodev.com>
parents:
884
diff
changeset
|
560 if (argv[i][2] == 'm') { |
e3f5ec336432
Allow menu ROM to be debugged
Michael Pavone <pavone@retrodev.com>
parents:
884
diff
changeset
|
561 debug_target = 1; |
e3f5ec336432
Allow menu ROM to be debugged
Michael Pavone <pavone@retrodev.com>
parents:
884
diff
changeset
|
562 } |
515
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
510
diff
changeset
|
563 break; |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
510
diff
changeset
|
564 case 'D': |
1495179d6737
Initial GDB remote debugging support. Lacks some features, but breakpoints and basic inspection of registers and memory work.
Mike Pavone <pavone@retrodev.com>
parents:
510
diff
changeset
|
565 gdb_remote_init(); |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
566 dtype = DEBUGGER_GDB; |
1164
21df13266e6a
Restore functionality of the -D flag for GDB remote debugging
Michael Pavone <pavone@retrodev.com>
parents:
1140
diff
changeset
|
567 start_in_debugger = 1; |
184
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
568 break; |
1946 | 569 case 'e': |
570 i++; | |
571 if (i >= argc) { | |
572 fatal_error("-e must be followed by a file name\n"); | |
573 } | |
574 port = parse_addr_port(argv[i]); | |
575 if (port) { | |
576 event_log_tcp(argv[i], port); | |
577 } else { | |
578 event_log_file(argv[i]); | |
579 } | |
580 break; | |
338
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
336
diff
changeset
|
581 case 'f': |
860
213c3b5160d0
Default to fullscreen on Android since windowed mode does not make sense there
Michael Pavone <pavone@retrodev.com>
parents:
846
diff
changeset
|
582 fullscreen = !fullscreen; |
338
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
336
diff
changeset
|
583 break; |
488
32f053ad9b02
Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
487
diff
changeset
|
584 case 'g': |
501
e1355aa80f4d
Use OpenGL by default. Add OpenGL switch to help text
Mike Pavone <pavone@retrodev.com>
parents:
496
diff
changeset
|
585 use_gl = 0; |
488
32f053ad9b02
Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
487
diff
changeset
|
586 break; |
197
7c227a8ec53d
Add instruction address logging to translator and support for reading an address log to the disassembler
Mike Pavone <pavone@retrodev.com>
parents:
195
diff
changeset
|
587 case 'l': |
1113
45db303fc705
Restore 68K address logging functionality
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
588 opts |= OPT_ADDRESS_LOG; |
197
7c227a8ec53d
Add instruction address logging to translator and support for reading an address log to the disassembler
Mike Pavone <pavone@retrodev.com>
parents:
195
diff
changeset
|
589 break; |
464 | 590 case 'v': |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
787
diff
changeset
|
591 info_message("blastem %s\n", BLASTEM_VERSION); |
464 | 592 return 0; |
593 break; | |
265
c6d12878ea93
Add -n flag for disabling the Z80 core
Mike Pavone <pavone@retrodev.com>
parents:
264
diff
changeset
|
594 case 'n': |
c6d12878ea93
Add -n flag for disabling the Z80 core
Mike Pavone <pavone@retrodev.com>
parents:
264
diff
changeset
|
595 z80_enabled = 0; |
c6d12878ea93
Add -n flag for disabling the Z80 core
Mike Pavone <pavone@retrodev.com>
parents:
264
diff
changeset
|
596 break; |
341
6ad8e36de685
Support regions other than USA
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
597 case 'r': |
6ad8e36de685
Support regions other than USA
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
598 i++; |
6ad8e36de685
Support regions other than USA
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
599 if (i >= argc) { |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
787
diff
changeset
|
600 fatal_error("-r must be followed by region (J, U or E)\n"); |
341
6ad8e36de685
Support regions other than USA
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
601 } |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1097
diff
changeset
|
602 force_region = translate_region_char(toupper(argv[i][0])); |
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1097
diff
changeset
|
603 if (!force_region) { |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
787
diff
changeset
|
604 fatal_error("'%c' is not a valid region character for the -r option\n", argv[i][0]); |
341
6ad8e36de685
Support regions other than USA
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
605 } |
6ad8e36de685
Support regions other than USA
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
606 break; |
1140
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
607 case 'm': |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
608 i++; |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
609 if (i >= argc) { |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
610 fatal_error("-r must be followed by a machine type (sms, gen or jag)\n"); |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
611 } |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
612 if (!strcmp("sms", argv[i])) { |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
613 stype = force_stype = SYSTEM_SMS; |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
614 } else if (!strcmp("gen", argv[i])) { |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
615 stype = force_stype = SYSTEM_GENESIS; |
2428 | 616 } else if (!strcmp("pico", argv[i])) { |
617 stype = force_stype = SYSTEM_PICO; | |
2459
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2438
diff
changeset
|
618 } else if (!strcmp("copera", argv[i])) { |
cb62730d5c99
Initial work on Copera emulation
Michael Pavone <pavone@retrodev.com>
parents:
2438
diff
changeset
|
619 stype = force_stype = SYSTEM_COPERA; |
1140
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
620 } else if (!strcmp("jag", argv[i])) { |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
621 stype = force_stype = SYSTEM_JAGUAR; |
2289
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
622 } else if (!strcmp("media", argv[i])) { |
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
623 stype = force_stype = SYSTEM_MEDIA_PLAYER; |
1140
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
624 } else { |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
625 fatal_error("Unrecognized machine type %s\n", argv[i]); |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
626 } |
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
627 break; |
424
7e8e179116af
Add support for loading GST format savestates
Mike Pavone <pavone@retrodev.com>
parents:
422
diff
changeset
|
628 case 's': |
7e8e179116af
Add support for loading GST format savestates
Mike Pavone <pavone@retrodev.com>
parents:
422
diff
changeset
|
629 i++; |
7e8e179116af
Add support for loading GST format savestates
Mike Pavone <pavone@retrodev.com>
parents:
422
diff
changeset
|
630 if (i >= argc) { |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
787
diff
changeset
|
631 fatal_error("-s must be followed by a savestate filename\n"); |
424
7e8e179116af
Add support for loading GST format savestates
Mike Pavone <pavone@retrodev.com>
parents:
422
diff
changeset
|
632 } |
7e8e179116af
Add support for loading GST format savestates
Mike Pavone <pavone@retrodev.com>
parents:
422
diff
changeset
|
633 statefile = argv[i]; |
7e8e179116af
Add support for loading GST format savestates
Mike Pavone <pavone@retrodev.com>
parents:
422
diff
changeset
|
634 break; |
832
0433fdd9ba66
Added a command line option to force BlastEm to not open a new terminal even if it detects that stdin/out are not terminals
Michael Pavone <pavone@retrodev.com>
parents:
819
diff
changeset
|
635 case 't': |
0433fdd9ba66
Added a command line option to force BlastEm to not open a new terminal even if it detects that stdin/out are not terminals
Michael Pavone <pavone@retrodev.com>
parents:
819
diff
changeset
|
636 force_no_terminal(); |
0433fdd9ba66
Added a command line option to force BlastEm to not open a new terminal even if it detects that stdin/out are not terminals
Michael Pavone <pavone@retrodev.com>
parents:
819
diff
changeset
|
637 break; |
407
c3abc4ada43d
Add support for logging YM2612 channels to WAVE files
Mike Pavone <pavone@retrodev.com>
parents:
405
diff
changeset
|
638 case 'y': |
1113
45db303fc705
Restore 68K address logging functionality
Michael Pavone <pavone@retrodev.com>
parents:
1111
diff
changeset
|
639 opts |= YM_OPT_WAVE_LOG; |
407
c3abc4ada43d
Add support for logging YM2612 channels to WAVE files
Mike Pavone <pavone@retrodev.com>
parents:
405
diff
changeset
|
640 break; |
1016
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
641 case 'o': { |
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
642 i++; |
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
643 if (i >= argc) { |
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
644 fatal_error("-o must be followed by a lock on cartridge filename\n"); |
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
645 } |
1472
d2d637dbacfb
Change load_rom into load_media with some interface changes in preparation for CD support
Michael Pavone <pavone@retrodev.com>
parents:
1460
diff
changeset
|
646 if (!load_media(argv[i], &lock_on, NULL)) { |
1016
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
647 fatal_error("Failed to load lock on cartridge %s\n", argv[i]); |
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
648 } |
1140
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
649 cart.chain = &lock_on; |
1016
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
650 break; |
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
1009
diff
changeset
|
651 } |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
652 case 'h': |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
787
diff
changeset
|
653 info_message( |
469
5f3344d0d42f
Fix argument handling so that the rom filename does not need to be specified first
Mike Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
654 "Usage: blastem [OPTIONS] ROMFILE [WIDTH] [HEIGHT]\n" |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
655 "Options:\n" |
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
656 " -h Print this help text\n" |
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
657 " -r (J|U|E) Force region to Japan, US or Europe respectively\n" |
1223
a477cc22a960
Fix indentation of -m option
Michael Pavone <pavone@retrodev.com>
parents:
1201
diff
changeset
|
658 " -m MACHINE Force emulated machine type to MACHINE. Valid values are:\n" |
2428 | 659 " sms - Sega Master System/Mark III\n" |
660 " gen - Sega Genesis/Megadrive\n" | |
661 " pico - Sega Pico\n" | |
2289
92449b47cce8
Integrate VGM player into main blastem binary
Michael Pavone <pavone@retrodev.com>
parents:
2286
diff
changeset
|
662 " media - Media Player\n" |
1017
216fa63749b3
Added documentation for lock-on support and a fullscreen config option.
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
663 " -f Toggles fullscreen mode\n" |
501
e1355aa80f4d
Use OpenGL by default. Add OpenGL switch to help text
Mike Pavone <pavone@retrodev.com>
parents:
496
diff
changeset
|
664 " -g Disable OpenGL rendering\n" |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
665 " -s FILE Load a GST format savestate from FILE\n" |
1017
216fa63749b3
Added documentation for lock-on support and a fullscreen config option.
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
666 " -o FILE Load FILE as a lock-on cartridge\n" |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
667 " -d Enter debugger on startup\n" |
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
668 " -n Disable Z80\n" |
501
e1355aa80f4d
Use OpenGL by default. Add OpenGL switch to help text
Mike Pavone <pavone@retrodev.com>
parents:
496
diff
changeset
|
669 " -v Display version number and exit\n" |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
670 " -l Log 68K code addresses (useful for assemblers)\n" |
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
671 " -y Log individual YM-2612 channels to WAVE files\n" |
1946 | 672 " -e FILE Write hardware event log to FILE\n" |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
673 ); |
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
674 return 0; |
184
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
675 default: |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
787
diff
changeset
|
676 fatal_error("Unrecognized switch %s\n", argv[i]); |
184
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
677 } |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
678 } else if (!loaded) { |
1955
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
679 reader_port = parse_addr_port(argv[i]); |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
680 if (reader_port) { |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
681 reader_addr = argv[i]; |
1946 | 682 } else { |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
683 romfname = strdup(argv[i]); |
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
684 if (!load_media(romfname, &cart, stype == SYSTEM_UNKNOWN ? &stype : NULL)) { |
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
685 fatal_error("Failed to open %s for reading\n", argv[i]); |
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
686 } |
463
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
687 } |
a1d298119153
Added -h help text option
Mike Pavone <pavone@retrodev.com>
parents:
458
diff
changeset
|
688 loaded = 1; |
184
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
689 } else if (width < 0) { |
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
690 width = atoi(argv[i]); |
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
691 } else if (height < 0) { |
ebcbdd1c4cc8
Fix a bunch of bugs in the CPU core, add a 68K debugger
Mike Pavone <pavone@retrodev.com>
parents:
166
diff
changeset
|
692 height = atoi(argv[i]); |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
693 } |
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
694 } |
2053 | 695 |
1402
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
696 int def_width = 0, def_height = 0; |
1326
071e761bcdcf
Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents:
1295
diff
changeset
|
697 char *config_width = tern_find_path(config, "video\0width\0", TVAL_PTR).ptrval; |
433
ed4d0017c041
Read default render width from config file
Mike Pavone <pavone@retrodev.com>
parents:
430
diff
changeset
|
698 if (config_width) { |
ed4d0017c041
Read default render width from config file
Mike Pavone <pavone@retrodev.com>
parents:
430
diff
changeset
|
699 def_width = atoi(config_width); |
ed4d0017c041
Read default render width from config file
Mike Pavone <pavone@retrodev.com>
parents:
430
diff
changeset
|
700 } |
ed4d0017c041
Read default render width from config file
Mike Pavone <pavone@retrodev.com>
parents:
430
diff
changeset
|
701 if (!def_width) { |
ed4d0017c041
Read default render width from config file
Mike Pavone <pavone@retrodev.com>
parents:
430
diff
changeset
|
702 def_width = 640; |
ed4d0017c041
Read default render width from config file
Mike Pavone <pavone@retrodev.com>
parents:
430
diff
changeset
|
703 } |
1402
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
704 char *config_height = tern_find_path(config, "video\0height\0", TVAL_PTR).ptrval; |
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
705 if (config_height) { |
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
706 def_height = atoi(config_height); |
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
707 } |
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
708 if (!def_height) { |
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
709 def_height = -1; |
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
710 } |
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
711 width = width < 1 ? def_width : width; |
458df351af06
Allow height to be specified in the config file and properly calculate from the aspect setting if it is not specified
Michael Pavone <pavone@retrodev.com>
parents:
1397
diff
changeset
|
712 height = height < 1 ? def_height : height; |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1097
diff
changeset
|
713 |
1326
071e761bcdcf
Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
Michael Pavone <pavone@retrodev.com>
parents:
1295
diff
changeset
|
714 char *config_fullscreen = tern_find_path(config, "video\0fullscreen\0", TVAL_PTR).ptrval; |
1017
216fa63749b3
Added documentation for lock-on support and a fullscreen config option.
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
715 if (config_fullscreen && !strcmp("on", config_fullscreen)) { |
216fa63749b3
Added documentation for lock-on support and a fullscreen config option.
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
716 fullscreen = !fullscreen; |
216fa63749b3
Added documentation for lock-on support and a fullscreen config option.
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
717 } |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
351
diff
changeset
|
718 if (!headless) { |
1975
3701517d852c
Avoid expensive re-init from switching to external sync after render_init has been called
Michael Pavone <pavone@retrodev.com>
parents:
1958
diff
changeset
|
719 if (reader_addr) { |
3701517d852c
Avoid expensive re-init from switching to external sync after render_init has been called
Michael Pavone <pavone@retrodev.com>
parents:
1958
diff
changeset
|
720 render_set_external_sync(1); |
3701517d852c
Avoid expensive re-init from switching to external sync after render_init has been called
Michael Pavone <pavone@retrodev.com>
parents:
1958
diff
changeset
|
721 } |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1097
diff
changeset
|
722 render_init(width, height, "BlastEm", fullscreen); |
1397
89eb967fed72
Initial support for drag and drop. Some work needed for proper menu integration.
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
723 render_set_drag_drop_handler(on_drag_drop); |
342
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
341
diff
changeset
|
724 } |
1583
430dd12e4010
Refactor to split device bindings from IO emulation code
Michael Pavone <pavone@retrodev.com>
parents:
1582
diff
changeset
|
725 set_bindings(); |
2053 | 726 |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
727 uint8_t menu = !loaded; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
728 uint8_t use_nuklear = 0; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
729 #ifndef DISABLE_NUKLEAR |
1651 | 730 use_nuklear = !headless && is_nuklear_available(); |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
731 #endif |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
732 if (!loaded && !use_nuklear) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
733 //load menu |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
734 romfname = tern_find_path(config, "ui\0rom\0", TVAL_PTR).ptrval; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
735 if (!romfname) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
736 romfname = "menu.bin"; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
737 } |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
738 romfname = strdup(romfname); |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
739 if (is_absolute_path(romfname)) { |
1692 | 740 if (!(cart.size = load_media(romfname, &cart, &stype))) { |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
741 fatal_error("Failed to open UI ROM %s for reading", romfname); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
742 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
743 } else { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
744 cart.buffer = (uint16_t *)read_bundled_file(romfname, &cart.size); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
745 if (!cart.buffer) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
746 fatal_error("Failed to open UI ROM %s for reading", romfname); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
747 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
748 uint32_t rom_size = nearest_pow2(cart.size); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
749 if (rom_size > cart.size) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
750 cart.buffer = realloc(cart.buffer, rom_size); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
751 cart.size = rom_size; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
752 } |
1692 | 753 cart.dir = path_dirname(romfname); |
754 cart.name = basename_no_extension(romfname); | |
755 cart.extension = path_extension(romfname); | |
2404
6f8400ce7a0f
Fix reload of zipped and gzipped ROMS
Michael Pavone <pavone@retrodev.com>
parents:
2401
diff
changeset
|
756 cart.orig_path = romfname; |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
757 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
758 //force system detection, value on command line is only for games not the menu |
1140
4490c9c12272
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Michael Pavone <pavone@retrodev.com>
parents:
1128
diff
changeset
|
759 stype = detect_system_type(&cart); |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
760 loaded = 1; |
1128
093c19f34dfd
Detect failures to initialize a system context and report an error rather than crashing
Michael Pavone <pavone@retrodev.com>
parents:
1113
diff
changeset
|
761 } |
1428
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
762 char *state_format = tern_find_path(config, "ui\0state_format\0", TVAL_PTR).ptrval; |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
763 if (state_format && !strcmp(state_format, "gst")) { |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
764 use_native_states = 0; |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
765 } else if (state_format && strcmp(state_format, "native")) { |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
766 warning("%s is not a valid value for the ui.state_format setting. Valid values are gst and native\n", state_format); |
2540c05520f2
New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents:
1423
diff
changeset
|
767 } |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
768 |
1955
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
769 if (loaded && !reader_addr) { |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
770 if (stype == SYSTEM_UNKNOWN) { |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
771 stype = detect_system_type(&cart); |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
772 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
773 if (stype == SYSTEM_UNKNOWN) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
774 fatal_error("Failed to detect system type for %s\n", romfname); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
775 } |
2053 | 776 |
1955
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
777 current_system = alloc_config_system(stype, &cart, menu ? 0 : opts, force_region); |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
778 if (!current_system) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
779 fatal_error("Failed to configure emulated machine for %s\n", romfname); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
780 } |
2053 | 781 |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
782 setup_saves(&cart, current_system); |
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1593
diff
changeset
|
783 update_title(current_system->info.name); |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
784 if (menu) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
785 menu_system = current_system; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
786 } else { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
787 game_system = current_system; |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
788 } |
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:
872
diff
changeset
|
789 } |
2053 | 790 |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
791 #ifndef DISABLE_NUKLEAR |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
792 if (use_nuklear) { |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
793 blastem_nuklear_init(!menu); |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
794 current_system = game_system; |
1486
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
795 menu = 0; |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
796 } |
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
797 #endif |
1955
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
798 |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
799 if (reader_addr) { |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
800 init_event_reader_tcp(&reader, reader_addr, reader_port); |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
801 stype = reader_system_type(&reader); |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
802 if (stype == SYSTEM_UNKNOWN) { |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
803 fatal_error("Failed to detect system type for %s\n", romfname); |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
804 } |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
805 game_system = current_system = alloc_config_player(stype, &reader); |
1958
9c01945b5d20
Use zlib to compress event log streams
Mike Pavone <pavone@retrodev.com>
parents:
1955
diff
changeset
|
806 //free inflate stream as it was inflateCopied to an internal event reader in the player |
9c01945b5d20
Use zlib to compress event log streams
Mike Pavone <pavone@retrodev.com>
parents:
1955
diff
changeset
|
807 inflateEnd(&reader.input_stream); |
1955
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
808 setup_saves(&cart, current_system); |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
809 update_title(current_system->info.name); |
1c7af12efe8b
Fix awful playback latencin in new netplay implementation
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
810 } |
2053 | 811 |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
812 current_system->debugger_type = dtype; |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
813 current_system->enter_debugger = start_in_debugger && menu == debug_target; |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
814 current_system->start_context(current_system, menu ? NULL : statefile); |
1932
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1850
diff
changeset
|
815 render_video_loop(); |
883
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
816 for(;;) |
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
817 { |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
818 if (current_system->should_exit) { |
949
5e4fb650de58
Make Exit option in menu work
Michael Pavone <pavone@retrodev.com>
parents:
940
diff
changeset
|
819 break; |
5e4fb650de58
Make Exit option in menu work
Michael Pavone <pavone@retrodev.com>
parents:
940
diff
changeset
|
820 } |
1397
89eb967fed72
Initial support for drag and drop. Some work needed for proper menu integration.
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
821 if (current_system->next_rom) { |
89eb967fed72
Initial support for drag and drop. Some work needed for proper menu integration.
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
822 char *next_rom = current_system->next_rom; |
89eb967fed72
Initial support for drag and drop. Some work needed for proper menu integration.
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
823 current_system->next_rom = NULL; |
1483
001120e91fed
Skip loading menu ROM if Nuklear UI is enabled. Allow disabling Nuklear UI in favor of old menu ROM both at compile time and in config. Fall back to ROM UI if GL is unavailable
Michael Pavone <pavone@retrodev.com>
parents:
1474
diff
changeset
|
824 init_system_with_media(next_rom, force_stype); |
883
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
825 menu = 0; |
1423
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
826 current_system = game_system; |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
827 current_system->debugger_type = dtype; |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
828 current_system->enter_debugger = start_in_debugger && menu == debug_target; |
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
829 current_system->start_context(current_system, statefile); |
1980
81df9aa2de9b
Less hacky run on audio thread mode
Michael Pavone <pavone@retrodev.com>
parents:
1975
diff
changeset
|
830 render_video_loop(); |
1423
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
831 } else if (menu && game_system) { |
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
832 current_system->arena = set_current_arena(game_system->arena); |
9a3e003bdcb3
Make drag and drop play nice with the menu
Michael Pavone <pavone@retrodev.com>
parents:
1412
diff
changeset
|
833 current_system = game_system; |
883
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
834 menu = 0; |
1111
2eb54e24914e
Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents:
1103
diff
changeset
|
835 current_system->resume_context(current_system); |
1486
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
836 } else if (!menu && (menu_system || use_nuklear)) { |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
837 if (use_nuklear) { |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
838 #ifndef DISABLE_NUKLEAR |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
839 ui_idle_loop(); |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
840 #endif |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
841 } else { |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
842 current_system->arena = set_current_arena(menu_system->arena); |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
843 current_system = menu_system; |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
844 menu = 1; |
a6881d0d76d0
Pause game execution when in the new UI pause menu
Michael Pavone <pavone@retrodev.com>
parents:
1483
diff
changeset
|
845 } |
1487
6a35815cc409
Enable lock-on in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1486
diff
changeset
|
846 if (!current_system->next_rom) { |
6a35815cc409
Enable lock-on in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1486
diff
changeset
|
847 current_system->resume_context(current_system); |
1980
81df9aa2de9b
Less hacky run on audio thread mode
Michael Pavone <pavone@retrodev.com>
parents:
1975
diff
changeset
|
848 render_video_loop(); |
1487
6a35815cc409
Enable lock-on in Nuklear UI
Michael Pavone <pavone@retrodev.com>
parents:
1486
diff
changeset
|
849 } |
883
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
850 } else { |
9f149f0e98b7
It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents:
875
diff
changeset
|
851 break; |
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:
872
diff
changeset
|
852 } |
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:
872
diff
changeset
|
853 } |
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:
872
diff
changeset
|
854 |
88
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
855 return 0; |
c339559f1d4f
Forgot to add blastem main file earlier
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
856 } |