Showing posts with label visual novels. Show all posts
Showing posts with label visual novels. Show all posts

Thursday, 5 September 2013

PieceOfWonder has not been installed properly.

Faced this message after trying to run this old novel from an old hard drive without reinstalling. The original installer has been lost, what should I do?

First, let's locate the error message in the binary:
$ objdump -s PieceOfWonder.exe
...
5056c0 50696563 654f6657 6f6e6465 72206861  PieceOfWonder ha
5056d0 73206e6f 74206265 656e2069 6e737461  s not been insta
5056e0 6c6c6564 2070726f 7065726c 792e0000  lled properly...
...

Now let's see where the string is referred from:
$ objdump -d PieceOfWonder.exe |grep -C3 5056c0                              
  406ac6:       eb 09                   jmp    0x406ad1                                                            
  406ac8:       6a 00                   push   $0x0                                                                
  406aca:       6a 00                   push   $0x0                                                                
  406acc:       68 c0 56 50 00          push   $0x5056c0                                                           
  406ad1:       e8 21 46 0d 00          call   0x4db0f7                                                            
  406ad6:       8b 4c 24 08             mov    0x8(%esp),%ecx                                                      
  406ada:       33 c0                   xor    %eax,%eax        

Basic block that shows the error message starts from 406ac8, what calls it?

$ objdump -dF PieceOfWonder.exe | grep 4069f2
  4069f2:       0f 84 d0 00 00 00       je     0x406ac8 (File Offset: 0x6ac8)

So the panic routine is launched by the conditional jump at 4069f2.

Let's try replacing it with NOPs (NOP is a 1-byte instruction that does nothing, thus replacing a jump with them will prevent the program from showing the error dialog box and quitting) and see what it does:

WHOA.

In conclusion, in order to fix the problem, grab any hex editor, open the exe file in it, and replace bytes 69f2 through 69f7 with hexadecimal 90.
Example of what you should see before the edit:
000069f0: e800 0f84 d000 0000 480f 84be 0000 0048
And after:
000069f0: e800 9090 9090 9090 480f 84be 0000 0048

PS
Piece of Wonder does not look like the bane of visual novels so far. A lot of the art looks sketchy and rough, but the characters are certainly cute and the whole game had enough charm to make me want to come back to it. Oh, and it also has a great OP song.

PPS
Really surprised I managed to figure out the problem. And Pin was not needed. Still, a short summary on how to obtain an instruction trace of a program in Wine for future reference:
$ cd pin-2.12-58423-gcc.4.4.7-linux/source/tools/ManualExamples && make TARGET=ia32 # make itrace, must be the same arch as the instrumented program
$ winedbg PieceOfWonder.exe
$ .../pin-2.12-58423-gcc.4.4.7-linux/pin.sh -pid $(PoW_exe_pid) -t .../pin-2.12-58423-gcc.4.4.7-linux/source/tools/ManualExamples/obj-ia32/itrace.so
Wine-dbg>c

PPPS
Scratch itrace, DebugTrace *is* the PIN tool you want to use! Proper instruction + memory trace with value resolution, mmmm. To run it, do smth like ".../pin/pin -t .../pin/source/tools/DebugTrace/obj-ia32/debugtrace.dylib -instruction -i -memory -unique_logfile -flush -- ./my_binary"

Tuesday, 16 November 2010

No English text in Symphonic Rain

Note to self: don't forget to add (and probably modify first) SR.reg (located in the game's directory) to your registry before wondering why you cannot see any English text. Indeed, sometimes the issue may lie not in the "alternative" OS (works fine in Wine, woohoo!), but somewhere in between the keyboard and the chair.

P.S. The songs are charming and the game mechanics looks really fun, mind you, I've never played Guitar Hero or other rhytm games. The only one thing that's bothering me is that after 5 attempts I managed to get only 4 stars for the intro song. My years of piano practice went for nothing.

Monday, 11 October 2010

Running Tsukihime on Ubuntu Linux.

