Touhou Wiki
Advertisement

This guide aims to help you get Touhou Project shmups running in Linux. It might help with other Japanese software, too. Who knows?


Introduction

You may not need to follow any of these instructions. Maybe you're one of those lucky few with hardware l33t enough to run Imperishable Night at full speed in windowed mode using unmodified Cedega or even plain Wine!

For the test system, however, following these steps brought the framerate up from an average of 8 FPS to a full 60 FPS with an added bonus of getting rid of many visual glitches. Speaking of the test system, its relevant specs are as follows:

  • Pentium III 1.0 Ghz
  • GeForce FX 5200
  • Arch Linux
  • Kernel 2.6.11.7
  • Cedega from CVS, cedega-4-3 branch
  • X.Org 6.8.2
  • nVidia driver version 1.0-7174
  • driver version 1.0-7664 will not work
  • en_US.UTF-8 system locale
  • ja_JP locale for running games


Caveats and Cautions

Before you begin, back up your score.dat. If something breaks, score.dat will die first! Don't let it happen to you!

This guide assumes that you already have a working install of the games you intend to play. I had trouble installing them in Linux, so I installed them on another computer running Windows 2000 (Japanese default locale) and copied their directories over Samba.

On the test system, Imperishable Night and Phantasmagoria of Flower View worked with an unmodified Cedega. Horribly slowly and with many visual glitches, but it worked. If it doesn't work for you (crashes when trying to display Japanese text, freezes when loading a stage, etc.), then it may still not work even after following all the instructions below.

Don't allow a game to be interrupted as it loads. Imperishable Night, in particular, writes to score.dat as it is loading, so interrupting the loading process will probably be fatal to your score.dat file.

Getting Cedega (winex) from CVS

Type the following commands into a console. Everything that isn't separated by a blank line should be on the same line.

cvs -d:pserver:cvs@cvs.transgaming.org:/cvsroot login
Password: cvs
cvs -z3 -d:pserver:cvs@cvs.transgaming.org:/cvsroot 
checkout -r <BRANCH> winex

Replace <BRANCH> with the name of one of the branches selectable from the combobox at the bottom of Cedega's ViewCVS page.


Anticipation of Unifying Compile

cd into the winex directory.

configure flags

There's a script in ./tools/wineinstall that will handle configuration, compilation, and installation in one step... if you didn't need to change anything. Which you do. Find the line in the script that says:

CONFARGS="--enable-opengl"

and change it to something like:

CONFARGS="--prefix=/usr/local/cedega-cvs --enable-pthreads
--enable-opengl"

Whether you need to put --enable-pthreads or not varies between Linux distros. You could try leaving it out... If Wine fails to start with a message like "wine: exists lstat socket : No such file or directory", then you need to include --enable-pthreads.

The --prefix is also optional, but I don't know where it'll install if you leave it out. If you choose to use a different prefix path for whatever reason, remember to use your own path instead of /usr/local/cedega-cvs as you follow steps later in the guide.

Japanese locale

The Japanese locale file included with Cedega is quite out of date (to the point of displaying Japanese characters as blank squares), so it'd be a good idea to snatch one from cvs.winehq.org and modify it to suit the older format suppoorted by Cedega. For your convenience, just copy and paste this into an empty text file:


