WINE and CDemu


Previously I posted about installing software/game with different CD/DVD ISO images in WINE. But this method does not work in some installation ISO images. Because these installation will detect for the CD/DVD. The method above does not solve the problem because the installation does not detect the CD/DVD.

Recently, I found a better solution. It is CDemu. It is similar to DAEMON Tools in Windows. It will emulate the optical disc drive in Linux. As a result, it will produce /dev/sr0, /dev/sr1, and so on. Because it is a virtual CD/DVD, thus we have to load the image. It can be easily loaded by using gcdemu.

Once the image file is loaded, we have to mount the image as root. I mount the image to /mnt/cdrom. Then, in WINE, run the winecfg, then it will automatically appear the CD-ROM in Drives tab. In my case, it is E: drive.

Now, I run the installation from WINE, I can detect the image as CD/DVD.

Advertisements

Traditional Chinese (BIG5) in the LANG=zh_CN.UTF8 locale


Recently, I tried to play Tecmo Koei Sangokushi 12 PK Traditional Chinese version (三國志12威力加強版繁體中文) on WINE using PlayOnLinux. It works fine, but there is a problem that is the game can only be run in LANG=zh_CN.UTF-8 locale instead of zh_TW.UTF-8 locale (there are some reasons behind). As a result, if I enter some Chinese characters using fcitx, the output will be converted. Such as 一 becomes 珨. This is because when using fcitx in the zh_CN.UTF-8 locale, the character will be encoded as zh_CN.UTF-8. However, because the game itself is Traditional Chinese, the output will be encoded as possibly BIG5. This can be proved by using iconv with the following command,

echo "一" |iconv -f utf8 -t gb18030|iconv -f big5 -t utf8 #results 珨

Therefore, I need to convert this faulty character back to the character I intended. Thus, the iconv can be used to reverse the result by following command,

echo "珨" |iconv -f utf8 -t big5|iconv -f gb18030 -t utf8 #results 一

Because the game does not allow copy-paste, I can only solve this problem programmatically by creating a(n) fcitx module with the iconv. The module is available here.

The fcitx module I created works partially satisfying. It still has a problem which I cannot solve. I am not sure what is the root problem, either iconv, fcitx, WINE, the game itself, or other reason. That is, some of the Chinese characters such as 自 and 何 are not able to be entered and result question marks (?). (This is solved, read UPDATE below.)

Note: In order to use the module, that is to convert the GB18030 to BIG5 (yet still UTF8), because BIG5 is Traditional Chinese, that means we need to enable the “Simplified Chinese To Traditional Chinese” module in fcitx. Then only input the Traditional Chinese characters will work. Such as entering 會 instead of 会. Because BIG5 does not have the character for 会, but 會.

Sangokushi 12 PK Traditional Chinese in WINE problem with zh_CN.UTF-8 locale
Sangokushi 12 PK Traditional Chinese in WINE problem with zh_CN.UTF-8 locale

Because of the question mark problem as mentioned above, I can only give up playing the game with WINE. There is no choice but only to play the game with Windows in the VirtualBox which works fine in the Chinese (Taiwan) locale.

Update (2014-06-18): With the latest version of Wine 1.7.20 and fcitx 4.2.8, after using the module, all the words can be encoded as BIG5.

All about WINE (emulator)


I always thought that Wine (or WINE, WINE Is Not an Emulator) is good enough for me to play Windows games and running Windows applications without using the virtualisation such as VirtualBox. However, this is not completed.

Recently, due to a giveaway from CodeWeavers, I downloaded and tried the CrossOver. Then I found the comparison of Wine and CrossOver, CrossOver contains some proprietary components, which makes Windows applications run smoother than Wine. I tried, yes, there are some differences. But I am still using Wine because of my own favour.

WINEPREFIX (or bottle?)

When using Wine, we can always define different WINEPREFIX to install or run the applications separately. WINEPREFIX can be defined as the path of virtual Windows drive. We can create many virtual Windows drives with different WINEPREFIX. For example, I have two applications, namely A and B. Because Wine sometimes does not work perfectly with one setting for all the applications. Thus, I need to use different WINEPREFIX for application A, and another WINEPREFIX with different setting for application B. In CrossOver, the WINEPREFIX is called “bottle”, thus it make sense that we put different “wine” into different “bottles”.

Winetricks

To make some tricks or tweaks to our WINEPREFIX (or virtual Windows drive), winetricks is a powerful tool. We can use it to install all the fonts we need, make the changes in the registry, install some applications, install some Windows components such as DirectX, video codecs, etc. The downloaded installation files are cached in ~/.cache/winetricks, they can be re-used. This is normally what I did, using default WINEPREFIX which is ~/.wine, and installing all the important components using winetricks.

