Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alcaro committed Jul 31, 2023
0 parents commit eaff369
Show file tree
Hide file tree
Showing 21 changed files with 14,055 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Glorious-Eggroll/
mk/
gstkrkr-i386.so
gstkrkr-x86_64.so
krkrwine-i386.dll
krkrwine-x86_64.dll
run32.exe
run64.exe
*.wmv
*.WMV
*.mpg
*.mpeg
130 changes: 130 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# SPDX-License-Identifier: LGPL-2.0-or-later

FLAGS := -Wall
ifeq ($(OPT),1)
FLAGS := -Os -s -g0 -fno-rtti -Wall
endif

all: gstkrkr-x86_64.so gstkrkr-i386.so krkrwine-x86_64.dll krkrwine-i386.dll

clean:
-rm gstkrkr-x86_64.so gstkrkr-i386.so krkrwine-x86_64.dll krkrwine-i386.dll
-rm run32.exe run64.exe krmovie.dll

MINGW32 = i686-w64-mingw32-g++-win32 -std=c++20 -fno-exceptions -gdwarf-4 -static-libgcc -static-libstdc++ $(FLAGS)
MINGW64 = x86_64-w64-mingw32-g++-win32 -std=c++20 -fno-exceptions -gdwarf-4 -static-libgcc -static-libstdc++ $(FLAGS)

gstkrkr-x86_64.so: gstkrkr.c Makefile
gcc gstkrkr.c -shared -fPIC -std=c99 -DPLUGINARCH=x86_64 -o gstkrkr-x86_64.so -g $(shell pkg-config --cflags --libs gstreamer-1.0) -fvisibility=hidden -Wl,--no-undefined $(FLAGS)

# must use -std=c##, the default (gnu##) predefines the symbol i386
gstkrkr-i386.so: gstkrkr.c Makefile
gcc -m32 gstkrkr.c -shared -fPIC -std=c99 -DPLUGINARCH=i386 -o gstkrkr-i386.so $(shell pkg-config --personality=i386-linux-gnu --cflags --libs gstreamer-1.0) -fvisibility=hidden -Wl,--no-undefined $(FLAGS)

krkrwine-x86_64.dll: krkrwine.cpp Makefile
$(MINGW64) krkrwine.cpp -shared -fPIC -o krkrwine-x86_64.dll -lole32

krkrwine-i386.dll: krkrwine.cpp Makefile
$(MINGW32) krkrwine.cpp -shared -fPIC -o krkrwine-i386.dll -lole32

prepare:
cp $(EGGROLL)/files/lib64/gstreamer-1.0/libgstmpegpsdemux.so Glorious-Eggroll/x86_64-libgstmpegpsdemux.so
cp $(EGGROLL)/files/lib64/gstreamer-1.0/libgstasf.so Glorious-Eggroll/x86_64-libgstasf.so
cp $(EGGROLL)/files/lib64/libgstcodecparsers-1.0.so.0 Glorious-Eggroll/x86_64-libgstcodecparsers-1.0.so.0
cp $(EGGROLL)/files/lib64/libavcodec.so.58 Glorious-Eggroll/x86_64-libavcodec.so.58
cp $(EGGROLL)/files/lib64/libavutil.so.56 Glorious-Eggroll/x86_64-libavutil.so.56
cp $(EGGROLL)/files/lib64/libavfilter.so.7 Glorious-Eggroll/x86_64-libavfilter.so.7
cp $(EGGROLL)/files/lib64/libavformat.so.58 Glorious-Eggroll/x86_64-libavformat.so.58
cp $(EGGROLL)/files/lib64/libavdevice.so.58 Glorious-Eggroll/x86_64-libavdevice.so.58
cp $(EGGROLL)/files/lib64/libswresample.so.3 Glorious-Eggroll/x86_64-libswresample.so.3
cp $(EGGROLL)/files/lib64/libswscale.so.5 Glorious-Eggroll/x86_64-libswscale.so.5
cp $(EGGROLL)/files/lib/gstreamer-1.0/libgstmpegpsdemux.so Glorious-Eggroll/i386-libgstmpegpsdemux.so
cp $(EGGROLL)/files/lib/gstreamer-1.0/libgstasf.so Glorious-Eggroll/i386-libgstasf.so
cp $(EGGROLL)/files/lib/libgstcodecparsers-1.0.so.0 Glorious-Eggroll/i386-libgstcodecparsers-1.0.so.0
cp $(EGGROLL)/files/lib/libavcodec.so.58 Glorious-Eggroll/i386-libavcodec.so.58
cp $(EGGROLL)/files/lib/libavutil.so.56 Glorious-Eggroll/i386-libavutil.so.56
cp $(EGGROLL)/files/lib/libavfilter.so.7 Glorious-Eggroll/i386-libavfilter.so.7
cp $(EGGROLL)/files/lib/libavformat.so.58 Glorious-Eggroll/i386-libavformat.so.58
cp $(EGGROLL)/files/lib/libavdevice.so.58 Glorious-Eggroll/i386-libavdevice.so.58
cp $(EGGROLL)/files/lib/libswresample.so.3 Glorious-Eggroll/i386-libswresample.so.3
cp $(EGGROLL)/files/lib/libswscale.so.5 Glorious-Eggroll/i386-libswscale.so.5


