Jump to content

Is it possible to compile raine on arm device (Retropie)?


sockscap

Recommended Posts

I have a Pi3B running Retropie and some games cannot run at full speed with fbneo or mame. I'm wondering if it's possible to compile raine on this device, as I believe raine has better performance. 

I see someone did this for rg350 (https://github.com/goldmojo/raine) so it appears to be possible. I have very limited coding knowledge, but if there are compile instructions, I should be able to follow it. 

Link to comment
Share on other sites

Probably but you'll have to test that yourself, edit the makefile and be sure to uncomment the line NO_ASM = 1.

There might be a few very small bits of asm left here and there in the source though nothing complex since it works in 32 & 64 bits for the same code but there might be some very simple inline asm at some places. You can always try and if you are stuck at how to deal with some specific code, send some details and I'll take a look.

I hope you don't compile on the pi, it would be much faster to cross compile from a pc for that... but I have no pi, so I'll leave you test that.. !

Link to comment
Share on other sites

Posted (edited)

Thanks Tux! 

I don't have skills to do cross compile, so have to do this on the pi...I'm not an expert on this, hope you don't mind if I ask stupid questions. I really want to learn things and make raine work on retropie.

I download 0.96.7 souce code, edit makefile as you suggested. make fails with the following error:

Compiling c++ source/sdl/dialogs/sound_options.cpp...
source/sdl/dialogs/sound_options.cpp: In function ‘void init_sound_driver(int)’:
source/sdl/dialogs/sound_options.cpp:103:6: error: ‘SDL_GetAudioDeviceSpec’ was not declared in this scope
      SDL_GetAudioDeviceSpec(i,0,&spec);
      ^~~~~~~~~~~~~~~~~~~~~~
source/sdl/dialogs/sound_options.cpp:103:6: note: suggested alternative: ‘SDL_GetAudioDeviceName’
      SDL_GetAudioDeviceSpec(i,0,&spec);
      ^~~~~~~~~~~~~~~~~~~~~~
      SDL_GetAudioDeviceName
make: *** [makefile:1523: linux-gnu-sdl2/object/sdl/dialogs/sound_options.o] Error 1

The pi has libsdl2-dev 2.0.10 installed. This is the latest version shown in Respbian's apt. By doing some research, it appears this function is available since SDL 2.0.16.

Does this mean raine requires at least sdl2 2.0.16, and there's no way to compile it on my current retropie?

edit: what about old versions? possible to compile an old version of raine with libsdl2-dev 2.0.10?

Edited by sockscap
Link to comment
Share on other sites

You're doing a good job of finding the problem so far, 2.0.10 is quite old, I added this in december 2021 and it was already quite old, you could compile a more recent sdl2, it's quite easy to compile normally, I don't know what distribution you have on your pi but most distributions give instructions on how to compile a new package, usually it's mostly about passing the right --target argument to configure to tell where to install things (it's in /usr/local by default, and you want /usr if it's to replace the system version).

Otherwise you can just remove the functionality of this, the idea is to detect what the audio device can do to adapt to this so you'll just have to do your configuration manually. For that :

in sdl/dialogs/sound_options.cpp

delete the lines 103-105.

in sdl/sasound.c

delete line 192

normally it should work, you'll just have to make all sound configurations manually, there are defaults which should work normally though.

Link to comment
Share on other sites

Yeah. RetroPie doesn't update very frequently, the current v4.8 (adding Pi4 support) hasn't been updated for 2 years. I'm using RetroPie v4.7.1, the latest version when I built the system. As it's quite time-consuming to configure everything and most retro games are working fine, usually I only upgrade emulator cores when necessary rather than upgrade the os.

Usually I use apt-get to manage the software packages on Pi. I'm not sure if it could cause any dependency issues to other components if I manually update sdl2. The other thing is, I also run Sx05RE/EmuELEC (https://github.com/EmuELEC/EmuELEC) on several Amlogic tvbox devices. These cheap devices perform better than Pi for retro games, but unlike Pi, their software components cannot be upgraded (for 32-bit images, SDL is locked at 2.0.9). Generally it requires cross compile to build anything for these Amlogic tvbox devices, which beyonds my skillset. But I find that the programs I build on Pi usually work just fine, though sometimes I need import the missing libraries. So the idea is, if I can make raine work on retropie, I also plan to migrate them to these Amlogic tvbox devices. However, if the program I build on Pi explicitly requires a higher version of sdl, I don't think it can work on Amlogic tvbox devices. 

Therefore, if possible, I'd prefer to build raine without updating sdl version, but I fully understand that this may require too many code changes. If you evaluate that this is too troublesome and doesn't worth it, I fully understand.

Ok, so I comment the lines you mentioned. Now it fails with the following error:

Compiling source/sdl2/controllermap.c...
In file included from /usr/include/SDL2/SDL_main.h:25,
                 from /usr/include/SDL2/SDL.h:32,
                 from source/sdl2/controllermap.c:22:
/usr/include/SDL2/SDL_stdinc.h:313:20: error: size of array ‘SDL_compile_time_assert_s_arrBindingDisplay’ is negative
        typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
                    ^~~~~~~~~~~~~~~~~~~~~~~~
source/sdl2/controllermap.c:89:1: note: in expansion of macro ‘SDL_COMPILE_TIME_ASSERT’
 SDL_COMPILE_TIME_ASSERT(s_arrBindingDisplay, SDL_arraysize(s_arrBindingDisplay) == BINDING_COUNT);
 ^~~~~~~~~~~~~~~~~~~~~~~
source/sdl2/controllermap.c:117:5: error: ‘SDL_CONTROLLER_BUTTON_MISC1’ undeclared here (not in a function); did you mean ‘SDL_CONTROLLER_BUTTON_MAX’?
     SDL_CONTROLLER_BUTTON_MISC1,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
     SDL_CONTROLLER_BUTTON_MAX
source/sdl2/controllermap.c:118:5: error: ‘SDL_CONTROLLER_BUTTON_PADDLE1’ undeclared here (not in a function); did you mean ‘SDL_CONTROLLER_BUTTON_DPAD_LEFT’?
     SDL_CONTROLLER_BUTTON_PADDLE1,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     SDL_CONTROLLER_BUTTON_DPAD_LEFT
source/sdl2/controllermap.c:119:5: error: ‘SDL_CONTROLLER_BUTTON_PADDLE2’ undeclared here (not in a function); did you mean ‘SDL_CONTROLLER_BUTTON_DPAD_LEFT’?
     SDL_CONTROLLER_BUTTON_PADDLE2,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     SDL_CONTROLLER_BUTTON_DPAD_LEFT
source/sdl2/controllermap.c:120:5: error: ‘SDL_CONTROLLER_BUTTON_PADDLE3’ undeclared here (not in a function); did you mean ‘SDL_CONTROLLER_BUTTON_DPAD_LEFT’?
     SDL_CONTROLLER_BUTTON_PADDLE3,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     SDL_CONTROLLER_BUTTON_DPAD_LEFT
source/sdl2/controllermap.c:121:5: error: ‘SDL_CONTROLLER_BUTTON_PADDLE4’ undeclared here (not in a function); did you mean ‘SDL_CONTROLLER_BUTTON_DPAD_LEFT’?
     SDL_CONTROLLER_BUTTON_PADDLE4,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     SDL_CONTROLLER_BUTTON_DPAD_LEFT
source/sdl2/controllermap.c:122:5: error: ‘SDL_CONTROLLER_BUTTON_TOUCHPAD’ undeclared here (not in a function); did you mean ‘SDL_CONTROLLER_BUTTON_MAX’?
     SDL_CONTROLLER_BUTTON_TOUCHPAD,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     SDL_CONTROLLER_BUTTON_MAX
In file included from /usr/include/SDL2/SDL_main.h:25,
                 from /usr/include/SDL2/SDL.h:32,
                 from source/sdl2/controllermap.c:22:
/usr/include/SDL2/SDL_stdinc.h:313:20: error: size of array ‘SDL_compile_time_assert_s_arrBindingOrder’ is negative
        typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
                    ^~~~~~~~~~~~~~~~~~~~~~~~
source/sdl2/controllermap.c:124:1: note: in expansion of macro ‘SDL_COMPILE_TIME_ASSERT’
 SDL_COMPILE_TIME_ASSERT(s_arrBindingOrder, SDL_arraysize(s_arrBindingOrder) == BINDING_COUNT);
 ^~~~~~~~~~~~~~~~~~~~~~~
source/sdl2/controllermap.c: In function ‘WatchJoystick’:
source/sdl2/controllermap.c:570:17: error: ‘SDL_FALLTHROUGH’ undeclared (first use in this function); did you mean ‘SDL_HAT_RIGHT’?
                 SDL_FALLTHROUGH;
                 ^~~~~~~~~~~~~~~
                 SDL_HAT_RIGHT
source/sdl2/controllermap.c:570:17: note: each undeclared identifier is reported only once for each function it appears in
make: *** [makefile:1515: linux-gnu-sdl2/object/sdl2/controllermap.o] Error 1

1. I have no idea about the SDL_compile_time_assert error.

2. SDL_CONTROLLER_BUTTON_MISC1/PADDLE1/PADDLE2/PADDLE3/PADDLE4/TOUCHPAD errors: They are not defined in SDL_gamecontroller.h in sdl 2.0.10. Not suse which version initially adds them.

3. SDL_FALLTHROUGH error: It's not defined in begin_code.h. Not suse which version initially adds it.

I remember I read somewhere that you mention the old raine code is not easy to compile on non-windows platforms. Do you think it would be easier or more difficult if I choose to build an old version before december 2021 (for example, 0.91.21)?

 

 

Link to comment
Share on other sites

Wow, that's a long one this time !

1) SDL2 is backward compatible, so you won't have any problem overwriting an old version with a more recent one, assuming it's still version 2.0.x.