LOCVAL(LOCALE_FONTSIGNATURE, L"¥x0283¥x8000¥x6cf8¥x38c7¥x0010¥x0000¥x0000¥x0000¥x0000¥x0002¥x0000¥x0000¥x0000¥x0002¥x0000¥x0000") LOCVAL(LOCALE_ICALENDARTYPE, "1") LOCVAL(LOCALE_ICENTURY, "1") LOCVAL(LOCALE_ICOUNTRY, "81") LOCVAL(LOCALE_ICURRDIGITS, "0") LOCVAL(LOCALE_ICURRENCY, "0") LOCVAL(LOCALE_IDATE, "2") LOCVAL(LOCALE_IDAYLZERO, "1") LOCVAL(LOCALE_IDEFAULTANSICODEPAGE, "932") LOCVAL(LOCALE_IDEFAULTCODEPAGE, "932") LOCVAL(LOCALE_IDEFAULTCOUNTRY, "81") LOCVAL(LOCALE_IDEFAULTEBCDICCODEPAGE, "20290") LOCVAL(LOCALE_IDEFAULTLANGUAGE, "0411") LOCVAL(LOCALE_IDEFAULTMACCODEPAGE, "10001") /*LOCVAL(LOCALE_IDEFAULTUNIXCODEPAGE, "20932")*/ LOCVAL(LOCALE_IDIGITS, "2") LOCVAL(LOCALE_IDIGITSUBSTITUTION, "1") LOCVAL(LOCALE_IFIRSTDAYOFWEEK, "6") LOCVAL(LOCALE_IFIRSTWEEKOFYEAR, "0") LOCVAL(LOCALE_IINTLCURRDIGITS, "2") LOCVAL(LOCALE_ILANGUAGE, "0411") LOCVAL(LOCALE_ILDATE, "2") LOCVAL(LOCALE_ILZERO, "1") LOCVAL(LOCALE_IMEASURE, "0") LOCVAL(LOCALE_IMONLZERO, "1") LOCVAL(LOCALE_INEGCURR, "1") LOCVAL(LOCALE_INEGNUMBER, "1") LOCVAL(LOCALE_INEGSEPBYSPACE, "0") LOCVAL(LOCALE_INEGSIGNPOSN, "3") LOCVAL(LOCALE_INEGSYMPRECEDES, "1") LOCVAL(LOCALE_IOPTIONALCALENDAR, "3") LOCVAL(LOCALE_IPAPERSIZE, "9") LOCVAL(LOCALE_IPOSSEPBYSPACE, "0") LOCVAL(LOCALE_IPOSSIGNPOSN, "3") LOCVAL(LOCALE_IPOSSYMPRECEDES, "1") LOCVAL(LOCALE_ITIME, "1") LOCVAL(LOCALE_ITIMEMARKPOSN, "0") LOCVAL(LOCALE_ITLZERO, "0") LOCVAL(LOCALE_S1159, "午前") LOCVAL(LOCALE_S2359, "午後") LOCVAL(LOCALE_SABBREVCTRYNAME, "JPN") LOCVAL(LOCALE_SABBREVDAYNAME1, "月") LOCVAL(LOCALE_SABBREVDAYNAME2, "火") LOCVAL(LOCALE_SABBREVDAYNAME3, "水") LOCVAL(LOCALE_SABBREVDAYNAME4, "木") LOCVAL(LOCALE_SABBREVDAYNAME5, "金") LOCVAL(LOCALE_SABBREVDAYNAME6, "土") LOCVAL(LOCALE_SABBREVDAYNAME7, "日") LOCVAL(LOCALE_SABBREVLANGNAME, "JPN") LOCVAL(LOCALE_SABBREVMONTHNAME1, "1") LOCVAL(LOCALE_SABBREVMONTHNAME2, "2") LOCVAL(LOCALE_SABBREVMONTHNAME3, "3") LOCVAL(LOCALE_SABBREVMONTHNAME4, "4") LOCVAL(LOCALE_SABBREVMONTHNAME5, "5") LOCVAL(LOCALE_SABBREVMONTHNAME6, "6") LOCVAL(LOCALE_SABBREVMONTHNAME7, "7") LOCVAL(LOCALE_SABBREVMONTHNAME8, "8") LOCVAL(LOCALE_SABBREVMONTHNAME9, "9") LOCVAL(LOCALE_SABBREVMONTHNAME10, "10") LOCVAL(LOCALE_SABBREVMONTHNAME11, "11") LOCVAL(LOCALE_SABBREVMONTHNAME12, "12") LOCVAL(LOCALE_SABBREVMONTHNAME13, "") LOCVAL(LOCALE_SCOUNTRY, "Japan") LOCVAL(LOCALE_SCURRENCY, L"¥x00a5") LOCVAL(LOCALE_SDATE, "/") LOCVAL(LOCALE_SDAYNAME1, "月曜日") LOCVAL(LOCALE_SDAYNAME2, "火曜日") LOCVAL(LOCALE_SDAYNAME3, "水曜日") LOCVAL(LOCALE_SDAYNAME4, "木曜日") LOCVAL(LOCALE_SDAYNAME5, "金曜日") LOCVAL(LOCALE_SDAYNAME6, "土曜日") LOCVAL(LOCALE_SDAYNAME7, "日曜日") LOCVAL(LOCALE_SDECIMAL, ".") LOCVAL(LOCALE_SENGCOUNTRY, "Japan") LOCVAL(LOCALE_SENGCURRNAME, "Japanese Yen") LOCVAL(LOCALE_SENGLANGUAGE, "Japanese") LOCVAL(LOCALE_SGROUPING, "3;0") LOCVAL(LOCALE_SINTLSYMBOL, "JPY") LOCVAL(LOCALE_SISO3166CTRYNAME, "JP") LOCVAL(LOCALE_SISO639LANGNAME, "ja") LOCVAL(LOCALE_SLANGUAGE, "Japanese") LOCVAL(LOCALE_SLIST, ",") LOCVAL(LOCALE_SLONGDATE, "yyyy'年'M'月'd'日'") LOCVAL(LOCALE_SMONDECIMALSEP, ".") LOCVAL(LOCALE_SMONGROUPING, "3;0") LOCVAL(LOCALE_SMONTHNAME1, "1月") LOCVAL(LOCALE_SMONTHNAME2, "2月") LOCVAL(LOCALE_SMONTHNAME3, "3月") LOCVAL(LOCALE_SMONTHNAME4, "4月") LOCVAL(LOCALE_SMONTHNAME5, "5月") LOCVAL(LOCALE_SMONTHNAME6, "6月") LOCVAL(LOCALE_SMONTHNAME7, "7月") LOCVAL(LOCALE_SMONTHNAME8, "8月") LOCVAL(LOCALE_SMONTHNAME9, "9月") LOCVAL(LOCALE_SMONTHNAME10, "10月") LOCVAL(LOCALE_SMONTHNAME11, "11月") LOCVAL(LOCALE_SMONTHNAME12, "12月") LOCVAL(LOCALE_SMONTHNAME13, "") LOCVAL(LOCALE_SMONTHOUSANDSEP, ",") LOCVAL(LOCALE_SNATIVECTRYNAME, "日本") LOCVAL(LOCALE_SNATIVECURRNAME, "円") LOCVAL(LOCALE_SNATIVEDIGITS, "0123456789") LOCVAL(LOCALE_SNATIVELANGNAME, "日本語") LOCVAL(LOCALE_SNEGATIVESIGN, "-") LOCVAL(LOCALE_SPOSITIVESIGN, "") LOCVAL(LOCALE_SSHORTDATE, "yyyy/MM/dd") LOCVAL(LOCALE_SSORTNAME, "XJIS") LOCVAL(LOCALE_STHOUSAND, ",") LOCVAL(LOCALE_STIME, ":") LOCVAL(LOCALE_STIMEFORMAT, "H:mm:ss") LOCVAL(LOCALE_SYEARMONTH, "yyyy'年'M'月'")


