# Fan of Diablo I? DevilutionX almost working on FreeBSD



## nunotex (May 10, 2019)

Hello,

DevilutionX: Diablo build for modern operating systems.








						GitHub - diasurgical/devilutionX: Diablo build for modern operating systems
					

Diablo build for modern operating systems. Contribute to diasurgical/devilutionX development by creating an account on GitHub.




					github.com
				




For those that are interested helping us to getting this project ported to FreeBSD, please read this pull request:









						Request for feedback: Making StormLib compile on FreeBSD by kraileth · Pull Request #49 · diasurgical/devilutionX
					

DevilutionX compiles without problems on FreeBSD when the address sanitizer is disabled. The only thing that requires patches is StormLib which uses some (glibc?) internal structs. I've read on the...




					github.com
				




Thanks,

Nuno Teixeira


----------



## malavon (May 10, 2019)

I've taken a (very) quick look at it.  Just a few small suggestions to make porter's lives easier. Code could use some restructuring as well to make porting easier, but that's more of an upstream issue anyway.

I would suggest doing actual detection for a FreeBSD platform (by checking for __FreeBSD__) instead of relying on the current behaviour.
It will make it easier to define FreeBSD-specific behaviour (which I assure you, there will be at least some of that).


```
//-----------------------------------------------------------------------------
// Assumption: we are not on Windows nor Macintosh, so this must be linux *grin*

#if !defined(PLATFORM_DEFINED)
```

Basically something like this (before the Linux detection) should be enough. You can just copy the Linux headers for now.


```
#if !defined(PLATFORM_DEFINED) && defined(__FreeBSD__)
```

Good luck in your endeavours. If I find the time I might chime in with some extra code, but I'm currently working on something else that takes up all my attention.

Note: to find out what's going wrong with the filesystem thingy, compile the project with debug:
`cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc8 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++8 -DASAN=OFF -DCMAKE_BUILD_TYPE=Debug .. && make`

Then debug it with gdb (lldb might also work, but since it's compiled with gcc I'd say use gdb)
`gdb ./devilutionx`

Look around the web to find out the gdb commands. 'bt' is your first friend for sure.


----------



## Crivens (May 10, 2019)

So now I can do all that time wasting from the old days _again_? Well... it was a lot of fun.


----------



## malavon (May 12, 2019)

Of course I couldn't let it go. I just had to dedicate my sunday to getting more people to game on FreeBSD 

There's a port on my GitHub repository. Copy your diabdat.mpq to `~/.local/share/diasurgical/devilution/diabdat.mpq`.
Happy gaming!

There's also a miniscule PR on the project's GitHub to do away with the patch for CMakeLists.txt


----------



## malavon (May 13, 2019)

Ok, I made a stupid mistake and the branch has also been updated. I fixed the port 

Note that right now the port builds from a specific branch, not a tag. So when that branch gets updated, your port actually changes a little (or a lot). 
Once the necessary things are in the main branch and released as a tag, I'll update it and maybe even create an official port from it


----------



## Crivens (May 13, 2019)

It will tempt me to waste weeks and months of my time, again. I've been clean for 4 years. 

Well done, good work


----------



## nunotex (May 14, 2019)

Well done all that contribute time, knoledge to projects that need to be taking into consideration. This is not a game, this is a way to remember that some fantastic and beutifull games was created to be playing in MS DOS and Win95 an now can be remembered in Linux, *BSD, etc. I think this projects very important because they remember from where we been.

Thanks for all involved here:

- Devilutionx project
- kraileth
- malavon

And all that put some flame in this thread. And it worked 

Yours,

Nuno Teixeira


----------



## Crivens (May 14, 2019)

I didn't mean to flame anything. I just feel tempted to put time into this for old times sake instead putting it into my kids. But  in some years now I can show them "This is what daddy used to procrastinate..."

And maybe it will be fun to have a match against them. You do have multiplayer, don't you?


----------



## malavon (May 14, 2019)

Crivens said:


> And maybe it will be fun to have a match against them. You do have multiplayer, don't you?


From the readme, never tested it (fun fact: I never played Diablo):


> *Multiplayer*
> 
> TCP/IP only requires the host to expose port 6112
> UPD/IP requires that all players expose port 6112
> All games are encrypted and password protected.