2) For the distribution, there are lots of distributions on the pi, see there : https://linuxconfig.org/list-of-linux-distributions-available-for-raspberry-pi
Personally, I prefer arch so I would advice the very last one in the page : linux arch on arm, but if you are still a beginner with linux you might have some hard time with it, if it's like the pc version, there is no install program, you must do most of the stuff manually, which is not a bad idea because it forces you to know your system well and it's not that hard if you follow carefully their guide. The advantage is that after that you get a rolling distribution which is always updated and the updates go very very fast on arch. For info sdl2 is at version 2.30.3 currently on pc, absolutely not comparable with your outdated thing... !

3) the main problem here : it's even harder than the previous one obviously. This controllermap.c file is taken directly from the sdl source, with some light modifications, that's what you learn if you look at the git log about this file, and it explains why it crashes so hard when you try to compile it with an sdl version older that itself. The only sane way to fix that is just to remove the ability to edit the mappings of a controller !
For that :

sdl/controls.cpp: delete line 1100 and then the whole do_mapping function from line 1102 to 1191. Then finally delete the gui call to do_mapping in line 1207, you should probably do this one 1st to keep the line numbers while going up, it's this line which should be removed :
  { _("Controller mapping"), &do_mapping },
makefile: delete line 1263.

That's the safest option here. controllermap.c is taken directly from the sdl2 source, so you might also be able to take the one there was in sdl2 2.0.10, but then you must add the modifications I added to it, even if there is not a lot of things, it's a risky operation if you are not familiar with diffs so it's really much more reasonable to remove all this.