Save it in the winex directory as dlls/kernel/nls/jpn.nls . Ensure that the charset used for the file is sjis.

WINNLSEnableIME

Lots of Japanese software, including the Touhou series, try to call a function called WINNLSEnableIME() for no apparent reason. The call doesn't seem to serve any purpose, but programs won't start without it. We'll trick it into calling another function by modifying dlls/user/user32.spec . Add a line to it that says:

@ stdcall WINNLSEnableIME(long long) EnableWindow

Assembly of Bacchus Nectar

This would be the easiest step of the process were it not for the compile error I encountered. Your mileage may vary. Type this into the console:

./tools/wineinstall

With some luck, all will go well. If all does not go well and the compile process breaks on a file called ppl.l, make note of where that file is (there's two of them), open it up, and replace all commented-out instances of "]]" with "] ]".

Once you've done that, re-run ./tools/wineinstall . At the very end of the process, the script will ask whether you want to copy over a local config file. Respond however you like.


Eastern Form

wine config file

Some small changes need to be made to the default wine configuration file. There may or may not already be a copy of it in $HOME/.wine/config . If there isn't, copy it over from the source directory under documentation/samples/config .

There are many options in the config file you might want to tweak, but I'll just list the essentials. Modify each of the configuration entries under the appropriate sections, as follows:

[Version]
"Windows" = "win2000"
[x11drv]
; Include the next three lines if you don't want to run in
; full screen.
"Desktop" = "640x480"
"UseXVidMode" = "N"
"UseXRandR" = "N"
; Include the next line to use other windows while the
; game is running.
"DXGrab" = "N"
; VideoRam should be the same as the AGP Aperture Size
; setting in the BIOS.
"VideoRam" = "64"
; AGPVertexRam should be half the size of the AGP Aperture
; Size setting in the BIOS.
"AGPVertexRam" = "32"
[d3dgl]
"ClipSpaceFix" = "Y"
; Include the next three lines if your video card has
; hardware-accelerated vertex shaders
"VertexShaders" = "Y"
"VertexShaderMode" = "Hardware"
"FixedProgram" = "No"
[fonts]
"FreeType" = "N"

Environment variables

Some environment variables need to be set before wine can be expected to run properly. For your convenience, put them all in a shell script:

#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/cedega-cvs/lib:/usr/local/cedega-cvs/bin:
export PATH=/usr/local/cedega-cvs/bin:$PATH
export REGAPI=/usr/local/cedega-cvs/bin/regapi
export WINEDBG=/usr/local/cedega-cvs/bin/winedbg
export WINELOADER=/usr/local/cedega-cvs/bin/wine
export WINEPREFIX=$HOME/.wine
export WINESHELLLINK=/usr/local/cedega-cvs/bin/wineshelllink

Put the script somewhere in your path. /usr/bin/cedega-cvs-env should be fine. In the future, before running Cedega, run it in the current shell (note the period at the beginning):

. cedega-cvs-env

Now, we are finally ready to try running something.


Eastern Wonderland

cd into a directory in which one of the Touhou shmups is installed and type this into a console:

. cedega-cvs-env
LANG=ja_JP wine --use-dos-cwd . custom.exe

If you see ugly squares instead of Japanese text, something's not right. Your guess is as good as mine as to what exactly isn't right. If you don't mind the garbled text, you could try running the games anyway, but they may not work perfectly.

Ensure that the game is set to run in Full Screen (フルスクリーン) mode. Windowed (ウィンドウ) mode is slow and full of many visual glitches. If you followed the config file guidelines outlined above, it should be easy to toggle between actually running the game in full screen or running it in a window that it thinks is the full screen. :) Comment/uncomment Desktop, UseXVidMode, and UseXRandR as you please.

To run the game, use a command line similar to this one:

LANG=ja_JP wine --debugmsg -all --use-dos-cwd . th08.exe

Now you hopefully have something not entirely dissimilar to a working game that doesn't crash, freeze, or otherwise bug out for no reason.

Advertisement