Jump to content

[EXTRA1 Linux Port done!] Ao no Kanata no Four Rythm + EXTRA1 Linux Port & +18 Patch for Nintendo Switch


loam

Recommended Posts

In homage to loam's profound contributions to humanity at large, @leycec Productions presents... Lutris-based Linux installers!

My GitHub repository currently hosts experimental Lutris installers for loam's awe-inspiring native Linux port of the official NekoNyan, JAST, and Steam releases for Aokana – including a supplementary installer for the Steam release optionally installing the free-as-in-beer Perfect Edition+ R18 DLC.

What's most needed from the Linux visual community now is testing. Please help us get a better idea of the state of these installers by submitting a new issue documenting your installation experience. Installers verified as working will be published to the Lutris page for Aokana. Until verified, these installers will only be available from this repository.

Since the initial "AokanaLinuxPatch.zip" archive is both unversioned and inaccessible from automated Lutris installer scripts, I've also taken the liberty of hosting that zipfile at this repository as a GitHub Release named "aokana-linux_0.0.1.zip". If that displeases you greatly, loam, just let me know and I'll make everything right again.

Also, would you like to be added as a repository maintainer? I'd be delighted to give you push access. If you're not already hosting your Unity changeset somewhere, this could be the perfect place. If you are already hosting those changes somewhere, just let me know the URL and I'll link to you straight away.

Thanks for all the hard-working volunteerism! You have my vote for the next NekoNyan engineering hire. 😌

Edited by leycec
...for the good of mankind.
Link to comment
Share on other sites

On 10/6/2020 at 9:37 PM, leycec said:

In homage to loam's profound contributions to humanity at large, @leycec Productions presents... Lutris-based Linux installers!

My GitHub repository currently hosts experimental Lutris installers for loam's awe-inspiring native Linux port of the official NekoNyan, JAST, and Steam releases for Aokana – including a supplementary installer for the Steam release optionally installing the free-as-in-beer Perfect Edition+ R18 DLC.

What's most needed from the Linux visual community now is testing. Please help us get a better idea of the state of these installers by submitting a new issue documenting your installation experience. Installers verified as working will be published to the Lutris page for Aokana. Until verified, these installers will only be available from this repository.

Since the initial "AokanaLinuxPatch.zip" archive is both unversioned and inaccessible from automated Lutris installer scripts, I've also taken the liberty of hosting that zipfile at this repository as a GitHub Release named "aokana-linux_0.0.1.zip". If that displeases you greatly, loam, just let me know and I'll make everything right again.

Also, would you like to be added as a repository maintainer? I'd be delighted to give you push access. If you're not already hosting your Unity changeset somewhere, this could be the perfect place. If you are already hosting those changes somewhere, just let me know the URL and I'll link to you straight away.

Thanks for all the hard-working volunteerism! You have my vote for the next NekoNyan engineering hire. 😌

Thanks for all the hard work! I don't have much time to maintain stuff like that, but it's amazing that someone picked up what I did and made it a simple one click install for Lutris users.

I'm not keeping track of the changes in the Unity assembly, just edited the binaries in dnSpy and wrote all the custom Linux code there (on second thought, I probably should... it'll be for the next time then). I haven't created a GitHub account for all this stuff, but I probably will when I find the time to make one and upload the sources there. Feel free to redistribute it wherever you want, the version number is fine too.

PD: I was going to post a pastebin including the libaokanaproc.so source now since it was very basic, but I lost the source while reinstalling my PC! It's very basic though, basically just libwebp and a specific function exported. I'll also upload the source of the tool I wrote for the Switch patch, an (un)packer for the .dat files, when I take care of setting up github stuff.

Link to comment
Share on other sites

Fantasmic. That all sounds great, of course. When you get your GitHub account up and running, just give me a shout-out either here or at the existing Aokana Linux repository and I'll add you as a repository co-owner with full push privileges. You're the upstanding human that enabled all this, after all. If you'd prefer to just ignore that and push changes to your own personal GitHub repository, that's absolutely fine too.

Other volunteer GitHubbers should definitely be interested in extending and improving on the core Linux support you've already built, so I'm excited to see where this eventually goes. You rock it, loam! 😌

Link to comment
Share on other sites

  • 2 weeks later...