I strongly advice that you loose more time but try to install another linux distribution on your pi, it will be a lot more beneficial in the long run. Also there are tutorials for doing cross compilations from a pc running arch, and it's quite easy to do actually now, preparing your pi programs on your pc would be much faster, although if it's a pi4 it goes at a reasonable speed I heard...

If you continue along this path of changing the source for sdl2-2.0.10, you still have to clean up the bits of x86 asm here and there, which would be the hardest part for me, for that I'll probably have to make some git commits, but we'll see if you eventually reach this point.

For info if you want to go back to a raine which was compatible with such an old sdl2, it would be version 0.92.1, which means almost the 1st raine version using sdl2, you can still get the source from git if you are curious.

Link to comment
Share on other sites

Thanks Tux for your detailed explanation!

The main purpose is retro games. I'm willing to learn things but I know I don't have the talent to be a developper. RetroPie and EmuELEC are systems designed specifically for retro gaming purpose. I'm happy that while I enjoy the retro games, I also learn a lot through using these Linux systems. Maybe this is my way of learning things. I guess I will quickly lose interest if it's just linux and no games :) 

I don't want to waste your time on changing the source for sdl2-2.0.10, unless you feel this brings value to raine. But I do feel that raine has values on these arm devices and silimar situations. They are not powerful enough and performance matters. 

