nicymike / serflings

Serflings Remake Project
https://serflings.simpleguide.net/
28 stars 0 forks source link

[Android] serflings-2.0.0-SNAPSHOT-20230530 work in Android via Termux (fully playable, but no sound due issue #104) #106

Open ShpakMA opened 1 year ago

ShpakMA commented 1 year ago

I want play Settlers while I passenger in transport. I have Android based phone (OnePlus 5T A5010).

  1. Install latest Termux 0.118.0 — https://f-droid.org/packages/com.termux/
  2. Install XServer-XSDL-1.20 — https://sourceforge.net/projects/libsdl-android/files/apk/XServer-XSDL/
  3. Launch and configure XServer-XSDL — you need, at least, turn on 24bpp color in video settings, or black window result
  4. Launch and setup enviroment. Write it via keyboard or launch attachet script. XFCE are optional, but GUI is better, then software keyboard. termux-install-java-xorg-xfce.sh.tar.gz
    termux-setup-storage;
    pkg update;
    pkg upgrade;
    pkg install x11-repo;
    pkg install openjdk-17-x mc xorg-* pulseaudio pulseeffects portmidi timidity++ termux-x11-alpha aterm xfce4*;
    echo 'export DISPLAY=127.0.0.1:0 PULSE_SERVER=tcp:127.0.0.1:4713' >>.bashrc;
    chmod 755 ~/.bashrc;
  5. Put Serflings files somewhere in home directory (you may use mc for ease, sdcard are avalible under home/storage, but java not work with this storage (not understand why...)). Do not forget SPAE.PA.
  6. Restart Termux. The home/.bashrc are executing during initialisation and DISPLAY variable is set automatically.
  7. Launch java -jar serflings-2.0.0-SNAPSHOT.jar for direct jre launch, or startxfce4 for launch window manager first (both working, but first eats less memory);
  8. Switch to XServer-XSDL via Android recents. And enjoy game.

Now sound not working in Serflings, but other sound software work good. I check by listening music via Parole Media Player from XFCE.

ShpakMA commented 1 year ago

Screenshot_20230606-163107 Screenshot_20230606-150137 Screenshot_20230606-150031 Screenshot_20230606-150010

nicymike commented 1 year ago

This is great. 👍

Thank you for testing this out. How do you control the game because touch inputs are working quite different than mouse? Or does Termux simulate a mouse?

ShpakMA commented 1 year ago

How do you control the game because touch inputs are working quite different than mouse? Or does Termux simulate a mouse?

6" smartphone is too small. I use touchpad mode (mouse not absolute — swipe just move cursor in same directions). And mouse buttons are binded to volume keys…

I play few years original Settlers via DosBox Turbo in same manner…

This is not my video, but idea is same: https://youtu.be/j_4ZaIJ-r68

Only one difference — he bind virtual joystick to mouse. I bind volume keys instead…

ShpakMA commented 1 year ago

Termux simulate a mouse

XSDL, not Termux. In NIX graphics and terminal should present on dedicated mainframe. Using videocard, keyboard and mouse on same computer is bad flavor. But PC use it. Mouse support is part of Xserver, not client. Android XSDL server is very tiny, but if we achieve stable work on it — we obtain stable work on any NIX…

https://en.wikipedia.org/wiki/X_Window_System#Software_architecture

But X Window System have no sound. This part work separately, and also may be dedicated to another server… This is good, but in results my phone work as big Zoo with heterogeneous servers instead animals…

Just look on operational flow chart here: https://en.m.wikipedia.org/wiki/PulseAudio#Software_architecture

And now we need just troubleshoot this huge Zoo…

nicymike commented 1 year ago

So does fixing no sound isse #104 also fixes this issue?

ShpakMA commented 1 year ago

So does fixing no sound isse #104 also fixes this issue?

Probably, yes. I will play today on smartphone 2 hours. The Game was stable only if sound is switched off via config file.

ShpakMA commented 1 year ago

Ok, I was play 3 hours on android last night…

  1. The May and June (2023) snapshots are stable until player not attempt to switch on music or sound in game settings. If one of them is switched on, no chances to switch off — player have 2 seconds before crash. It is good to equip your smartphone with text editor (i use mcedit from mc package).
  2. Fullscreen game is totaly laggy on my phone. Lags are on termux side, not XSDL. Lags is out than screen is zoomed in — less objects on screen provide less lags.
  3. Panning is to slow on full resolution, but too fast in half resolution. Panning sensivity settings are strongly need.
  4. Lags steal mouse clicks.
  5. In result, playing original game via dosbox is more comfortable, than Serflings…
nicymike commented 1 year ago

Please check render times while playing (press F3 key).

I think render is using most of the time which will lead to lags. The game currently only uses software rendering which needs a fair amount of RAM and CPU (mostly CPU I guess). I have plans to use hardware rendering but I need to do some code changes before.

After all, Serflings is just a spare time project. :)

ShpakMA commented 1 year ago

Please check render times while playing (press F3 key).

Screenshot_20230612-075600 Screenshot_20230612-075615 Screenshot_20230612-075632 Screenshot_20230612-075644 Screenshot_20230612-083655 Screenshot_20230612-083754 Screenshot_20230612-083659

ShpakMA commented 1 year ago

JRE from adoptium.net ( OpenJDK17U-jre_aarch64_linux_hotspot_17.0.7_7.tar.gz ) not working on android in Termux.

Linux localhost 4.4.205-perf+ #1 SMP PREEMPT Thu Dec 3 03:44:27 CST 2020 aarch64 Android

2023-06-14T11:53:47+03:00

/data/data/com.termux/files/home/serflings/jre/bin/java -verbose -jar /data/data/com.termux/files/home/serflings//data/data/com.termux/files/home/serflings/serflings-2.0.0-SNAPSHOT-20230608.jar --validate-data
/data/data/com.termux/files/home/serflings/serflings-2.0.0-SNAPSHOT-20230608.sh: line 8: /data/data/com.termux/files/home/serflings/jre/bin/java: cannot execute: required file not found

2023-06-14T11:53:47+03:00

/data/data/com.termux/files/home/serflings/jre/bin/java -verbose -jar /data/data/com.termux/files/home/serflings//data/data/com.termux/files/home/serflings/serflings-2.0.0-SNAPSHOT-20230608.jar --system-info
/data/data/com.termux/files/home/serflings/serflings-2.0.0-SNAPSHOT-20230608.sh: line 14: /data/data/com.termux/files/home/serflings/jre/bin/java: cannot execute: required file not found

2023-06-14T11:53:47+03:00

/data/data/com.termux/files/home/serflings/jre/bin/java -verbose -jar /data/data/com.termux/files/home/serflings//data/data/com.termux/files/home/serflings/serflings-2.0.0-SNAPSHOT-20230608.jar
/data/data/com.termux/files/home/serflings/serflings-2.0.0-SNAPSHOT-20230608.sh: line 20: /data/data/com.termux/files/home/serflings/jre/bin/java: cannot execute: required file not found

2023-06-14T11:53:47+03:00
nicymike commented 1 year ago

The game needs 50FPS to run smooth. This means there is only a maximum time of 20ms in total for both tick and render. Everything above reduces the FPS.