KS on Android... it's so close!

  • 6 Replies
  • 4498 Views
*

Offline msys

  • 4
  • 1
    • View Profile
KS on Android... it's so close!
« on: December 02, 2015, 03:39:32 »
Hello to all Knytters!

Recently I've done some experiments, which resulted in (almost) fully working Knytt Stories on Android!

First of all, the description of all the proceedings:

1. I've used NVidia Shield Tablet 32GB LTE RoW, fully updated to Android Lollipop
2. I've installed 'Exagear Strategies' from the Play Store - which is in fact a really neat x86-on-ARM emulator, capable of running .exe files out of the box (it is actually Wine wrapped in some sort of virtualizer, or something close to that); unfortunately it's proprietary, but the Wine people are claiming they also have something similar on the way
3. I've copied the whole 'Knytt Stories' directory as a subdirectory of /sdcard/Exagear/
4. after executing 'Knytt Stories.exe' inside Exagear, the program complained about temporary directory missing or something like that
5. ... because of the above 'problem', I've created a simple launcher that changed the env. variables TEMP and TMP to '.\_tmp' and also created an empty '_tmp' subdirectory in /sdcard/Exagear/Knytt Stories - the launcher is just a few lines of ahk (AutoHotKey) script compiled into an exe:

Code: [Select]
EnvSet, TEMP, .\_tmp
EnvSet, TMP, .\_tmp
Run, "Knytt Stories.exe"

6. Now we're talking! After launching the launcher, the Knytt Stories window is right there - with sound and everything clickable!
7. ... I've opted for a tutorial and... first screen appeared, with animation, env. sounds and everything
8. Being kind of resourceful ;), I've grabbed a nearby paired Bluetooth keyboard and pressed 'S' - and Juni jumped, whoa!
9. ... unfortunately, that's all that is working there: as soon as I've tried going 'left' or 'right', as soon as the correct frame (or maybe even two) is drawn for Juni, then Exagear quits without any explanation :(

After that, I've tried everything - selecting different levels, different controls (Exagear Strategies/RPG allows to use the touchscreen under some of the control schemes), remapping the keys via 'Knytt Stories Ex' (it is working, too, but 'Knytt Stories Plus' doesn't even start), using touchpad to move Juni, disabling sound (which does not work - when Juni is jumping, I still hear some sound - this behaviour is different from Windows original - so MAYBE the reason is somewhat related to some sound samples?)