WineGame

However, this is not the whole story. Recently, because I installed Evernote, then I want to re-install, so I uninstalled it. However, when I tried to re-install, it failed. The solution from the internet suggested that to remove the WINEPREFIX, and create new one. Because most of my applications are installed in the same WINEPREFIX, removing it means that I need to re-install all the other applications. Hence, I tried WineGame, which was installed in my computer.

I know how to use command-line to run the WINEPREFIX. But using different WINEPREFIX, meaning that I need to run the application with command-line every time. Thus, I chose WineGame as it is described as the front-end for Wine. Meaning that, we can create the shortcut to run the applications without using command-line.

WineGame has some predefined settings for the games such as StarCraft, WarCraft, Civilization, etc. However, because I tried WineGame recently, I found that its package repository is dead. As a result, WineGame is good for nothing. Since I installed WineGame long time ago, that is why I obtained the packages information for me to run WineGame properly. Actually, we can create our package information manually, using some files such as “control”, “.name”, “.note”, etc.

If you don’t get it, nevermind, there is alternative solution for the front-end of Wine.

Q4Wine

Because WineGame doesn’t work well, and the project has no update since 2010, so, I assumed that the project is inactive. There is an alternative, called Q4Wine. Actually both Q4Wine and WineGame are using winetricks. As a result, the downloaded installation files can be re-used. Unlike WineGame, Q4Wine does not provide any package repository. However, it works super well for managing the WINEPREFIX.

Still, WineGame has a strength which Q4Wine does not have. WineGame allows the user to use different versions of Wine to run the applications. This is something very interesting. Besides the “bottle”, the “wine” is also different. Why? This is because, Wine is a very strange project. The newer version of Wine, might not work better than older version of Wine in some of the applications. For example, this game in the WineHQ AppDB. Read the test results, the rating changed from Gold to Garbage, finally to Bronze. So, this is the advantage of WineGame to let you install different versions of Wine. However, the project is inactive, thus you cannot get the later versions of Wine.

Nevermind, there is a better solution.

PlayOnLinux

Here it comes, PlayOnLinux. I installed it before, but I never use it. Because I didn’t know the reason for such project exists. Because I thought Wine is sufficient for everything. Even I want to manage my WINEPREFIX, I can use any front-end application.

PlayOnLinux offers more things. Not only front-end, but also allows you to download different versions of Wine. The different versions includes the patched version, such as vertex blending version. And if you have compiled your own version of Wine, you can just  symbolic link or copy to ~/.PlayOnLinux/wine/linux-x86. PlayOnLinux allows to use your own custom Wine.

Though PlayOnLinux is wonderful, not all the versions of Wine are available, for example, I cannot get the Wine version 1.2 patched with vertex blending. As a result, I need to build the patched version by my own and put it into PlayOnLinux to use it.

PlayOnLinux has another different feature from Q4Wine or WineGame. The installation of the application done by PlayOnLinux will not create desktop entries into the X11 menu. This is because it disables the WINEDLLOVERRIDES. As a result, to run the applications, we must run from PlayOnLinux. But PlayOnLinux allows you to create shortcut to the desktop.

 

So, this is actually how Wine works. Choose your best bottle with your best wine to run your applications without flaw.

Installing games with CD iso images and change disc in WINE


Previously I mentioned about playing games in WINE and enabling Ibus input and CJK fonts. Recently, I solved another problem, that is installing the game with ISO images.

We know that, in Linux, we can mount the ISO image easily. However, some old games will need to install with several discs, that means we need to change discs during the installation. When my disc 1 was completed, I tried to unmount, it failed. Even I tried with symlink, the disc 2 with the symlink is not detected by the installer, failed also.

The solution is actually simple.

  1. Firstly, run the winecfg.
  2. Go to Drives tab.
  3. Click Show Advanced button.
  4. Click Add…, for example, add a D: drive.
  5. Now, we can Browse… the path of our mounted ISO images.
  6. The important part is the Type:, we need to change to CD-ROM.
  7. Apply.

Now, in the WINE, there is a new CD-ROM drive. We can change the CD-ROM to any Linux file system path. So, mount the disc 1, run the installer.exe in the D:, complete disc 1, the installer will ask for disc 2. In the winecfg, change the D: path to mounted disc 2, apply. Go back to the installer, the disc 2 should be detected.

Enjoy the games.

(This is tested with SimCity 4 Deluxe.)

CJK fonts in Wine and also works with IBus input


CJK (Chinese, Japanese, Korean) fonts in Wine was really troublesome for me. Today, I have solved it totally. Before explaining the solution, just to say about the system environment I am using.