krkrwine.tar.gz: | Glorious-Eggroll/x86_64-libgstmpegpsdemux.so
$(MAKE) clean
$(MAKE) OPT=1
-rm krkrwine.tar.gz
tar -czvf krkrwine.tar.gz --transform='s%^%krkrwine/%' --show-transformed-names README.md install.py gstkrkr-i386.so gstkrkr-x86_64.so krkrwine-i386.dll krkrwine-x86_64.dll Glorious-Eggroll/


# The following is various debug tools. If you're just trying to compile krkrwine, you don't need them;
# if you're trying to debug or patch this program, you may find some of them useful. (Some of them are hardcoded for my own use.)

run32.exe: runner.cpp Makefile
$(MINGW32) runner.cpp -o run32.exe -lole32 -ld3d9

run64.exe: runner.cpp Makefile
$(MINGW64) runner.cpp -o run64.exe -lole32 -ld3d9 -lgdi32

run: krkrwine-x86_64.dll gstkrkr-x86_64.so run64.exe
GST_DEBUG_NO_COLOR=1 WINEDEBUG=+warn,+error,+fixme timeout 10 wine run64.exe 2>&1 | guidfilt

run32: krkrwine-i386.dll gstkrkr-i386.so run32.exe
GST_DEBUG_NO_COLOR=1 timeout 10 wine run32.exe 2>&1 | guidfilt

runv: krkrwine-x86_64.dll gstkrkr-x86_64.so run64.exe
GST_DEBUG_NO_COLOR=1 GST_DEBUG=6 WINEDEBUG=trace+quartz,warn+quartz timeout 10 wine run64.exe 2>&1 | guidfilt | head -n2000 | tee e.log

mk/microkiri.exe:
echo 'Download and extract microkiri from https://bugs.winehq.org/show_bug.cgi?id=9127#c102 to the mk/ subdirectory'
mkdir mk
false
mk/_rmovie.dll: mk/microkiri.exe
mv mk/krmovie.dll mk/_rmovie.dll
krmovie.dll: fake-krmovie.cpp Makefile
$(MINGW32) fake-krmovie.cpp -shared -fPIC -o krmovie.dll -lole32 -ld3d9
rmk: krmovie.dll krkrwine-i386.dll mk/_rmovie.dll
-rm mk/krmovie.dll
cp krmovie.dll mk/krmovie.dll
LC_ALL=ja_JP wine mk/microkiri.exe

rmkd: krmovie.dll krkrwine-i386.dll mk/_rmovie.dll
-rm mk/krmovie.dll
cp krmovie.dll mk/krmovie.dll
LC_ALL=ja_JP wine ~/tools/mingw64-11.2.0/bin/gdb.exe -ex "set disassemble-next-line on" -ex "set disassembly-flavor intel" mk/microkiri.exe

rwa: krkrwine-i386.dll gstkrkr-i386.so krmovie.dll
LC_ALL=ja_JP wine /games/wine/waga/waga/waga.exe
rwas: krkrwine-i386.dll gstkrkr-i386.so krmovie.dll
LC_ALL=ja_JP timeout 7 wine /games/wine/waga/waga/waga.exe

wau:
mv /games/wine/waga/waga/plugin/_rmovie.dll /games/wine/waga/waga/plugin/krmovie.dll
wai:
mv -n /games/wine/waga/waga/plugin/krmovie.dll /games/wine/waga/waga/plugin/_rmovie.dll
ln -s $(shell realpath .)/krmovie.dll /games/wine/waga/waga/plugin/krmovie.dll

X1_HOME = /home/walrus/mount/x1/home/x1/
X1_PROTON = $(X1_HOME)steam/steamapps/common/"Proton 8.0"/
X1_PFX = $(X1_PROTON)dist/share/default_pfx/
X1_DLL = $(X1_PFX)drive_c/windows/syswow64/krkrwine.dll
X1_EXE = $(X1_HOME)Desktop/a.exe
X1_GST = $(X1_PROTON)dist/lib/gstreamer-1.0/gstkrkr-i386.so
ax1: run32.exe krkrwine-i386.dll gstkrkr-i386.so
-rm $(X1_DLL) $(X1_EXE) $(X1_GST)
cp krkrwine-i386.dll $(X1_DLL)
cp run32.exe $(X1_EXE)
cp gstkrkr-i386.so $(X1_GST)

installx1: all
./install.py $(X1_PROTON)

installx2: all
./install.py /home/walrus/mount/x2/home/x2/steam/steamapps/common/"Proton 8.0"/

X2_WAGAPATH = /home/walrus/mount/x2/home/x2/steam/steamapps/common/"WAGAMAMA HIGH SPEC"
waux2:
mv $(X2_WAGAPATH)/plugin/_rmovie.dll $(X2_WAGAPATH)/plugin/krmovie.dll
waix2: krmovie.dll
mv -n $(X2_WAGAPATH)/plugin/krmovie.dll $(X2_WAGAPATH)/plugin/_rmovie.dll
cp krmovie.dll $(X2_WAGAPATH)/plugin/krmovie.dll
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
krkrwine
========