This is even more mysterious than that: given that Knytt Stories works perfectly under Wine, and also under Exagear Desktop (another product from the same company, for ARM devices but with full desktop environment, you can execute full x86 Linux distro with X on it). About the last part: although I've never tried Exagear Desktop myself, I've seen some video on YouTube showing 'DragonBox Pyra' prototype (the next OpenPandora device, all the retro-maniacs out there should know what I'm talking about :) ) with Knytt Stories up and running, among other windows.

I'm feeling this is so close - I mean KS on Android. To date, I've been using DraStiC emulator on a Shield Portable with KSDS homebrew on a specially crafted FAT32 filesystem - it works perfectly, but it is far away from the desktop experience, mainly because you cannot see the whole screen simultaneously, but this... Exagear, could be the perfect way.

I've run out of ideas about how to proceed - maybe someone knowing at least some of the Knytt Stories / MMF2 internals could help there?

I don't have MMF2 myself, so I cannot modify the sources to test this further...

In case you have any questions, please do ask!
ms
« Last Edit: December 02, 2015, 03:44:55 by msys »

*

Offline egomassive

  • 1850
  • 250
    • View Profile
    • egomassive games
Re: KS on Android... it's so close!
« Reply #1 on: December 02, 2015, 21:27:29 »
None of this emulation stuff is my scene. I speculate KS+ wont start when the others do because it launches a child window. Maybe it will work if launched from the level editor, because it skips the nested windows set-up.

There's not much that can be revealed about the source. Jumping an running/walking are both controlled by an extension for platforming, the inner-workings of which are hidden. Key presses are detected and passed along to the extension which handles the movement. Then the animation and sounds are switched. Everything for running/walking is identical to jumping except for 2 subtle differences. One, The running/walking sound has it's own reserved sound channel. This channel is no different than other channels though. It's reserved for running/walking because the track can go on for such a long time. Two, running and walking choose a random position for their animations to start. The RNG is another hidden element of MMF2, but it may not be called until this point.

*

Offline msys

  • 4
  • 1
    • View Profile
Re: KS on Android... it's so close!
« Reply #2 on: December 03, 2015, 00:30:11 »
Wow, I've got a reply from egomassive himself! Kudos to you, for all of the years (yours and mine) 'invested' in pure entertainment ;)

Now, this got me thinking... although we don't know the exact internal code, maybe there is a possibility to narrow the problem down and in the end, maybe even to find some workaround.

You're basically telling that two possible reasons stand out of all the other: the specially reserved sound channel and the RNG.

I cannot test either of these, because I don't have MMF2 and even if I had, I have none of the experience required in using this tool. You on the other hand...

Could you please provide me with two simple programs (simple being the most important requirement):
1. doing some stuff with the platforming extension, but stripped from any sound? I mean some character walking left and right - and that's it, possibly with no sound, or with sound configured to be disabled?
2. doing some calculations involving calling the RNG and displaying the result somehow?

I'll then try to execute these on the tablet and then get back to you with the results. The goal is to try until we find precisely what does not work under Exagear. Maybe then we'll work out how to patch Knytt Stories under MMF2 to work there?

As for launching Knytt Stories through Level Editor, following are the results of me trying:
- all level editors can be launched to the point of the menu with the levels
- original level editor and 'Level Editor Ex' both load the level normally, whereas 'Level Editor Plus' invariably aborts afterwards (silently)
- because of the above, I cannot start 'Knytt Stories Plus' from within 'Level Editor Plus'
- I don't know how to launch 'Knytt Stories' form within the original level editor
- starting Knytt Stories - any version, via renaming the .exe file - from 'Level Editor Ex' (via '3rd Party Tools -> Run Knytt Stories') results in Android error message: 'Unfortunately, Exagear Strategies has stopped'
- the same fate awaits any attempt to execute 'Knytt Stories Manager', so I suppose the launching itself from within MMF2 is somehow failing

BTW there are some Exagear logfiles, but I've never found anything even remotely useful in these, just a lot of internal garbage about virtual directories, also the same exact messages that Wine gives while launching Knytt Stories under some desktop Linux - but it works there, so these messages shouldn't be worrying at all...

All the best!
ms
« Last Edit: December 03, 2015, 00:41:39 by msys »

*

Offline msys

  • 4
  • 1
    • View Profile
Re: KS on Android... it's so close!
« Reply #3 on: December 03, 2015, 00:35:27 »
One more thing: if the platforming extension uses the RNG to decide on the starting frame, then the RNG itself might be ok, at least for the first second of using it, because after pressing 'left' I'm seeing the Juni animation frame changing right before Knytt Stories quits, so I suppose it had to be chosen somehow before being drawn...

On the other hand, I've never heard any 'walking sound' before quitting...

*

Offline AA

  • 510
  • 23
  • Was ITA84
    • View Profile
    • Insight on Videogames
Re: KS on Android... it's so close!
« Reply #4 on: December 03, 2015, 07:51:28 »
^ But you've said Juni can jump without crashing the game, right? So I doubt it's about sound samples. The only difference between jump and walk sounds is that Juni's steps cycle over 4 different noises (presumably it's just one sound sample, in any case it's not random).

Unfortunately I've never delved into MMF2 nor into the KS code, so I can't help much.

Anyway, good job so far :)
Videogames are for everyone, by everyone

*

Offline msys

  • 4
  • 1
    • View Profile
Re: KS on Android... it's so close!
« Reply #5 on: December 03, 2015, 09:39:42 »
Well, my understanding of what egomassive said:
Quote
'Everything for running/walking is identical to jumping except for 2 subtle differences. [...]'
is that walking is different from jumping (and from anything else?). Obviously, I don't have any means of testing to what extent this is true, so I have to stick to the exact words there...

Also, it seems that in Exagear I cannot turn the jumping sound off - this in itself looks suspicious...

*

Offline egomassive

  • 1850
  • 250
    • View Profile
    • egomassive games
Re: KS on Android... it's so close!
« Reply #6 on: December 05, 2015, 04:51:18 »
I looked at the source. I was mistaken about the animation starting at a random frame. It's the run sound that starts at a random position. This does not happen with the walking sound so you can rule out the RNG by holding "A" to walk. If you can walk but not run then the emulator either doesn't like the RNG or it doesn't like starting a sound sample at a location other than the beginning. Since sounds are already acting up, my guess is the sound emulation of the emulator does not get along with MMF2 applications. This is core to the program, so there's nothing I can do by meddling with the KS source.

I didn't see anything else that would cause running but not jumping to fail. On the surface, it's all handled the same way. Under the surface, it's anybody's guess; we can't peek under the surface.

On a side note, the guy who made the DS Homebrew version of KS started work on an Android version. If you can code then getting in touch with him to make a native Android app would surely be a better approach.