Late yesterday evening, when I was heading home, pondering whatever people usually ponder in cold dark evenings, I saw the moon. It is quite rare to see it so clear in the town where I live, but there it was, big, incredibly beautiful, with a tinge of blue. Long story short, that hit the trigger in my head and I got a strong urge to play the Moon Princess again.

There is one problem, though: my desktop PC is running Linux. Actually, the problem is not that big, because the English translation of Tsukihime uses the ONScripter engine, which is open source and multi-platform. And although Mirror Moon, the folks who translated Tsukihime, did not release a separate set of binaries for Linux, they were very kind to provide their patch for Onscripter-en to make things work.
http://mirrormoon.org/news/2007-01-15-tsukihime_english_for_linux_and_osx

Just as it is always happening, the actual process is harder than it is supposed to be and has a couple of unexpected caveats. To begin with, you may have discovered that the Ubuntu repo actually has the Onscripter package. Well, surprise! It won't work with the game, because it does not have the patch! So let's compile the game from the source instead.

Let's get these two files:
$ ls
onscripter-20060724-insani.src.zip  onscripter-20060724-insani-zalas.patch2

Then unzip onscripter:
$ unzip onscripter-20060724-insani.src.zip ; cd onscripter-20060724-insani

Now let's apply the patch:
$ patch -p1 < ../onscripter-20060724-insani-zalas.patch2

After that, install all the dependences mentioned in the README file. You will know you're missing something if the compilation fails saying there is no header file.

Now, after these steps we WERE supposed to get a working binary by just running:
$ make -f Makefile.Linux.insani


However, there is a problem:


...
ONScripterLabel_command.cpp: In member function ‘int ONScripterLabel::savescreenshotCommand()’:
ONScripterLabel_command.cpp:861: error: invalid conversion from ‘const char*’ to ‘char*’
ONScripterLabel_command.cpp: In member function ‘int ONScripterLabel::exbtnCommand()’:
ONScripterLabel_command.cpp:2225: warning: suggest parentheses around ‘&&’ within ‘||’
make: *** [ONScripterLabel_command.o] Error 1



This is simple. GCC has become more strict since the time this code was written, so we need to re-declare *ext on line 861 from char * to const char *. Now, can we have the working program?

$ make -f Makefile.Linux.insani
...
/usr/bin/ld: cannot find -lartsc
collect2: ld returned 1 exit status
make: *** [onscripter] Error 1



Not yet! The Arts sound library which we are missing here is outdated, and it's not available in the modern Ubuntu distros. Instead, a compatible sound interface is provided through PulseAudio, which is default nowadays. After a lot of googling, I finally figured out the solution: you should substitute -lartsc with -lpulse inside Makefile.Linux.insani in the uncommented "LIBS = ..." string. In addition, you must get rid of "-static", because there is no static version of libpulse-simple which you will need. (Actually, I have no idea why static linking was enabled in the first place). After these changes, LIBS should look like this:

LIBS = -z muldefs -Wl,--start-group `sdl-config --static-libs` `smpeg-config --libs` -lSDL_ttf -lfreetype -lSDL_image -ltiff -lpng -lSDL_mixer -lbz2 -lz -ljpeg -lm -lvorbis -lvorbisenc -lvorbisfile -logg -lgpm -lncurses -lslang -ldirectfb -lfusion -ldirect -lvga -ldl -lesd -lpulse -lasound -lX11 -laa -Wl,--end-group

$ make -f Makefile.Linux.insani

Finally, the binary is ready! After copying it to the game dir (or vice versa), all the preparations have been made, and we can enjoy the game:

$ ./onscripter
ONScripter version 20060724-insani(2.55)
Autodetect: insanity spirit detected!
Display: 640 x 480 (32 bpp)
Audio: 44100 Hz 16 bit stereo


P.S. The steps above were valid for Ubuntu 9.10 Karmic Koala. Chances are very high that the steps for 10.04 and 10.10 will be exactly the same.