----------



## nunotex (May 15, 2019)

I played diablo II for years but never tried multiplayer because I was allways trying the best tree to have more fun and not to difficult to enter hardcore mode.

I played Diablo I when I don't have an internet connection and we use floppys and cds from friends.

This project is important to me because Diablo I is still considered number 1 in its style in a lot of sites.


----------



## nunotex (May 18, 2019)

malavon said:


> Of course I couldn't let it go. I just had to dedicate my sunday to getting more people to game on FreeBSD
> 
> There's a port on my GitHub repository. Copy your diabdat.mpq to `~/.local/share/diasurgical/devilution/diabdat.mpq`.
> Happy gaming!
> ...



Hello Malavon,

Will you submit this port to freebsd ports?


----------



## malavon (May 19, 2019)

nunotex said:


> Will you submit this port to freebsd ports?


Probably, once there's a release on GitHub (as opposed using a branch which can change every second). It doesn't seem to be too difficult to maintain it either, so I'll go with it.
That said, if there's someone out here who can maintain it and who would actually play it (and thus test), speak up


----------



## Spartrekus (May 19, 2019)

Is this thing Diablo opensource a sort of (Opensource DIABLO) *MMORPG for Raspberry PI* ?
can it run online on a pi?

I'd like eternallands and diablo on pi


----------



## malavon (May 19, 2019)

The FreeBSD branch has been merged into the master branch today, I updated the port to point to master now.


----------



## nunotex (May 19, 2019)

hey! good news.


----------



## nunotex (May 19, 2019)

malavon said:


> The FreeBSD branch has been merged into the master branch today, I updated the port to point to master now.



I forgot to say that you can choose a specific tag for GH_TAGNAME=1f20338 for example, instead of master tag:

editors/xi-term uses:

DISTVERSION= g20190328
that ponts to:
GH_TAGNAME= 08dd47e

That way you will have no problems with checksums with  DISTINFO, because source will be inaltered to that specific tag.


----------



## malavon (May 19, 2019)

nunotex said:


> I forgot to say that you can choose a specific tag for GH_TAGNAME=1f20338 for example, instead of master tag:


I did not know that, but I've fixed it to the latest commit now. Thanks for letting me know.


----------



## nunotex (May 20, 2019)

BTW, theres a new release 0.4.0, so you can stay with this version tag because it includes changes for freebsd:









						Release 0.4.0 · diasurgical/devilutionX
					

Based on Devilution 0.9.6 Features  Fixed flickering mouse in caves 32bit ARM build (Raspberry Pi) 32bit FreeBSD build 32bit Haiku support (see HaikuDepot) Included font for rendering credits and p...




					github.com
				




cheers


----------



## malavon (May 20, 2019)

Port added: PR 237997

Also, while checking this out I came across the following PRs for other new games to be added:
PR 227844
PR 227168

More games are incoming it seems


----------



## shkhln (May 20, 2019)

It's probably better not to package that thing by default. Decompiled code is not even in a legal grey area, it's pretty clearly constitutes copyright infringement.


----------



## hukadan (May 20, 2019)

shkhln said:


> Decompiled code is not even in a legal grey area


Pardon my ignorance on the subject, but isn't "Reverse engineered" different form "Decompiled" ? I thought the former did not constitute copyright infringement contrary to the latter.


----------



## shkhln (May 20, 2019)

hukadan said:


> but isn't "Reverse engineered" different form "Decompiled"?



https://github.com/diasurgical/devilution#faq actually mentions decompilation.



hukadan said:


> I thought the former did not constitute copyright infringement contrary to the latter.



Decompilation itself does not constitute infringement, distribution of the derived work does.


----------



## malavon (May 20, 2019)

shkhln said:


> It's probably better not to package that thing by default. Decompiled code is not even in a legal grey area, it's pretty clearly constitutes copyright infringement.


This is a legitimate concern. I've been wondering about this as well. EDIT: I'll ask this on the Bugzilla to make sure and see what comes up there.


----------



## hukadan (May 20, 2019)

I missed that part of the Readme. Just saw the "Reverse engineered" of the Credit section. Thank you for the clarification.


----------



## nunotex (May 20, 2019)

malavon said:


> Port added: PR 237997
> 
> Also, while checking this out I came across the following PRs for other new games to be added:
> PR 227844
> ...



Thanks Malavon! This is really good news.

Don't bother with "reverse engeneering" stuff. Original game is always needed.

What's new and opensourced is the engine that plays original content.

Very happy here 

Nuno Teixeira


----------



## Spartrekus (May 21, 2019)

could it run evetntuall on a pi raspberry


----------



## malavon (May 21, 2019)

Spartrekus said:


> could it run evetntuall on a pi raspberry


Maybe, I don't know the future so can't say. It uses inline x86 assembly right now.
edit:
I just saw this in the release notes:


> 32bit ARM build (Raspberry Pi)


Spartrekus if you have a Pi, could you test this? If it works I can extend the archs


----------



## Sevendogsbsd (May 21, 2019)

I just bought Diablo 1 from GoG and it doesn't play in wine at all so I have the game content. I'd be willing to test once it gets in ports, or before, I just need to figure out what I need to do.


----------



## malavon (May 21, 2019)

Sevendogsbsd said:


> I just bought Diablo 1 from GoG and it doesn't play in wine at all so I have the game content. I'd be willing to test once it gets in ports, or before, I just need to figure out what I need to do.


You can just apply the patch to your ports tree, or download an entire up to date ports tree from my GitHub.
The patch can be found in PR 237997.
To apply it (in the root of the ports dir):
`cd /usr/ports/` (or wherever your ports tree is)
`patch -p1 < patchfile`
Then just make install as usual
`cd games/devilutionX && make install && make clean`

Or if you have poudriere set up the same applies with `poudriere bulk ...` instead of building the port manually and subsequently installing the created package.


----------



## Sevendogsbsd (May 21, 2019)

OK - I have a poudriere build box so will need to set up there. Might be a few days but will report back when I get things working.


----------



## malavon (May 27, 2019)

Yesterday the port was committed to the official (latest) ports repository: games/devilutionX. Feel free to check it out from there now.
I checked and it hasn't gone through a package build cycle yet, so if you'd prefer to use a package you'll have to wait a bit longer.


----------



## Sevendogsbsd (May 27, 2019)

Building as we speak using ports-mgmt/poudriere. Required devel/llvm60 and lang/gcc8 so those will take an hour or so to build. I have the Good Old Games version of Diablo I installed in wine so will use that content once this builds. Once I get this set up, I'll report back.


----------



## malavon (May 27, 2019)

Sevendogsbsd said:


> Required devel/llvm60


I'm guessing that's required by any of the dependencies? It shouldn't be required directly by the port.

Note: using CCache with poudriere speeds up builds massively once it's filled, as long as you can dedicate several dozens of gigabytes for it (preferably on an SSD)
Note2: if you have a lot of RAM, consider setting USE_TMPFS=all in poudriere.conf and turning down the amount of builders (-J option to `poudriere bulk`)
Note3: ZFS is useful as well, especially if you can't use note 2


----------



## Sevendogsbsd (May 27, 2019)

Probably a dependency. The actual packages built was 45, but that may be dependent on the state of my system - what I have installed, last time I ran a build, etc. I am quite familiar with poudriere and have both ccache and zfs set up.  Speeding up Pourdriere Build Times

Just down to gcc8 and the devilutionX port itself so shouldn't be too much longer.


----------



## malavon (May 27, 2019)

You indeed don't need those tips  Anyway, have fun with devilutionX.


----------



## Sevendogsbsd (May 27, 2019)

So, build and install successful, I am reading your GitHub page - where exactly is the devilutionx directory? Is there a default config that I need to copy?


----------



## malavon (May 27, 2019)

Probably not my GitHub page (or at least not one I wrote)  I didn't write this software, I just made a port Makefile for it.
Did you get the post-install message (pkg-message)? It should have told you:


> Copy DIABDAT.MPQ to ~/.local/share/diasurgical/devilution/diabdat.mpq
> Pay attention to the case, the resulting file needs to be entirely lowercase!


You'll have to create that directory in order to run it.


----------



## Sevendogsbsd (May 27, 2019)

Disregard - fresh ports page instructions got me going. Awesome! Thank you. Wish I could get it running at better than 640x480, but that was it back in the day 

