Box86 - Linux Userspace x86 Emulator

Discussion in 'General Discussions' started by ptitSeb, Mar 3, 2019.

  1. ElPoco

    ElPoco Very Active Member

    Joined:
    Feb 16, 2012
    Messages:
    671
    Location:
    Paris, France
    I didn't have time to try it yet and I don't know when I'll be able to, but I'm following this thread with interest.
    --- Double Post Merged, Mar 11, 2019, Original Post Date: Mar 11, 2019 ---
    Do I need to compile it on the Pandora, or can I cross-compile it from an x86 linux?
     
  2. ptitSeb

    ptitSeb Serial Porter

    Joined:
    Aug 15, 2012
    Messages:
    8,280
    Location:
    France, near Lyon
    It's a cmake project, with very little dependancies. You can cross-compile it, I don't see any reason why you could not.
     
  3. Farox

    Farox Certified Guru

    Joined:
    Jan 8, 2009
    Messages:
    2,015
    Location:
    Italy
    I give a go with a pair of simple games (but i have only found that they are not 32bit Elf executable), so i try with something that i think would be nice to have...Hollywood player
    Here is the result:
    --------------------------------------------------------------
    Setting PATH to /media/TEMPUS/eggnoggplus-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
    --------------------------------------------------------------
    Setting LD_LIBRARY_PATH to /media/TEMPUS/eggnoggplus-linux/lib:/lib:/usr/lib
    Debug level is 1
    BOX86_LD_LIBRARY_PATH: /media/TEMPUS/eggnoggplus-linux/lib/i386-linux-gnu/:/media/TEMPUS/eggnoggplus-linux/lib32/
    Using default BOX86_PATH: ./:bin/
    Counted 39 Env var
    Looking for ./HollywoodPlayer
    Using native(wrapped) libdl.so.2
    Using native(wrapped) libc.so.6
    Using native(wrapped) ld-linux.so.2
    Using native(wrapped) libpthread.so.0
    Using native(wrapped) librt.so.1
    Using native(wrapped) libm.so.6
    Using native(wrapped) libX11.so.6
    Error: Symbol srand48 not found, cannot apply R_386_JMP_SLOT @0x827b058 (0x804b7da)
    Error: Symbol drand48 not found, cannot apply R_386_JMP_SLOT @0x827b068 (0x804b81a)
    Error: Symbol XCopyGC not found, cannot apply R_386_JMP_SLOT @0x827b0ac (0x804b92a)
    Error: Symbol __libc_current_sigrtmin not found, cannot apply R_386_JMP_SLOT @0x827b134 (0x804bb4a)
    Error: Symbol XAllPlanes not found, cannot apply R_386_JMP_SLOT @0x827b248 (0x804bf9a)
    Error: Symbol XDefaultGC not found, cannot apply R_386_JMP_SLOT @0x827b258 (0x804bfda)
    Error: Symbol __h_errno_location not found, cannot apply R_386_JMP_SLOT @0x827b278 (0x804c05a)
    Error: Symbol XChangeGC not found, cannot apply R_386_JMP_SLOT @0x827b320 (0x804c2fa)
    Error: Symbol vfscanf not found, cannot apply R_386_JMP_SLOT @0x827b334 (0x804c34a)
    Error: Symbol XSetScreenSaver not found, cannot apply R_386_JMP_SLOT @0x827b44c (0x804c7aa)
    Using native(wrapped) libasound.so.2
    Using native(wrapped) libXfixes.so.3
    Using native(wrapped) libXcursor.so.1
    Using native(wrapped) libXxf86vm.so.1
    Warning: Cannot dlopen("libpango-1.0.so.0"/0x82554d8, 1)
    Using native(wrapped) libXrandr.so.2
    Using native(wrapped) libXss.so.1
    Warning: Cannot dlopen("libgtk-x11-2.0.so.0"/0x8255505, 1)
    Warning: Cannot dlopen("libglib-2.0.so.0"/0x8255519, 1)
    Warning: Cannot dlopen("libgobject-2.0.so.0"/0x825552a, 1)
    PltResolver: Ofs=0x81412ae, Id=616 (IP=(nil))

    I have used the (now) old release with AirlineTycoon...i need to retry with a more recent source release.
    Here is the runscript used to test
    #!/bin/bash

    pwd=$(pwd)

    export PS1='\w\$ '
    umask 022


    echo "--------------------------------------------------------------"
    echo "Setting PATH to $pwd:$PATH"
    export PATH=$pwd:$PATH

    echo "--------------------------------------------------------------"
    echo "Setting LD_LIBRARY_PATH to $pwd/lib:/lib:/usr/lib"
    export LD_LIBRARY_PATH=$pwd/lib:/lib:/usr/lib

    export LIBGL_FB=1

    export LIBGL_FASTMATH=1
    export LIBGL_ES=1

    export BOX86_LOG=INFO
    export BOX86_LD_LIBRARY_PATH=$pwd/lib/i386-linux-gnu:$pwd/lib32

    bin/box86 ./HollywoodPlayer
     
  4. ptitSeb

    ptitSeb Serial Porter

    Joined:
    Aug 15, 2012
    Messages:
    8,280
    Location:
    France, near Lyon
    There are a few missing function, that I should implement. The main issue I see it the fact it tries to open gtk. Can it run without GTK? If yes, I'll add the missing function (your crash is because of a missing function).
     
  5. Farox

    Farox Certified Guru

    Joined:
    Jan 8, 2009
    Messages:
    2,015
    Location:
    Italy
    I don't know for sure...but i think not.
    Anyway there is an Linux Arm version available but is compiled for HardFloat ( i think i need to wait for my Pyra to test it)
     
  6. ptitSeb

    ptitSeb Serial Porter

    Joined:
    Aug 15, 2012
    Messages:
    8,280
    Location:
    France, near Lyon
    I have just pushed a comit to add the missing function. Build your own version and can try again, it should go further...
     
  7. Linux-SWAT

    Linux-SWAT Hardcore Member

    Joined:
    Feb 13, 2010
    Messages:
    8,118
    Cannot the Pandora hardfloat compat lib help here ?
     
  8. Grench

    Grench Forum Addict!

    Joined:
    Oct 3, 2008
    Messages:
    5,912
    I have played NWN on a lot of X86 computers. The Odroid video - that is about how it runs on a Pentium II. If you do some more testing with it, try logging into a persistent world with it to test networking? Also, there are quite a few graphics settings that might help speed. Turn off pretty much everything. With Neverwinter Nights on max settings it can bog down just about any hardware. Were you using NWN EE or the pre-Beamdog NWN 1.69? The EE version is an improvement.
     
  9. elvissteinjr

    elvissteinjr Very Active Member

    Joined:
    Aug 23, 2013
    Messages:
    394
    Location:
    Germany
    I also tried to run a bunch of things I grabbed from my Humble Bundle library. NightSkyHD surprised me by starting and showing the title screen. I'm not sure if I got impatient there or it got stuck though. There was no input prompt and nothing could be done there.
    A bunch games with bin files with some kind of extractor in them actually ran those without any issues.
    The games themselves not so much. There were quite a few missing wraps, but didn't bother writing those done for now. I'll probably come back at those later. Focusing on stuff that almost works already is probably better.
    That was with the version in the latest Code::Blocks PND beta.

    A couple of the games came with a self extract shell script which end up calling some x86 binary. Is there a simple way to run a shell script in Box86? I'd guess either edit the scripts to call box86 or get a shell interpreter compiled for x86 and run it through that.
    Didn't bother extract those titles on PC first for now.


    Later on I tested with the latest git version. Compiling on the Pandora was surprisingly painless as long as I gave it enough swap (on CC).

    I thought of something ultimately useless, yet still interesting: Running my own game's x86 Linux build in Box86.
    It only directly depends on SDL2 and its friend libraries, but looks like they're not fully wrapped yet:

    Code:
    Error: Symbol SDL_GetNumTouchDevices not found, cannot apply R_386_JMP_SLOT @0x8288020 (0x807b8b6)
    Error: Symbol SDL_GetPowerInfo not found, cannot apply R_386_JMP_SLOT @0x8288060 (0x807b9b6)
    Error: Symbol SDL_SetWindowBordered not found, cannot apply R_386_JMP_SLOT @0x82880dc (0x807bba6)
    Error: Symbol SDL_GetNumTouchFingers not found, cannot apply R_386_JMP_SLOT @0x8288108 (0x807bc56)
    Error: Symbol SDL_ConvertSurfaceFormat not found, cannot apply R_386_JMP_SLOT @0x8288140 (0x807bd36)
    Error: Symbol SDL_GetSystemRAM not found, cannot apply R_386_JMP_SLOT @0x82881b0 (0x807bef6)
    Error: Symbol SDL_GetCPUCount not found, cannot apply R_386_JMP_SLOT @0x828827c (0x807c226)
    Error: Symbol SDL_GetTouchDevice not found, cannot apply R_386_JMP_SLOT @0x8288348 (0x807c556)
    Error: Symbol __sqrtf_finite not found, cannot apply R_386_JMP_SLOT @0x82883d0 (0x807c776)
    Error: Symbol Mix_HookMusicFinished not found, cannot apply R_386_JMP_SLOT @0x82883e0 (0x807c7b6)
    
    Most of these are logging and stuff not 100% necessary to run the game, so I could remove them from the code for testing purposes. But SDL_ConvertSurfaceFormat, __sqrtf_finite and perhaps also Mix_HookMusicFinished would be rather nice ones to actually have.

    It appears to get quite far into the init stuff of the game, so that's nice. Ultimately segfaults, of course. :)
     
    levi likes this.
  10. ptitSeb

    ptitSeb Serial Porter

    Joined:
    Aug 15, 2012
    Messages:
    8,280
    Location:
    France, near Lyon
    It's the 1.69 (well 1.68 because the french version is one step behind) version.I don't own the EE edition.

    I'll look at adding this function. Only the Mix_HookMusicFinish is a callback IIRC and need special care.
    And thanks for testing (yes, loading time can be very long)
    --- Double Post Merged, Mar 12, 2019 at 8:27 AM, Original Post Date: Mar 12, 2019 at 7:39 AM ---
    @elvissteinjr : I have pushed the wrapped function you needed. Your game should start now.
     
  11. EvilDragon

    EvilDragon Administrator Staff Member

    Joined:
    Mar 4, 2003
    Messages:
    19,507
    Location:
    Ingolstadt
    Wow, didn't see this until now - VERY nice project, indeed!
    Seeing how many games have been released on Linux these days, this will surely be interesting on the Pyra :D
     
  12. Grench

    Grench Forum Addict!

    Joined:
    Oct 3, 2008
    Messages:
    5,912
    IF you want to test with it, IM me your Steam user name and I will gift you a NWN EE license. (Offer only good for @ptitSeb)
     
  13. Farox

    Farox Certified Guru

    Joined:
    Jan 8, 2009
    Messages:
    2,015
    Location:
    Italy
    Unfortunately it didn't work on CC Pandoras (AFAIK).

    Yes it runs ( i built your latest revision of today morning of Box86)
    But after asking for a file (.hwa) to execute it correctly load it and start but segfault in few seconds.
    Here is the log:
    farox-pandora:/media/TEMPUS/eggnoggplus-linux$ ./runscript.sh
    --------------------------------------------------------------
    Setting PATH to /media/TEMPUS/eggnoggplus-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
    --------------------------------------------------------------
    Setting LD_LIBRARY_PATH to /media/TEMPUS/eggnoggplus-linux/lib:/lib:/usr/lib
    Debug level is 1
    BOX86_LD_LIBRARY_PATH: /media/TEMPUS/eggnoggplus-linux/lib/i386-linux-gnu/:/media/TEMPUS/eggnoggplus-linux/lib32/
    Using default BOX86_PATH: ./:bin/
    Counted 39 Env var
    Looking for ./HollywoodPlayer
    Using native(wrapped) libX11.so.6
    Using native(wrapped) librt.so.1
    Using native(wrapped) libm.so.6
    Using native(wrapped) libpthread.so.0
    Using native(wrapped) libc.so.6
    Using native(wrapped) ld-linux.so.2
    Using native(wrapped) libdl.so.2
    Using native(wrapped) libasound.so.2
    Using native(wrapped) libXfixes.so.3
    Using native(wrapped) libXcursor.so.1
    Using native(wrapped) libXxf86vm.so.1
    Warning: Cannot dlopen("libpango-1.0.so.0"/0x82554d8, 1)
    Using native(wrapped) libXrandr.so.2
    Using native(wrapped) libXss.so.1
    Warning: Cannot dlopen("libgtk-x11-2.0.so.0"/0x8255505, 1)
    Warning: Cannot dlopen("libglib-2.0.so.0"/0x8255519, 1)
    Warning: Cannot dlopen("libgobject-2.0.so.0"/0x825552a, 1)
    Warning, Ignoring sigaction(0x22, 0x4044a134, (nil))
    Warning, Ignoring sigaction(0x23, 0x4044a1d4, (nil))

    Select Hollywood applet to run: Samples/Playerinfo.hwa

    HollywoodPlayer 7.1 [Linux] [32-bit] (c) by Andreas Falkenhahn
    The Cross-Platform Multimedia Application Layer
    Loading applet Playerinfo.hwa...done
    Preparing display...done
    And Action!
    ./runscript.sh: line 25: 2705 Segmentation fault bin/box86 ./HollywoodPlayer

    At first i thought at low memory available on my CC but after enabling a swapfile (a big 2GB file) i have the same segafult...
     
  14. ptitSeb

    ptitSeb Serial Porter

    Joined:
    Aug 15, 2012
    Messages:
    8,280
    Location:
    France, near Lyon
    Ah, at least it start...
    Not much info about the crash there. I'll try to run it myself with gdb, see if I can see something.
    --- Double Post Merged, Mar 12, 2019 at 10:28 PM, Original Post Date: Mar 12, 2019 at 10:27 PM ---
    Yes, with the Dual Core and the much faster FPU, even in it's current state I'm pretty sure there are already a nice quantity of title that should run nicely.
     
    ClockworkCoder, Farox and levi like this.
  15. Farox

    Farox Certified Guru

    Joined:
    Jan 8, 2009
    Messages:
    2,015
    Location:
    Italy
    Ok thanks
     
  16. elvissteinjr

    elvissteinjr Very Active Member

    Joined:
    Aug 23, 2013
    Messages:
    394
    Location:
    Germany
    Getting further with Benri and the Bandits (typo in the commit, but not that it matters) now. But not a lot. Zero missing symbols though!

    With BOX86_LOG=2:
    Code:
    3192|0x8171e1e: Calling my2_SDL_RWFromMem (/media/SD_PANDORA/box86-master/build/box86) (082898A0, 0000007A, 082C0B48...) => return 0xA8187AD0
    3192|0x8171e34: Calling my2_IMG_Load_RW (/media/SD_PANDORA/box86-master/build/box86) (A8187AD0, 00000001, 082C0B48...) => return 0x00005089
    Segmentation fault
    
    What my game is doing at this point, is loading a PNG image from a 122 byte array in memory (embedded in source, if that matters) to the use it as a texture later.
    I can make a minimal demonstration of that if needed.


    However, it briefly looks like it's trying to show the fullscreen window with the OpenGL context it created before it segfaults. So that part works fine. :)
     
  17. ptitSeb

    ptitSeb Serial Porter

    Joined:
    Aug 15, 2012
    Messages:
    8,280
    Location:
    France, near Lyon
    The issue with current implementation of BOX86_LOG=2 is that when a Call is printed, that means it went well. Call that segfault are ot printed.
    I guess I'll have to try it too. Where is the x86 version of your game?
     
  18. elvissteinjr

    elvissteinjr Very Active Member

    Joined:
    Aug 23, 2013
    Messages:
    394
    Location:
    Germany
    It officially doesn't exist since I thought barely anyone would be running an x86 32-bit Linux nowadays (not like it's a big deal making that build, actually). I've attached the build I made for trying out in Box86. It's fully optimized and stripped though, so say if you need debugging symbols or even source code, I suppose.
    The config.ini in there is set to match what works for the Pandora. You can delete it if you're testing on some other device to get desktop defaults.

    Regarding Box86 output: I know for sure that it doesn't succeed in fully loading the texture at least, since the game does log successful texture loads. If IMG_Load_RW failed, it would've logged that as well.
    The next external call after IMG_LoadRW(rw, 1) would be SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0). Any other SDL calls you may see in the assembly between those two are in code paths which are not taken in this situation, if that helps a bit.

    Thanks for looking at this. Ultimately it doesn't matter if this game works in Box86 of course, but I think it helps with compatibility testing.
     

    Attached Files:

  19. ptitSeb

    ptitSeb Serial Porter

    Joined:
    Aug 15, 2012
    Messages:
    8,280
    Location:
    France, near Lyon
    Thanks for the binary @elvissteinjr .

    I reproduce the issue. I have slightly changed the way BOX86_LOG=DEBUG (or 2) works, and now a call that segfault should be printed.
    But it doesn't seems to be issue.
    I have that in end:
    Code:
    32668|0x81cd907: Calling __libc_malloc (/lib/libc.so.6) (0000001B, 08288000, 08288000...) => return 0xA81BB0E8
    32668|0x81ef554: Calling memcpy (/lib/libc.so.6) (A81BB0F4, 0823228C, 0000000E...) => return 0xA81BB0F4
    32668|0x81ed637: Calling strlen("embedded_debug_font") => return 0x00000013
    32668|0x81ed656: Calling memcmp (/lib/libc.so.6) (A81BB0F4, 08241BA4, 0000000E...) => return 0x00000013
    32668|0x81ed637: Calling strlen("embedded_white") => return 0x0000000E
    32668|0x81ed656: Calling memcmp (/lib/libc.so.6) (A81BB0F4, 08241BB8, 0000000E...) => return 0x00000000
    32668|0x8171e1e: Calling my2_SDL_RWFromMem (/media/sda1/sources/git/box86/build/box86) (082898A0, 0000007A, 082C0B48...) => return 0xA81BB028
    32668|0x8171e34: Calling my2_IMG_Load_RW (/media/sda1/sources/git/box86/build/box86) (A81BB028, 00000001, 082C0B48...) => return 0x00005089
    
    And that return address of my2_IMG_Load_RW seems wrong. It's supposed to be a new SDL_Surface* and can see the malloc giving stuff around 0xA81BBXXX on my run, but that one is 0x00005086, that seems wrong, and I guess accessing that to try get width or height or anything out of the pointer just segfault. I must have a typo somewhere...
    --- Double Post Merged, Mar 13, 2019 at 9:36 PM, Original Post Date: Mar 13, 2019 at 9:26 PM ---
    And I found the issue (and yes, that was some copy/pasta errors....).
    Pull latest version, and you'll see, It launches now :)
    --- Double Post Merged, Mar 13, 2019 at 9:52 PM ---
    @Farox I also fixed, somehow, the crash in Hollywood Player: there was a error in the wrapper for timer_create function. But once the timer is activated, it generate a signal, and because there is no signal handling yet in Box86, that signal make the program to quit... Also, it was too slow anyway (the little music I heard was chopy).
    Anyway, I'll have to add Signal Handling at some point I guess...
     
    levi likes this.
  20. Farox

    Farox Certified Guru

    Joined:
    Jan 8, 2009
    Messages:
    2,015
    Location:
    Italy
    Ok thanks for taking a look, and i'll retry when Signal Handling is implemented. No hurry.
    Now the hunt for a good x86 Linux application to run on Pandora restart :)
     

Share This Page

Loading...