I plan to try 0.92.1 and see how it goes.

Also, I haven't tested goldmojo's fork yet, because his release seems to be aarch64, while I need armv7(32-bit). The other problem is, it seems it's hard coded for RG350 controls, but I need using controllers (ideally via gamecontrollerdb.txt). But if I can compile it successfully, maybe you can guide me how to change the code for controller settings.

Hope this won't bring too much troubles to you. I will let you know when I have more info.

Link to comment
Share on other sites

Well, you should think about it twice before deciding, arch is not about dev only it has a huge package repository, I publish the arch packages here too but for x86 and x86_64 only so far. Just go to https://archlinux.org/packages/ and search the package you want, I doubt you wouldn't find it. Maybe take a look first to the site about the arm version in case it hasn't got 100% of the packages from the normal arch distrib.

And you should take a look at the changes in raine since 0.92.1, it's *HUGE*, there were lots of fixes for the sdl2 port too and you would loose most of them by going back to 0.92.1.

For the changes to git I talked about, it's because the NO_ASM version actually still uses some inline asm code, and it shouldn't, so it would be useful to all versions to clean this up, but no I don't plan to buy a pi, at least not for now...

Notice that everyone seems crazy about arm these days though, after apple, microsoft just released their surface laptop based on an arm too, so maybe I'll have some arm computer in the future but it's not planned for now... ! (but I don't plan to ever try to port raine to osx again, the way apple develops osx is crazy from my point of view, willingly making old versions incompatible to force people to update, but it's crazy for the binary package with a maintainer who doesn't want to make new versions all the time just to please apple... !).

Link to comment
Share on other sites

I see your point. I may try arch on a different TF card later, and maybe I can learn something new. 

The Amlogic devices work differently. They are very cheap (I bought them at around $10-$15 each, so I bought one for each of my TV), they boot up very fast, and you use gamepad to control everything (keyboard and mouse not required). SSH is used for advanced configurations. If needed, you can redirect the save folder to NAS, so for example you can continue playing the game at bedroom from the state you left at the living room. I run 32-bit system on old models and 64-bit system on new models. The 64-bit system supports portmaster (https://portmaster.games/games.html) with hundreds of port games avaialble (some of them can be migrated to 32-bit systems). I'm happy with it because of its simpilicity to use and setup. It would be even better if I can make raine work on them. 

Ok, so I've tried to compile the old versions. goldmojo's fork fails because it requires some special toolchain, let's forget it. 

The good news is, 0.92.1 almost succeeds to build. It fails at the linking stage. Apparently SDL_GameControllerSetPlayerIndex is only available after SDL 2.0.12. I hope this is not too hard to fix :)

Linking Raine...
/usr/bin/ld: linux-gnu-sdl2/object/sdl/control.o: in function `add_game_controller':
control.c:(.text+0xca8): undefined reference to `SDL_GameControllerSetPlayerIndex'
/usr/bin/ld: control.c:(.text+0xdc4): undefined reference to `SDL_JoystickSetPlayerIndex'
/usr/bin/ld: linux-gnu-sdl2/object/sdl/control.o: in function `set_joy_playerindex':
control.c:(.text+0x1850): undefined reference to `SDL_GameControllerSetPlayerIndex'
/usr/bin/ld: control.c:(.text+0x1858): undefined reference to `SDL_JoystickSetPlayerIndex'
collect2: error: ld returned 1 exit status
make: *** [makefile:1389: raine] Error 1

 

Link to comment
Share on other sites

Well I'll make this reply the shortest : it's obviously yet another problem because of sdl 2.0.10 which is clearly outdated here.

So decide where you want to go from here.

By the way you can view the changes in sdl since 2.0.10 there : https://github.com/libsdl-org/SDL/releases?page=4, 2.0.10 is towards the bottom of this page 4, at the top of page 1 you have the latest release.

Link to comment
Share on other sites

Could you please suggest how to change 0.92.1 source code so it can compile it with sdl 2.0.10?

I fully understand it's outdated, but I have to live with that as my Amlogic devices are locked with 2.0.9. I just want to get the most from what I already have.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...