Actually, the directory was created for me when I ran the app first time - had to kill the pid though because no data file in that directory. Once I put the data file in that directory, it ran fine.


----------



## malavon (May 27, 2019)

Sevendogsbsd said:


> Wish I could get it running at better than 640x480, but that was it back in the day


I think the people developing the open source version have it somewhere on their roadmap to add higher resolutions or at least a 16/9 option or something like that.


----------



## Sevendogsbsd (May 27, 2019)

So much fun, plays great! I had forgotten that unlike Diablo II, you can't run. No worries, brings back memories. Funny that a game 23 year old game can still be fun.


----------



## Spartrekus (May 27, 2019)

malavon said:


> I think the people developing the open source version have it somewhere on their roadmap to add higher resolutions or at least a 16/9 option or something like that.



It is likely meant to be slow. 

Have you tried Dune 2 for Unix?
You need a supercomputer today to run it, what was running on a 386DX.


----------



## iSiek (Jun 3, 2019)

Excellent job! Diablo is running on FreeBSD - cool

However, I found out small bug in it.

Dedicated folder in home where MPQ data file is saved is recognized properly when running the game (this seems to have correct path string returned to the program).

Everthing starts fine but...
... starting new game, requires save game file creation in that folder and in my case game is not working because...
user name is changed to lower cases in the path string. That means target folder does not exists, save file cannot be created and message about 10MB free disk space is displayed - Diablo is stopped


```
DUMMY: CreateFileA : file: /home/isiek/.local/share/diasurgical/devilution\single_0.sv (/home/isiek/.local/share/diasurgical/devilution/single_0.sv)
```
whereas my login is *iSiek *not* isiek*

`$ pwd
/home/iSiek`

No permissions issue, tried this first for troubleshooting but when I create symbolic link to my existing home folder with /home/isiek (returned string from DevilutionX) everything is working fine!

As I am not a programmer can you fix that in code and release new package, please 
Maybe you will save more people whose logins are not lowercase ones.

Thank you in advance and regards,
Krzysztof


----------



## malavon (Jun 3, 2019)

iSiek said:


> As I am not a programmer can you fix that in code and release new package, please


Could you report this on the project's GitHub? I only maintain the port, I'm not directly involved with the project.
Since this issue would also come up on Linux, it would be very useful to the project to fix it.

Edit: you already use my temporary fix


----------



## iSiek (Jun 4, 2019)

> Could you report this on the project's GitHub? I only maintain the port, I'm not directly involved with the project.



Ah ok, I did not know that 
Sure, I have raised bug at  FreeBSD 64bit DevilutionX start game error #126 
I hope this would be simply fixed.

In the meantime I have found out another bug (FreeBSD 12 64bit version)
Before I will post it there is someone able to verify if this is reproducible in other systems too?

1) When I drop an item from my belt, I cannot put it back
2) When I want to swap items on belt or in items menu, they are replaced by holding item  (you can imagine my face when I wanted to reorganize my gold piles with health/mana potions ) All gold piles were replaced by potions :|

Thank you in advance for your feedback on this matter.

Regards,
Krzysztof


----------



## malavon (Jun 6, 2019)

iSiek said:


> 1) When I drop an item from my belt, I cannot put it back
> 2) When I want to swap items on belt or in items menu, they are replaced by holding item  (you can imagine my face when I wanted to reorganize my gold piles with health/mana potions ) All gold piles were replaced by potions :|


I was hoping someone else would chime in, because I only have 12.0 on amd64 as well. I do have a few broken laptops that I intend to fix and install a i386 on, but I haven't gotten around to that yet (for years ... ).
Since 64-bit is highly experimental, it's difficult to say if this is an actual game bug (although it definitely would be a bug with 64-bit systems). I don't think it's FreeBSD-specific though, so it might still be a good idea to post it on GitHub.


----------



## iSiek (Jun 16, 2019)

OK, I have a confirmation that bug with lower case path has been fixed and now there is no issue when launching new game.
Could you adjust FreeBSD port and release new package, please?

Regards,
Krzysztof


----------



## malavon (Jun 17, 2019)

iSiek said:


> Could you adjust FreeBSD port and release new package, please?


Nope, I can't 
I'll update the port once the project decides to make a new release, but I don't expect they'll do that for a single issue (nor should they).


----------