so i already read how to apply to sxos, im playing this game using .nsz file and already update to 1.1, i also already copy on the dir sxos folder like the instruction but my game still not patched ( SW 1.01 ) only on the right corner start game

 

 

Edit : I can apply patch right now, thankyou

Edited by vunceer99
Link to comment
Share on other sites

  • 2 weeks later...

Poking at my freshly bought copy Aokana EXTRA1 copy, it now includes a native ogg/opus decoder alongside the .NET-based ogg/vorbis decoder. Asset system is the same as the original Aokana PC version.

While reversing it, I found what seems to be a small memory leak with it: the opus file and pcm buffers do get freed, but the library's own pointer does not get freed (the one where the opus file and buffer pointers are stored)!

The source code would resemble something like this - if you notice, "decptr" never gets freed. Might be good if someone informs the engine dev at Discord about this, although it's rather small and never becomes a problem (32bytes * 3718 voice lines = approximately 0,12mb leaked when reading all voice lines - seems to allocate multiplying by the ogg channel amount, not sure why, so it might be up to 0,24mb or so):

Spoiler

1XQjPMu.png

If there's no weird shenanigans with the new stuff, I should be able to finish this in a couple of hours (reinstalled pc so I have to setup dev environment for Linux again).

Edited by loam
Link to comment
Share on other sites

1 hour ago, loam said:

I found what seems to be a small memory leak with it: the opus_decoder and pcm buffers do get freed, but the library's own pointer does not get freed (the one where the opus file and buffer pointers are stored)!

The source code would resemble something like this - if you notice, "decptr" never gets freed. Might be good if someone informs the engine dev at Discord about this, although it's rather small and never becomes a problem (32bytes * 3718 voice lines = approximately 0,12mb leaked when reading all voice lines - seems to allocate multiplying by the ogg channel amount, not sure why, so it might be up to 0,24mb or so):

Engine dev here. Extra1 isn't using opus at all, so the mem leak shouldn't be a problem this time around. (It was used on Aokana's Kickstarter physical release and Switch port though, so a small patch wouldn't hurt if needed.)

Link to comment
Share on other sites

4 hours ago, binaryfail said:

Engine dev here. Extra1 isn't using opus at all, so the mem leak shouldn't be a problem this time around. (It was used on Aokana's Kickstarter physical release and Switch port though, so a small patch wouldn't hurt if needed.)

Oops, that's what I get for not really checking the audio files in the .dat files... thanks for the hint. I'll just reuse what I did for the previous patch then.

I get why you would use opus on the Switch, since it has a hardware accelerated decoder for opus. I had to use this for a port of an old game, it had performance issues with the original mp3 files, while wav was ok but wasted too much space, so hw accelerated opus was the perfect solution.

The game is now running on Linux, and now including a little guide to have full Steam support, something I couldn't really test because I didn't own the Steam version. Some trickery had to be made because Steam was very stubborn and refused to install and launch the game on Linux, or didn't acknowledge instances of the game launched outside of steam. I'll be uploading files shortly and reworking the post since it's become a little bit disorganized with multiple patches/mods in one single post.

Some screenshots:

Spoiler

JNQpezT.png

Ttm2L9A.png

I noticed that curiously the chinese videos are now encoded in vp8/vorbis, just like I did for the previous patch. No need for additional downloads for chinese users then. I can only speculate it was because of the good file size gains and little to no quality loss like I also noticed.

Edited by loam
Link to comment
Share on other sites

The patch is done! Only minor C# script patches were needed, it was just a matter of carrying over what I did in the original game to EXTRA1, so nothing interesting to tell. I'll try to edit the main post to make it look cleaner when I have time. In the meantime there's good instructions on the README file that allow you to even run it under Steam on Linux with full integration working.

NOTE: The Linux patch is to be installed after installing the official 1.01 patch (which was released some days after the game's release), either automatically by Steam (make sure you don't have any pending updates), or if using a non-steam version, by using the installer they provide here (click here) (to avoid going through Wine, the installer can be manually opened with tools that can open NSIS installers, for example 7-Zip, then it's just drag and dropping into the game's root directory). If it works correctly, you should see "1.01" or "1.01 (Steam)" while running on Linux.

