Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : Development : Building DROD on Raspberry Pi (So close, yet so far...)
New Topic New Poll Post Reply
Poster Message
incredibler2
Level: Goblin
Rank Points: 20
Registered: 01-20-2013
IP: Logged

File: screenshot3.png (623.9 KB)
Downloaded 52 times.
License: Public Domain
icon Building DROD on Raspberry Pi (+6)  
Hi guys. I have been playing around with building the latest DROD 5 source code so that I can have it run on the Raspberry Pi under Raspbian OS.

It has been a learning experience for me and I am so close to getting everything working! But I am stuck at an error at runtime that I can't solve.

You can see in the screenshot attached the stage I am at right now. A windows opens with the Door.png graphic, but then I get an error dialog saying "DROD couldn't load certain files that it needs. Try closing other applications to make more memory available. It's also possible that files are missing or corrupted, and reinstalling DROD would fix this problem."

I tried adding some cout statements to the code to see up to which point initialisation fails. Eventually, I was able to deduce that it fails when loading a certain bitmap resource when loading the GameScreen class. I added some cout lines to the CWidget:Load() method in Widget.cpp around line 455.

if (!pSurface){
    std::cout << "Failed to load bitmap: " << this->imageFilenames[wIndex].c_str() << std::endl;
    return false;
}
else{
    std::cout << "Bitmap loaded successfully:" << this->imageFilenames[wIndex].c_str() << std::endl;
}


Compiling and running this gives what is shown in the terminal window in the screenshot: Failed to load bitmap: Fog1

The error is the same when using the Data folder from both full and demo versions of DROD:TSS.

Is it an error with a library? It seems strange because other resources are loading fine.

If it helps, below is the process that I followed.




Building DROD

First I cloned the official github repository, then I manually downloaded and compiled the libraries that were listed in the instructions for compiling DROD for Windows.

Compiling and building the dependencies from source was surprisingly a breeze since it is so optimised for Linux. It was a much less painful experience for me than compiling for Windows!

Once they were compiled, included and linked correctly, I encountered relatively few errors trying to build the whole project. Firstly I had to modify the architecture flags so that they were optimised for the Raspberry Pi 3. Inside the ninjamaker file in the Master/Linux directory I added a new entry called [arm] inside archflags around line 15.
archflags=(
[x86_64]="-m64"
[i686]="-m32 -march=i686"
[arm]="-mfpu=crypto-neon-fp-armv8 -march=armv8-a+crc -mcpu=cortex-a53"
)

Then I changed the options[arch] parameter accordingly around line 60
options[arch]=arm

This time after running ./ninjamaker and ./build, most C++ files are compiling successfully!

Compiling

I then encountered some compiler errors in BackEndLib/PortsBase.h and DROD/RoomWidget.cpp

In PortsBase.h an error was being raised saying "Unknown byte order. Please add your system above". Running lscpu in the terminal reveals that the system is little endian, so I modified line 81 like so:
#  if (defined(WIN32) || defined(__i386__) || defined(__x86_64__) || defined(__ARM__))

Then I added a define statement at the top of PortsBase.h

#define __ARM__


In RoomWidget.cpp there was an error in line 7706 "narrowing conversion of 'M_NONE' from 'unsigned int' to 'int'". M_NONE is the enum equivalent of -1 according to MonsterType.h so I changed the code like so
case -1: return false; //Don't show anything if player is not being shown.

Now everything is compiling successfully. Hooray!

Linking

This was mostly straightforward. The build system found nearly all of the external dependencies that I built from source in /usr/local/.

I encountered an error linking metakit: "ld: cannot find -lmk4". I couldn't figure out how to compile metakit as a static library, so I added a "-Wl,-Bdynamic" flag before the "-lmk4" flag in my ninjamaker file around line 190.

staticlibs = ... -ltheora -lvorbisfile -lvorbis -logg -ljpeg -Wl,Bdynamic -lmk4 $(${PKG_CONFIG} --libs freetype2 libpng libcurl expat jsoncpp zlib)


Finally everything is linking and building correctly, and I get an executable!

Running

I navigate to the Master/Linux/builds/custom.release.arm/ folder and copy the Data directory from my full copy of DROD:TSS. Running the game using ./drod in the terminal leads me up to the current point in the screenshot.
01-09-2022 at 06:30 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Svante
Level: Master Delver
Avatar
Rank Points: 169
Registered: 04-23-2005
IP: Logged
icon Re: Building DROD on Raspberry Pi (+3)  
I barely know what I'm doing when it comes to C++ compilation, but I compiled Metakit statically (I think? :lol) for DRODbot. The makefile is here, if it helps at all.

But I agree that it sounds weird that it would be a problem with a library. I guess you already checked that you aren't actually running out of memory?
01-14-2022 at 05:00 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
incredibler2
Level: Goblin
Rank Points: 20
Registered: 01-20-2013
IP: Logged
icon Re: Building DROD on Raspberry Pi (0)  
Thanks for the message Svante. I did some playing around with building it on Manjaro Linux on my x64 PC, and initially I was able to get it to run somehow. Then a few days later I think I changed some libraries and I ended up with the same problem :weep

The Pi 3 has 1GB of RAM with 2GB swapfile, it doesn't get anywhere near full when I run the game. So I don't think that's the issue. In any case I will try to play around with the library versions and see where it gets me :D
01-22-2022 at 05:04 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
incredibler2
Level: Goblin
Rank Points: 20
Registered: 01-20-2013
IP: Logged

File: DRODPi.zip (2.6 MB)
Downloaded 26 times.
License: Public Domain
icon Re: Building DROD on Raspberry Pi (+3)  
On a brighter note, I (almost) managed to get the DROD 2.0 engine working! There is one major bug where any levels that use the Fortress theme (e.g level 4 from KDD or JtRH) cause the game to crash when loaded. I'm still trying to figure out the cause.

I have attached a zip with the compiled executables for King Dugan's Dungeon and Journey to Rooted Hold. The only extra thing you need are the Data folders from either demo or full versions of the games, which go in the same folder as the executable.

I also tested it with RetroPie and the games seem to play well. I have added a script for adding them to the Ports menu. In the past a few people has asked about this so hopefully some people will find this useful :D
01-22-2022 at 10:45 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Building DROD on Raspberry Pi (0)  
Thank you for sharing your progress on this cool achievement!

I don't have specific things to recommend looking for with respect to the image loading issues you've been experiencing, but maybe check the attribute flags in the image metadata (e.g., alpha channel, color depth). Possibly converting settings in the particular images with issues will fix things.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 02-16-2022 07:32 PM]
02-16-2022 at 07:32 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : Development : Building DROD on Raspberry Pi (So close, yet so far...)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.