This program implements various missing functionality in Wine / Proton, such that videos work properly in Kirikiri-based visual novels. (Other games are not targetted by krkrwine, but they may be improved as well.)

Installation - Linux/Proton
---------------------------

Simply run ./install.py ~/steam/steamapps/common/Proton\ 8.0/, and it will install into every current and future game using that Proton. Installing krkrwine into Glorious Eggroll should work too, though this is untested.

krkrwine does not replace any existing files, and Steam's updater ignores files it doesn't recognize; therefore, you don't need to reinstall krkrwine if Proton updates. (However, if you reinstall Proton, or download a new Proton version, you obviously need to reinstall krkrwine too.)

krkrwine is only tested in Proton 8.0; I don't think it'll break too hard in anything else, but it's untested.

Installation - Linux/Wine
-------------------------

On Debian,

- sudo apt install gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-plugins-good:i386 gstreamer1.0-plugins-bad:i386 gstreamer1.0-plugins-ugly:i386 gstreamer1.0-libav:i386
- ./install.py --wine

On other distros, the package names are different.

Note that on Debian, gstreamer1.0-libav is not part of, or a dependency of, gstreamer1.0-plugins-good, -bad, nor -ugly; it must be installed separately. I haven't checked other distros.

install.py will obey the WINEPREFIX environment variable, if set.

gstkrkr will not be installed; it does nothing useful if you have the above plugins and don't have protonmediaconverter. If you want them anyways for development purposes, you can copy or link them to ~/.local/share/gstreamer-1.0/plugins/.

Installation - macOS
--------------------

See the Linux/Wine steps, it'll probably work. However, it's untested, and I can't help you if it breaks.

Installation - Windows
----------------------

Don't. All relevant functionality is already in place on every Windows edition I'm aware of, and some parts of this program depend on Wine internals that are different on Windows.

Compilation
-----------

- Download and extract your favorite release of Glorious Eggroll (I use 8.4; no real reason, I just picked one)
- sudo apt install make gcc libgstreamer1.0-dev gcc-multilib libgstreamer1.0-dev:i386 g++-mingw-w64-i686-win32 g++-mingw-w64-x86-64-win32
- make prepare EGGROLL=/home/user/steam/compatibilitytools.d/GE-Proton8-4/
- make
- ./install.py /home/user/steam/steamapps/common/Proton\ 8.0/
If desired, you may acquire i686-w64-mingw32-g++-win32 and x86_64-w64-mingw32-g++-win32 programs from elsewhere. I use https://winlibs.com/ in Wine.

License
-------

krkrwine itself is LGPL-2.0, same as Wine and GStreamer. Some test programs are GPL-2.0, since they contain code copied from Kirikiri.

The Glorious-Eggroll subdirectory of the releases is, as the name implies, copied from a Glorious Eggroll release. They're either LGPL-2.0 or GPL-2.0, depending on how they were compiled; I didn't check.

Upstreaming
-----------

Ideally, this project would be unnecessary. As such, I'm offering bounties on fixing the Windows-side issues in upstream Wine.

- $250 - CLSID_MPEG1Splitter video output, and CLSID_CMpegVideoCodec (these objects may use GStreamer, of course)
- $25 - CLSID_MPEG1Splitter IAMStreamSelect (doesn't need to be fully implemented, just needs the parts Kirikiri uses)
- $25 - CLSID_VideoMixingRenderer9 ChangeD3DDevice and NotifyEvent
- $500 - WMCreateSyncReader compressed output, CLSID_CWMADecMediaObject, and CLSID_CWMVDecMediaObject
- $100 - Direct3D 9 on WS_CHILD windows under wined3d
- $25 - make WMSyncReader resize its allocator, so it can output RGB32 properly
- $100 - figure out what's going on with the memory allocator and VFW_E_NOT_COMMITTED, and solve it
- $0 - anything involving gstkrkr and Proton's GStreamer. That's a patent issue; it's a question for lawyers, not programmers. It's only needed in Proton, not vanilla Wine.
- Anything that Kirikiri needs but isn't in the above list - that's a bug in this readme, contact me

I can't do it myself; I've debugged some things too hard, and have single-stepped and disassembled Windows DLLs.

You are allowed, but not required, to base such efforts on this project. My architecture is very different from Wine's existing objects, and many of them are implemented in an awful way, so most of my code is unusable; but you're welcome to look for hints on the objects' expected behavior, or otherwise use them to help implement yours. You may also use the Kirikiri source code, <https://github.com/krkrz/krkr2/tree/master/kirikiri2/trunk>

To claim a bounty, post at <https://github.com/Alcaro/krkrwine/discussions/1>, or email me at [email protected]. These bounties can be combined with similar offers made by others.

If I see any of the above implemented, but nobody claims the bounty, I will donate it to Wine.
Loading

0 comments on commit eaff369

Please sign in to comment.