Base patch: http://www.mediafire.com/file/5qkd4az69yytqe0/AokanaExtra1LinuxPatch_1.01.zip/file

English videos (these play when you play the game on English/Japanese - not needed if you will play in chinese): http://www.mediafire.com/file/5h53tkbjz7wwatk/AokanaExtra1VideoFilesEN.zip/file

Edited by loam
Link to comment
Share on other sites

Legit made an account just to say thank you so much for making this patch! I picked up the Switch version and I was really hoping there was something like this. I'm curious though, do you know how hard it would be for someone with programming experience to make something similar for another VN, say Grisaia?

Edited by garha
Link to comment
Share on other sites

  • 2 weeks later...

I've updated the Linux patch for AokanaEXTRA1 to include the patches from the official 1.01 update, which fixes some small bugs - official note:

 

The Linux patch is to be installed after installing the official 1.01 patch, either automatically by Steam (make sure you don't have any pending updates) or by using the installer they provide (to avoid going through Wine, the installer can be manually opened with tools that can open NSIS installers, for example 7-Zip, then it's just drag and dropping into the game's root directory). If it works correctly, you should see "1.01" or "1.01 (Steam)" while running on Linux.

Other than that, installation instructions are unchanged.

New download link (link in main post has been updated as well - you don't need to download the older patch for this one to work): http://www.mediafire.com/file/5qkd4az69yytqe0/AokanaExtra1LinuxPatch_1.01.zip/file

  

On 11/13/2020 at 3:29 AM, garha said:

Legit made an account just to say thank you so much for making this patch! I picked up the Switch version and I was really hoping there was something like this. I'm curious though, do you know how hard it would be for someone with programming experience to make something similar for another VN, say Grisaia?


The difficulty would depend on the engine and its file formats. I've never peeked into other VN engines, I'll admit I'm kinda of a newbie around stuff used in VNs, but small reverse engineering experience as well as experience with the Switch's inner workings and homebrew resources did help a bit in the case of this patch. It was also very easy to reverse engineer the main executable, because of Unity/C#. Other VNs can be harder, specially if it's an uncommonly used engine (less tooling & resources around) and/or contains console-specific changes to the executable and/or file formats (more time spent disassembling). Like I said before, I don't want to make any promises, but I might be looking into other VNs in the future, starting with the ones people have asked me about.

Edited by loam
fix typo + reply
Link to comment
Share on other sites

  • 2 months later...
On 20/09/2020 at 4:02 AM, loam said:

Hello, I've finished the Aokana for Linux patch:

This patch allows Aokana to run on Linux natively, without any compatibility software like Wine/Proton/etc. This eliminates most of the bugs related to these compatibility solutions and I guess it removes the overhead of such a compatibility layer if this was of any concern to you.

Videos had to be transcoded to webm (vp8/vorbis), because Linux can't play the already-present mp4 videos. The file sizes are very similar for English videos (~16mb bigger) and I didn't notice any visual deterioration. The Chinese videos on the other hand are around ~100MB smaller. You'll have to download them again for videos to work on Linux; the patch will take care of loading these instead. I uploaded these as separate downloads so people don't have to download videos for a language they might not speak. When using Japanese, the English videos are loaded instead (don't worry, the subtitles for the videos between chapters are saved somewhere else except for the opening - it's the same on the normal release)

About Steam Integration: I couldn't test it myself, but I provided the Linux equivalent of the library that the game tries to use for Steam, so it should work. Feedback about this would be appreciated.

The patch works on Windows too, in case you switch frequently between Windows and Linux. The patch will run the original windows code and will not suffer from the differences Linux has.

I also took the liberty to add a small extra feature: If you run the game with the Continue.bat/Continue.sh files on Windows or Linux respectively (or pass --continue as a command line arg, which is what these files do internally), it loads a special save file (a save not present on the load/save menu that gets saved everytime you exit the game; this save on exit functionality was already done by NekoNyan, but not used anywhere) immediately after starting the game, skipping the intro logos/movie and placing you right back where you were last time you played. No Title, no Main Menu. You should be able to try this out even if you've never used the patch before because of what was mentioned before.

Unfortunately it has a few but subtle/minor differences from the Windows version (explained why on the rundown further below):

  • Save thumbnail uses Unity-provided bilinear filtering (like the Switch version), which provides inferior quality compared to Windows' bicubic filtering.
  • Importing a background or saving an image using the Sprite Viewer won't work because Windows specific dialogs were used and no alternative was coded into this patch (at least for now).
  • Letterboxing (black bars on sides/bottom) will be present if you resize the window manually and it doesn't match the game's aspect ratio, unlike the Windows version which corrects itself.
  • The game's sound won't be paused when minimized, unlike the Windows version.
  • Apparently the game tries to set the cursor on Windows for things like prompts and the gallery. Even with the original windows game, I never saw this behaviour even though it should've worked (no idea why). In any case, this wasn't ported to Linux.

Downloads:
Main patch: http://www.mediafire.com/file/k02f4pb0ovxckn7/file

REMEMBER: Download the Linux-compatible videos for your language!
English videos (also used when the game is set to Japanese): http://www.mediafire.com/file/bhm65i1h9tx68yv/file
Simplified Chinese videos: http://www.mediafire.com/file/s3rai72u2je60t1/file
Traditional Chinese videos: http://www.mediafire.com/file/fsisjaibh73wc8v/file

 

Screenshots: (SFW)

  Reveal hidden contents

QZBcCee.png

eYcAXyx.png

HbTP8pl.png

SPmUvup.png


Boring technical rundown:

  Hide contents

 

This was relatively "easy" to do because of the fact that this VN in particular is using a custom in-house engine based on Unity, made by NekoNyan. It's written in C# (Unity's scripting API is mainly in C# for those that may not know) and it's highly portable since all the Platform specific stuff is either handled by Unity already or isolated and easy to change. UI and other stuff are loaded from files inside a custom format (which also includes the scripts), which means effort has been put into making this a repurpose-able engine for future projects (they have a few projects announced to be on their new engine as well). Porting it to Linux wasn't a walk in the park as all this would suggest though:

Fortunately, Aokana was built with Vulkan support (I've heard it solves some issues and runs faster for some). This is nice as no effort has to be done into porting DirectX shaders to Vulkan/OpenGL manually; some custom shaders are being used for some effects and since it gets built into a DirectX specific format by Unity when building, it would've required redoing those for Vulkan. Linux defaults to Vulkan for running the game as a result. OpenGL wasn't included on their build.

The script itself had to receive some changes to actually run on Linux. On the original Windows version, because Unity doesn't provide some stuff to manipulate the window freely, some stuff had to be done using the Windows API. On Linux, X11 (the most common window system) has a rather old and cumbersome API. Most use desktop environments which implement X11, but others might use Wayland, or who knows what. In theory they should also have a working X11 compatibility layer, but in practice this doesn't always work and tends to break. Anyways, I could've make the extra effort to port functionality but since it's just a couple of small features for an unofficial port I just didn't think it was worth the effort for now. This is the reason why minimizing detection, cursor moving made by the game and window size correction are missing in Linux. As for the file browser for saving images and importing backgrounds for the sprite viewer, it also used a Windows specific dialog. Like before, and being a kinda niche feature, I didn't implement a new cross-platform dialog for it, so it will not work at all, sorry if you were planning to use this.

One rather unexpected hurdle to go through was the usage of a custom native windows library called aokanaproc.dll, which took care of the resizing code and webp support: webp (an image format, a very good one) is used for almost every texture of the game. Because Unity doesn't support it, it had to be implemented in their custom native code. As a result I had to download and build a compatible library, libaokanaproc.so, which will do what aokanaproc.dll did on Windows, but on Linux (sans window resizing code).

As for the videos, it was very simple: mp4 not supported in Linux, so it needs another format, and between ogv and webm, webm seemed more favorable, so I went with webm (vp8 for video, vorbis for sound).

The save thumbnail quality issue: Windows specific code was being used (System.Drawing, which isn't officially supported by Unity but can be used nonetheless), which provided Bicubic filtering when downscaling the texture for the thumbnails. Unity doesn't provide a straightforward method for resizing textures, so some tinkering with textures in the code had to be done, and the best I could get was bilinear filtering which is provided by Unity. I believe the Switch version uses this since the quality is very similar, so I decided to leave it like that.

 

 

Would it be possible to get the source code somehow? 

Edited by Grayscale
Fix mistake
Link to comment
Share on other sites

  • 2 months later...

Made this account just to say this lol😆. Playing patched version on my phone with eggns, somehow i manage to make it work didn't thought it would be possible to play this with a phone in r18 version lol. Thanks anyway i played the prologue and got interested as i accidentally saw this post almost two years past also does the extra1 include in this switch version not that i expect an reply hahahah, just wanna say my regards thanks

Edited by Seleiya
Link to comment
Share on other sites

  • 10 months later...
  • 2 weeks later...

Hey there's, it's been a while. I didn't even knew there was an update for the game already! Seems I missed it for a little beat over a year... sorry for that! The patch already contains fixes to the script from PC that were not yet released on Switch, and I think the fixes are very minor, so if you really want to play, I'm sure the base version (or an update that released when this patch released - I'm not sure anymore!) should work.

I've retired from Switch homebrew (Steam Deck replaced all of its homebrew use so I lost interested), and because of this the project is very buried and archived under my hard drive, but I still have the tools so I can probably come up with something next month, no guarantees though.

Some asked me (through other social media) if something could be done for a Senren Banka R18 Switch Patch, which runs on the same engine. I tried researching to this, but it's incredibly difficult to pull off because the original source of the scripts was compiled to an M2 middleware format (that I can only describe as a rather needlessly complicated hot mess of garbage). As a result, macros got expanded into single operations for the original engine. On the Switch, these macros were implemented on the engine itself and converted variants are to be seen on the converted source that this engine uses. To do a Switch patch requires a workload multiple times bigger than what the Aokana patches took.

On 2/8/2022 at 1:39 AM, Seleiya said:

i accidentally saw this post almost two years past also does the extra1 include in this switch version not that i expect an reply hahahah, just wanna say my regards thanks

In theory it's possible and I already tested this over a year ago, but distributing a simple drag and drop for EXTRA 1 would be piracy. I could make a patcher or something but eh...

 

On 2/7/2021 at 10:09 AM, Grayscale said:

Would it be possible to get the source code somehow? 

Sorry for the horrible delay. In case you're still interested:

https://github.com/theloam/aokanaproc

Edited by loam
noticed unfinished sentence after 7 months
Link to comment
Share on other sites

  • 3 months later...
On 12/18/2022 at 5:02 AM, loam said:

Hey there's, it's been a while. I didn't even knew there was an update for the game already! Seems I missed it for a little beat over a year... sorry for that! The patch already contains fixes to the script from PC that were not yet released on Switch, and I think the fixes are very minor, so if you really want to play, I'm sure the base version (or an update that released when this patch released - I'm not sure anymore!) should work.

I've retired from Switch homebrew (Steam Deck replaced all of its homebrew use so I lost interested), and because of this the project is very buried and archived under my hard drive, but I still have the tools so I can probably come up with something next month, no guarantees though.

Some asked me (through other social media) if something could be done for a Senren Banka R18 Switch Patch, which runs on the same engine. I tried researching to this, but it's incredibly difficult to pull off because the original source of the scripts was compiled to an M2 middleware format (that I can only describe as a rather needlessly complicated hot mess of garbage). As a result, macros got expanded into single operations for the original engine. On the Switch, these macros were implemented on the engine itself and converted variants are to be seen on the converted source that this engine uses. To do a Switch patch requires a workload multiple times bigger than what the Aokana patches took.

In theory it's possible and I already tested this over a year ago, but distributing a simple drag and drop for EXTRA 1 would be piracy. I could make a

 

Sorry for the horrible delay. In case you're still interested:

https://github.com/theloam/aokanaproc

"I'm sure the base version (or an update that released when this patch released - I'm not sure anymore!) should work." 

just tested it and that doesn't actually work, so could you please update it?

Link to comment
Share on other sites

  • 3 months later...
On 8/26/2020 at 9:27 PM, littleshogun said:

To me it's not like anyone who own Switch and can play adult content (18 or above) didn't own the PC anyway. While I'm sounds like not interested with your (Redundant) effort, I should appreciate it in that some people may prefer console to watch the sex scenes even though they might more than able to buy laptop that can play Aokana, so good job on that.

Well, there's me, who has a hacked switch and doesn't own the PC version of the game, despite having a desktop PC and laptop. I prefer to play on portable devices, so this is perfect.

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...