Tumgik
geoffthepirate-blog · 6 years
Text
Utawarerumono
You can't buy this game. Like, not even original. But I got scammed on EBay once trying to do it. This game was never released outside of Japan. It was never released in English. Fan-translation is available, but copy-protection makes it impossible to boot on any modern PC.
So I'm going with Wine on this one.
Utawarerumono: The One of Whom Legends are Sung
There were four problems to tackle. Resolution, video playback, fonts and saving.
The game was released in 2002 and it renders in 640x480. You may think thats ridiculous, but Japanese PC market is so backwards that in order to debug their stuff, they are still building altairs and sacrificing small animals.
Tumblr media
Of course, such resolution is unacceptable in 2017, that's why modern Japanese games are getting released in 800x600 after all. To fix Utawarerumono, some actual magic was needed.
Do you know about XComposite extension? That's the thing that makes your Compiz cube spin. It's roughly as old as Utawarerumono, so your X should support it even if you don't. And it allows Window Manager to take content of any window and use it as OpenGL texture. So, Utawarerumono, look at me. I'm the Window Manager now.
I've basically hacked together library, that's LD_PRELOAD-ed between X and Wine and redirects any 640x480 window into OpenGL texture for my application. Then I hacked together my application. Little of GO+C+SDL and voilà: Utawarerumono scales to 4k screen nicely. Of course, source image is still 640x480 and even if there are some shaders thrown to the mix, you can't make too much from old dog, but it's playable, at least. Except it can't accept your inputs.
X allows you to do a lot of magic, but input handling sucks. You can't do anything with it. You click, event fires, on that place, no questions asked. That sucks when your window is 10 times smaller than area it renders into. Luckily, if you have full controll of target process, you can emulate X event pretty easyly. There are sane method, fast method, near-zero-lattency method and then there is XSendEvent. So that's what I used. Hey, it's visual novel, you are not going to notice few ticks of latency. And it's really simple to pull out. Any input SDL catches is translated to XEvent right away, mouse coordinates are recalculated and entire thing is XSend to Wine.
Tumblr media
At this point, Utawarerumono would be playable, if it were not for opening video. You probably heard scary stories about video playback under Wine, but let me tell you, reallity is much worse. Any attempt to load format that Utawarerumono uses leads to crash. But wine uses GStreamer and GStreamer is pretty benevolent when it comes to formats. You can tell it “I’m sending mpeg1 format from 1994″ while sending AVI and it’ll just play it obediently. So just converting both movies to mp4 allowed them to load and get skipped because of codec being unsupported. That means two options - reencoding movies to more common codec, or recompiling GStreamer with support for original. And who am I to spoil White Fox's gem by reencoding?
Last problem was saving. Originaly, I didn't expected this to be problem at all. Most of visual novels are saving to their own directory, but they use some subdirectory that can be easily redirected with symlink. Utawarerumono has to be different. It saves right where exe is. Like, really, this game, made in 2002 and sold on DVD, expects to be allowed to shit right to where it sleeps. Did I mention any old dogs before?
Tumblr media
I almost gone for same approach as Flatpak-Linux guys do, creating fake game dir and symlinking every file to it. But I take pride in my clean saves locations and putting 60 symlinks inside is just maddness. But you can't use LD_PRELOAD tricks to redirect paths managed by Wine and going through its source told me only that writing to file can be done from like 2000 locations. So best way to fix this is in Windows code.
Win32 alternative to open is CreateFileA and CreateFileW functions. You pass them filename and some flags that are definitelly not like those in old Unix, so nobody copied anything and I shouldn’t dwell into that too much. Hooking to them is trivial and allows me to redirect any call to save files somewhere else. What’s less trivial is actually preloading that hook, but code to do so can be found on Codeplex and compiled into small pre-loader exe. And best part of it is that you could use this fix on Windows as well, should you find your old Windows 98 installation.
Last problem was font, as game uses one that dont exists by default. On Windows, it gets replaced by situable Arial, with Wine, it gets replaced by something that breaks kerning. Luckily, this was easily fixable by creating situable font with name of default one.
Tumblr media
And with that, old legend got packed with new life. You can sing along.
1 note · View note
geoffthepirate-blog · 6 years
Text
Millia -The ending-
I don't get why this one was not available on Linux before. It's RenPy based, what mean that developer had to go forward and remove all Linux-related files from his release. It's like theyre explicitly don't want our money.
Millia -The ending-
Despite developer clearly not wanting you to, you can buy this game on Steam. It costs less than metro ticket, so...
Being it RenPy game should also mean that porting it shoud be straightforward, right? Just restore missing files and see it crashing, right?
Tumblr media
Turns out that I and Flatpak have something in common. We both dont like Python. For me, Python is that weird language in middle of fullblown language for applications and tool for scripting, taking all bad from both. For Flatpak, Python is that thing that can't make sense out of /app/all/your/files/belongs/to/here structure.
To be honest, I don't have great story here, because all I had to do is to edit some python scripts and hardcode different paths. After two-three attempts, game began to work and only two remaining problems were saving and ending video. Unlike all normal RenPy based games, this one overwrites where saves are stored for... reasons. Like, I cant imagine what drowe anyone from perfectly sane default to mess where saves are stored just in the middle of game data, but it was fixable by one dumb symlink.
Tumblr media
And for ending video? Option to use custom-built ffmpeg proves you how much is Flatpak awesome. And when Ive been building it anyway, it allowed me to recode credit roll to much effective codec, saving you hundreds of megabytes. You are welcome.
2 notes · View notes
geoffthepirate-blog · 6 years
Text
Planetarian
Let me tell you a story about one absolutely unknown studio’s firstling. Ok, that was a joke, I will be talking about Planetarian by Key.
Key is called the best by many. Clannad, Charlotte, Angel Beats… Their stories never did it for me, but even I can recognize when someting get insaneli popular for right reasons.
Key and Visual Arts, their parent company, never thinked much about western market. Importing their games is strictly illegal and running them o non-Japanese Windows could disable entire machine. That got changed when Sekai Project started bundling their games with fan-translations and made bank by selling them on Steam. Even most bonehead developer understands language of money. But in world of copyright, cash is not at all that all-powerfull. English Planetarian is stuck in copyright limbo. Similary to old movies from times of soyuz, nobody really holds copyright to it. Studio that released it first holds exclusiverights to their translation. Group that actually did it is no longer active and Planetarian HD was designed for Chinese mobile market and Visual Arts Hold rights only for the graphics. Even if Visual Arts can, and did, released game on Steam, they can’t do it in English. Chinese and German languages are available.
Luckily, none of that is concern to me. I’m a pirate.
planetarian ~the reverie of a little planet~
If you wanna do right thing, buy Planetarian HD on Steam. It gets you rights for graphics and this studio deserves every cent it can get.
It was not hard to get it to run, hard part was getting it to use HD graphics. Key’s RealLive engine has open-source implementation called RLVM, wich can play original Planetarian with no trouble. And english patch for original is available, so that was my starting point.
Tumblr media
Extracting graphics from Planetarian HD was no issue, but that gives a lot of bitmaps with japanese text in propertiary format. Not usable for anything. Format is almost completly known and tools for converting them to PNG are available and usable with Wine. But RLVM can’t load PNGs and there are no tools for converting them back and there is not like thing is opensource so I can code in PNG loader… oh, wait.
Yeah, I spent fist day implementing PNG loader to horrible C/C++ mess that doesn’t even understand transparency. Ok, that was mean, it does, but not kind that PNG has. Oh and did I talked about how that propertiary can hold more data than just bitmap? Paddings, marigns, click areas, they made their own version of CSS in that hell. Luckily, Planetarian uses almost none of that, so I just sticked needed data into binary file and named it Better Propertiary Format.
Tumblr media
Now I have Planetarian that can display HD graphics. On completly wrong places. As I found, RealLive have all positions hardcoded in random places in script. That's the reason why you can resize their windows. Everything would break. My first instinct was to decrypt script and fix all numbers manually. Tools are available and Planetarian is short game, so why not? Would you care to guess how many numbers can one stick per paragraph?</p><p>And that's how this simple port became actual hacking. RLVM knows about 20 instructions dealing with those numbers, so just multiplying everything by (new resoltion / original resolution) solved most of stuff and for few special cases, numbers were hardcoded to source of engine. Gross.
And that leaved me redrawing images with text on third day. I originally though about just upscaling pictures from non-HD English release, but those wouldn't fit exactly and placing some text in GIMP is pretty fast. Last fix was for saving and hallelujah, Planetarian HD in English is born.
Tumblr media
Oh and that's something you can't have even on Windows. Enjoy that.
2 notes · View notes
geoffthepirate-blog · 6 years
Text
Intro
Hello. Iam guy with holly mission of making best of visual novels available on Linux, any way necessary.
My works is based on well-known Flatpak script and you can find those all over the internet, specifically by searching for "Flatpak-Novels". On this blog I want to talk about some cases where bringing them to our platform were more interesting than just running "flatpak-make".
2 notes · View notes