-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblastem-0.6.2.patch
361 lines (342 loc) · 10 KB
/
blastem-0.6.2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
commit cc06e71f2329b95d2b0655535b77910dfef44a41
Author: Joey Parrish <[email protected]>
Date: Wed Mar 27 07:39:28 2024 -0700
Emulate Kinetoscope hardware in BlastEm 0.6.2
Patch based on https://github.com/libretro/blastem revision 277e4a62
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8f39f7f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+*.o
+*.sw*
+blastem
+dis
+termhelper
+vgmplay
+zdis
+kinetoscope
diff --git a/Makefile b/Makefile
index 0dddc9f..77d119e 100644
--- a/Makefile
+++ b/Makefile
@@ -23,11 +23,11 @@ ifeq ($(CPU),i686)
CC:=i686-w64-mingw32-gcc-win32
WINDRES:=i686-w64-mingw32-windres
GLUDIR:=Win32
-SDL2_PREFIX:="sdl/i686-w64-mingw32"
+SDL2_PREFIX:=sdl/i686-w64-mingw32
else
CC:=x86_64-w64-mingw32-gcc-win32
WINDRES:=x86_64-w64-mingw32-windres
-SDL2_PREFIX:="sdl/x86_64-w64-mingw32"
+SDL2_PREFIX:=sdl/x86_64-w64-mingw32
GLUDIR:=x64
endif
GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/$(GLUDIR)/glew32s.lib
@@ -96,10 +96,11 @@ LDFLAGS:=-lm glew/lib/libGLEW.a
endif
ifeq ($(OS),Darwin)
-SDL_INCLUDE_PATH:=Frameworks/SDL2.framework/Headers
-CFLAGS+= -mmacosx-version-min=10.10
-LDFLAGS+= -mmacosx-version-min=10.10
-FIXUP:=install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/Frameworks/SDL2.framework/Versions/A/SDL2
+SDL_INCLUDE_PATH:=sdl/include
+LDFLAGS+= -Llib -lSDL2 -framework OpenGL
+# These support font_mac:
+LDFLAGS+= -framework Foundation -framework AppKit
+FIXUP:= install_name_tool -change /usr/local/lib/libSDL2-2.0.0.dylib @executable_path/lib/libSDL2.dylib
else
SDL_INCLUDE_PATH:=sdl/include
LDFLAGS+= -Wl,-rpath='$$ORIGIN/lib' -Llib -lSDL2
@@ -129,6 +130,35 @@ endif
endif #PORTABLE
endif #Windows
+
+# For the kinetscope symlink in this folder
+CFLAGS+= -I.
+
+ifneq ($(PLATFORM),emscripten)
+# Curl, but only if it's not an emscripten environment
+ifdef PORTABLE
+# Static libcurl
+CFLAGS+= -Icurl/include -DCURL_STATICLIB
+LDFLAGS+= curl/lib/.libs/libcurl.a
+else
+# System libcurl
+LDFLAGS+= $(shell curl-config --libs)
+endif
+endif
+
+ifneq ($(OS),Windows)
+# Pthread is required, except on Windows
+CFLAGS+= -pthread
+LDFLAGS+= -pthread
+endif
+
+ifeq ($(OS),Darwin)
+# Needed for curl on macOS?
+LDFLAGS+= -framework SystemConfiguration
+endif #Darwin
+
+
+
ifndef OPT
ifdef DEBUG
OPT:=-g3 -O0
@@ -221,10 +251,12 @@ endif
MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o $(RENDEROBJS) io.o romdb.o hash.o menu.o xband.o \
realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \
+ kinetoscope.o \
$(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o zip.o bindings.o jcart.o gen_player.o
LIBOBJS=libblastem.o system.o genesis.o debug.o gdb_remote.o vdp.o io.o romdb.o hash.o xband.o realtec.o \
i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \
+ kinetoscope.o \
$(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o jcart.o rom.db.o gen_player.o $(LIBZOBJS)
ifdef NONUKLEAR
@@ -365,8 +397,11 @@ m68k.c : m68k.cpu cpu_dsl.py
%.o : %.m
$(CC) $(CFLAGS) -c -o $@ $<
+kinetoscope.o : kinetoscope/emulator-patches/kinetoscope.c kinetoscope/emulator-patches/fetch.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
%.png : %.xcf
- xcf2png $< > $@
+ convert $< $@
%.tiles : %.spec
./img2tiles.py -s $< $@
diff --git a/Makefile.libretro b/Makefile.libretro
index a8af9bc..f890d01 100644
--- a/Makefile.libretro
+++ b/Makefile.libretro
@@ -58,7 +58,7 @@ endif
core: $(OBJ)
- $(MAKE) $(target) OS=$(OS) CC=$(CC) CPU=$(ABI) LIBRETRO=$(LIBRETRO)
+ $(MAKE) $(target) OS=$(OS) CC=$(CC) CPU=$(ABI) LIBRETRO=$(LIBRETRO) PLATFORM=$(platform)
cp -v $(target) $(libname)
install: $(libname)
diff --git a/build_release b/build_release
index f5faa10..c49e0b9 100755
--- a/build_release
+++ b/build_release
@@ -3,28 +3,52 @@
set -e
if [ -z "$OS" ]; then
- OS=`uname -s`
+ echo "\$OS should be Linux, Darwin, or Win64"
+ exit 1
fi
-if [ $OS = "Linux" ]; then
+if [ $OS = "Linux" -o $OS = "Darwin" ]; then
cd sdl
./configure
- make all
+ make build/libSDL2.la
cd ..
rm -rf lib
mkdir lib
- cp sdl/build/.libs/libSDL2-*.so.*.*.* lib
- sdl=`ls lib`
- link=`echo $sdl | sed -E 's/(so\.[0-9]*).*/\1/'`
+ if [ $OS = "Linux" ]; then
+ cp sdl/build/.libs/libSDL2-*.so.*.*.* lib
+ sdl=`ls lib`
+ link=`echo $sdl | sed -E 's/(so\.[0-9]*).*/\1/'`
+ link2="libSDL2.so"
+ else
+ cp sdl/build/.libs/libSDL2-*.*.*.dylib lib
+ sdl=`ls lib`
+ link=`echo $sdl | sed -E 's/(-[0-9]*).*(\.dylib)/\1\2/'`
+ link2="libSDL2.dylib"
+ fi
cd lib
ln -s "$sdl" "$link"
- ln -s "$sdl" libSDL2.so
+ ln -s "$sdl" "$link2"
cd ..
cd glew
make all
cd ..
fi
-echo "Path is: $PATH"
+
+if [ $OS = "Win64" ]; then
+ OS_FLAGS="--host=x86_64-w64-mingw32 --disable-pthreads"
+else
+ OS_FLAGS=""
+fi
+
+cd curl
+./configure \
+ --enable-static --disable-shared --without-ssl \
+ --without-libpsl --without-zstd --without-brotli \
+ --without-libidn2 --without-librtmp \
+ --without-zlib --without-nghttp2 --disable-ldap $OS_FLAGS
+make -C lib
+cd ..
+
if [ $OS = "Win64" ]; then
make PORTABLE=1 OS=Windows CPU=x86_64 clean all
SDLDLLPATH=sdl/x86_64-w64-mingw32/bin
@@ -32,53 +56,20 @@ else
make PORTABLE=1 clean all
SDLDLLPATH=sdl/i686-w64-mingw32/bin
fi
-make menu.bin tmss.md
-if [ $OS = "Windows" -o $OS = "Win64" ]; then
+
+if [ $OS = "Win64" ]; then
binaries="dis.exe zdis.exe vgmplay.exe blastem.exe $SDLDLLPATH/SDL2.dll"
- verstr=`sed -E -n 's/^[^B]+BLASTEM_VERSION "([^"]+)"/blastem \1/p' blastem.c`
- txt=".txt"
else
- binaries="dis zdis vgmplay blastem termhelper"
- if [ $OS = "Darwin" ]; then
- binaries="$binaries Frameworks"
- else
- binaries="$binaries lib"
- fi
- verstr=`./blastem -v`
- txt=""
-fi
-binaries="$binaries menu.bin tmss.md"
-ver=`echo $verstr | awk '/blastem/ { gsub(/\r/, "", $2); print $2 }'`
-if [ $OS = "Windows" ]; then
- suffix='-win32'
-elif [ $OS = "Win64" ]; then
- suffix='-win64'
-elif [ $OS = "Darwin" ]; then
- suffix='-osx'
-else
- suffix=`file ./blastem | sed -E 's/^[^:]*: [^ ]* ([0-9]*)-bit .*/\1/'`
+ binaries="dis zdis vgmplay blastem termhelper lib"
fi
-dir="blastem${suffix}-${ver}"
-echo $dir
+
+dir="blastem-0.6.2-kinetoscope"
rm -rf "$dir"
mkdir "$dir"
+
cp -r $binaries shaders images default.cfg rom.db gamecontrollerdb.txt systems.cfg "$dir"
for file in README COPYING CHANGELOG; do
- cp "$file" "$dir"/"$file$txt"
+ cp "$file" "$dir"/"$file".txt
done
-if [ $OS = "Darwin" ]; then
- cp SDL-LICENSE "$dir"
-else
- cp sdl/COPYING.txt "$dir"/SDL-LICENSE$txt
-fi
-cp glew/LICENSE.txt "$dir"/GLEW-LICENSE$txt
-
-if [ $OS = "Windows" -o $OS = "Win64" ]; then
- rm -f "${dir}.zip"
- zip -r "${dir}.zip" "$dir"
- echo "${dir}.zip"
-else
- rm -f "${dir}.tar.gz"
- tar -cvzf "${dir}.tar.gz" "$dir"
- echo "${dir}.tar.gz"
-fi
+cp sdl/LICENSE.txt "$dir"/SDL-LICENSE.txt
+cp glew/LICENSE.txt "$dir"/GLEW-LICENSE.txt
diff --git a/gdb_remote.c b/gdb_remote.c
index 9dbfce4..2effc89 100644
--- a/gdb_remote.c
+++ b/gdb_remote.c
@@ -582,6 +582,6 @@ void gdb_remote_init(void)
}
socket_close(listen_sock);
#else
- disable_stdout_messages();
+ //disable_stdout_messages();
#endif
}
diff --git a/img2tiles.py b/img2tiles.py
index c91273c..f637add 100755
--- a/img2tiles.py
+++ b/img2tiles.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
from PIL import Image
def gchannel(Val):
diff --git a/romdb.c b/romdb.c
index 79afa76..b5e7c9a 100644
--- a/romdb.c
+++ b/romdb.c
@@ -14,6 +14,7 @@
#include "megawifi.h"
#include "jcart.h"
#include "blastem.h"
+#include "kinetoscope/emulator-patches/kinetoscope.h"
#define DOM_TITLE_START 0x120
#define DOM_TITLE_END 0x150
@@ -338,6 +339,45 @@ void add_memmap_header(rom_info *info, uint8_t *rom, uint32_t size, memmap_chunk
warning("ROM uses MegaWiFi, but it is disabled\n");
}
return;
+ } else if(!memcmp("SEGA KINETOSCOPE", rom + 0x100, strlen("SEGA KINETOSCOPE"))) {
+ info->mapper_type = MAPPER_NONE;
+ info->map_chunks = base_chunks + 3;
+ info->map = malloc(sizeof(memmap_chunk) * info->map_chunks);
+ memset(info->map, 0, sizeof(memmap_chunk)*3);
+ memcpy(info->map+3, base_map, sizeof(memmap_chunk) * base_chunks);
+
+ info->map[0].start = 0x200000;
+ info->map[0].end = 0x400000;
+ info->map[0].mask = 0x1FFFFF;
+ info->map[0].flags = MMAP_READ;
+ // Returns the address of the buffer that emulates the SRAM banks (2MB).
+ info->map[0].buffer = kinetoscope_init();
+
+ // In hardware, this whole range will trigger the /TIME signal.
+ info->map[1].start = 0xA13000;
+ info->map[1].end = 0xA13100;
+ // In our hardware, we use A1-A3 to address various special ports. A0 (low
+ // byte / high byte) doesn't exist in the cartridge interface. But we
+ // effectively respond to changes in the bottom 5 bits.
+ // Therefore our port address is 0xA13000 and the mask is 0x01F.
+ // In real hardware, the range would wrap around and 0x...00, 0x...20,
+ // 0x...40, ... would all map to the same port.
+ info->map[1].mask = 0x00001F;
+
+ info->map[1].write_16 = kinetoscope_write_16;
+ info->map[1].write_8 = kinetoscope_write_8;
+ info->map[1].read_16 = kinetoscope_read_16;
+ info->map[1].read_8 = kinetoscope_read_8;
+
+ info->map[2].start = 0x000000;
+ info->map[2].end = 0x200000;
+ if (rom_end < info->map[2].end) {
+ info->map[2].end = rom_end;
+ }
+ info->map[2].mask = 0x1FFFFF;
+ info->map[2].flags = MMAP_READ;
+ info->map[2].buffer = rom;
+ return;
} else if (has_ram_header(rom, size)) {
uint32_t ram_start = read_ram_header(info, rom);
diff --git a/zlib/gzguts.h b/zlib/gzguts.h
index 990a4d2..db6ee72 100644
--- a/zlib/gzguts.h
+++ b/zlib/gzguts.h
@@ -3,6 +3,17 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
+#if defined(__MINGW32__)
+# include <wchar.h> // _wopen
+# include <sys/types.h>
+# include <unistd.h>
+int open(const char *pathname, int flags, mode_t mode);
+off_t lseek(int fd, off_t offset, int whence);
+ssize_t read(int fd, void *buf, size_t count);
+ssize_t write(int fd, const void *buf, size_t count);
+int close(int fd);
+#endif
+
#ifdef _LARGEFILE64_SOURCE
# ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1