Arch Linux
wine 1.3.37
winetricks 20111115
ibus 1.4.0
ibus-pinyin 1.4.0
ibus-qt 1.3.1
ibus-table 1.3.9.20110827
ibus-table-extraphrase 1.3.9.20110827
ibus-table-wubi-git 20110410

Problem

I have installed all the fonts using winetricks with allfonts. I have also used winetricks to set fakechinese, fakejapanese, fakekorean. But none of these tricks work fine on my Wine.

Changing locale works fine, “env LANG=zh_CN.gbk wine notepad”. The menu is okay, but in some dialogs, some characters are still missing.

Wine notepad CJK problem
Wine notepad CJK problem

Solution

To solve it, make sure you have installed several fonts, from winetricks or from the package manager. I have installed allfonts from winetricks and other fonts using pacman. Wine is able to use external fonts.

In order to make the CJK fonts display properly, firstly, we need to know what type of system font is used in the different locale,

env LANG=zh_CN.gbk wine regedit

Then, we look into the “HKLM\Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink” to check what is the system font that is used in this locale.

(I just found that, for the newer version of Wine, mine is 1.5.6, there is no registry key as mentioned above. But we can still get the information in “HKLM\Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes“, look at the MS Shell Dlg.  It will show the font that used in the Windows Dialog.)

For my experience, I can see the following fonts in different locale

  • SimSun in zh_CN.gbk
  • PMingLiu in zh_TW.big5
  • MS UI Gothic in ja_JP.utf8
  • Lucida Sans Unicode, Tahoma, Microsoft Sans Serif.

Now, to make them work properly, we need to add the key “HKCU\Software\Wine\Fonts\Replacements” as mentioned here.

Then, add the string value with those system font name, such as SimSun, PMingLiu, MS UI Gothic.

For the data, we need to use the font name. The font name we can get from “HKCU\Software\Wine\Fonts\Cache”, see all the keys. We need to use the font name based on those key, not the “English Name”.

After setting this registry, we should able to read the fonts correctly.

My registry is

  • Lucida Sans Unicode = Lucida Console (external, get from ttf-mac-fonts)
  • Microsoft Sans Serif = MS Sans Serif (installed with wine)
  • MS UI Gothic = TakaoGothic (installed through winetricks)
  • PMingLiu = AR PL Ukai TW (external, get from ttf-arphic-ukai)
  • SimSun = AR PL Ukai CN (external, get from ttf-arphic-ukai)
  • Tahoma = Tahoma (installed through winetricks)

I am not sure does Tahoma setting is useless or not. But this setting works fine for me. Now, start the notepad with different locale, everything should work fine.

Now, after this setting, even the tray icon with CJK tooltip also works fine.

Wine Mini Thunder in system tray

IBus input method

I tried to play a game with traditional Chinese characters, namely Big5. In the game, I cannot input the Chinese characters with IBus input method. I asked in Wine Forum (here), but no one can answer me how to solve it. But today, after solving the CJK problem, I also manage to solve this IBus input problem.

Firstly, we must enable IBus to run properly, we must set the environment variables,

export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus

Some of the people mentioned that these environment variables can be  set in .xinitrc, .bashrc, or some other place. But in my case, they can only work in .xprofile.

The next thing, make sure ibus-daemon is started with “-x” or “–xim”.

ibus-daemon --xim

In my case, I just use the file “/etc/xdg/autostart/ibus.desktop”.

Now, the crucial part is Wine. If the locale is non-UTF8, then IBus will not work. Simply to say, IBus will work on UTF8 locale in Wine. Try it

env LANG=zh_TW.utf8 wine notepad

Now, we should able to enter any characters in notepad with IBus. Howevere, if it is zh_TW.big5 or zh_CN.gbk, IBus will not work.

Yes, this is the solution.

Wine game with IBus CJK input
Wine game with IBus CJK input

Playing games with Ubuntu


Linux is a great OS. Open source and free. Can work as server or desktop. There are a lot of applications: office suite, internet web browser, email client, image editor, 3D modeler, games, online games, software development tools, etc. Using Linux, I can almost do anything I want just as I am using proprietary OS.

However, there is a drawback. If a computer cannot be used for playing games, then it will not be 100% perfect. Yes, Linux has a lot of free and open source games, but I feel that there is still a gap between free games and the commercial games. Though I may not use Linux to play the latest game, at least it should allow me to play my favourite game.

Luckily there is WINE. Though it cannot 100% compatible to all the games, at least have a try. The following is a screenshot of my most favourite game!

Taikou Risshiden 5
Taikou Risshiden 5 using WINE