User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Prepare for Descent

Thu Aug 09, 2012 4:45 pm

Hi,

let me announce the successfull port of another great game: Descent (& Descent2) in its current open-source incarnation dxx-rebirth (http://www.dxx-rebirth.com).
raspi-d1x-rebirth.jpg
Photo of RPi with Descent Level 1
raspi-d1x-rebirth.jpg (64.05 KiB) Viewed 8050 times


SOURCE CODE and BUILDING on the PI
The official source tarballs of dxx-rebirth beginning with version 0.58.1 support the RPi out of the box, no external patches are needed any more.

My beta builds are based on my current unification/rpi branch at https://github.com/derhass/dxx-rebirth. However, all of my patches have been merged into the official code base, so building from https://github.com/dxx-rebirth/dxx-rebirth should work too (but that branch is still experimental and building might break).

Building on the RPi is done by:

Code: Select all

scons raspberrypi=1 [other options you might want to use, see scons -h] 
For the latest builds on based on the unification branch, you should install gcc-4.9 which is in the raspbian jessie repo (the code base has been rewritten to modern C++, older compilers have some issues):

Code: Select all

CC=gcc-4.9 CXX=g++-4.9 scons raspberrypi=1 [...] 
There is no explicit support for cross-compiling yet. But you might get this to work.

The dxx-rebirth project already has an OpenGL ES 1.1 port, so this patch only adds the VideoCore API stuff. There is a README.RPi which hopefully explains all that is necessary to get this to work.

I'm very interested in having some other users beta-test this.

GETTING THE FULL VERSION

If you want to buy the full versions, I recommend grabbing them as DRM-free downloads from gog.com: If you still have your old D1/D2 CDs or disk sets, you can of course extract the needed files from there. You might also be able to still find some sellers for some used retail CD versions.


Regards,
derhass
Last edited by derhass on Sun Mar 17, 2019 4:09 pm, edited 5 times in total.
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

asb
Forum Moderator
Forum Moderator
Posts: 853
Joined: Fri Sep 16, 2011 7:16 pm

Re: Prepare for Descent

Thu Aug 09, 2012 5:29 pm

That is absolutely fantastic, I had no idea dxx-rebirth already had a gles backend. I need to break out my joystick and give this a go. If anyone needs the level packs, Descent 1+2 are super cheap on GOG and DRM-free http://www.gog.com/en/gamecard/descent_1_descent_2

SSilver2k2
Posts: 179
Joined: Wed Jun 06, 2012 1:51 am
Location: United States

Re: Prepare for Descent

Thu Aug 09, 2012 7:31 pm

Wooot! Loved this series so much, I could never finish any of them though lol.

Can't wait to try this.
My blog of various geeky things - http://blog.sheasilverman.com
PiPLAY - http://piplay.org
DeskCade.com - Mini Raspberry Pi Arcade Cabinet

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32345
Joined: Sat Jul 30, 2011 7:41 pm

Re: Prepare for Descent

Thu Aug 09, 2012 8:30 pm

One of my most favourite games ever.

Awesome.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32345
Joined: Sat Jul 30, 2011 7:41 pm

Re: Prepare for Descent

Thu Aug 09, 2012 8:31 pm

Actually, to the OP - what did you have to do to port to the Raspi? Would be well worth a write up to help others out who might be porting code.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

asb
Forum Moderator
Forum Moderator
Posts: 853
Joined: Fri Sep 16, 2011 7:16 pm

Re: Prepare for Descent

Thu Aug 09, 2012 9:19 pm

jamesh wrote:Actually, to the OP - what did you have to do to port to the Raspi? Would be well worth a write up to help others out who might be porting code.
The patches are very readable. As this Descent source port was wonderful enough to already support GLES, it seems it mostly needed a little vc_dispman glue and to deal with the fact the native window type isn't an X11 window.

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Thu Aug 09, 2012 9:34 pm

asb wrote: The patches are very readable. As this Descent source port was wonderful enough to already support GLES, it seems it mostly needed a little vc_dispman glue and to deal with the fact the native window type isn't an X11 window.
Yeah, this sums it up quite well. A little bit reading the /opt/vc headers, a little bit googling, and a little bit of guessing...
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

pmk
Posts: 21
Joined: Wed Jun 20, 2012 5:27 pm

Re: Prepare for Descent

Fri Aug 10, 2012 10:05 am

One of my favourite games. I will be interested in testing it on my Pi ......

tulblut
Posts: 11
Joined: Fri Aug 10, 2012 10:07 pm

Re: Prepare for Descent

Fri Aug 10, 2012 11:07 pm

I'm quite a newbie linux user, any help in how to compile this?

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK

Re: Prepare for Descent

Fri Aug 10, 2012 11:16 pm

Pretty much the only game I ever played on a PC.
(I used to run in on a 25Mhz 486SX with 4MB RAM and it used to crash 1 in every 3 attempts to finish each level and move to the next one until I eventually forked out for another 4MB of RAM)

So hopefully, it'll be like SOAS on a 256MB 700Mhz machine with a GPU :)

Si
PS Can I really plug my Sidewinder into my RPi :)

PPS Can't wait for a RPi LAN battle - I might not be any good with Quake but by golly I reckon I used to be Gold Medal class on Descent :)
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Fri Aug 10, 2012 11:51 pm

tulblut wrote:I'm quite a newbie linux user, any help in how to compile this?
Well. First make sure you have installed all the dependencies, that is all the libraries the game is using (packages libsdl1.2-dev libsdl-mixer1.2-dev libphysfs-dev on debian/raspbian) and the compilers and tools ( build-essential scons patch should do on debian/raspbian). Then download the original game sourcecode and extract it to some directory.
Download the patches, you can apply them by running (from the top level directory of the just extracted archive):

Code: Select all

zcat d1x-rebirth-rpi.diff.gz | patch -p1
Now you are ready to compile the game:

Code: Select all

scons raspberrypi=1
It will take some time on the RPi (maybe 30 minutes or so, never measured it). If everything works, you will end up with an executeable file called d1x-rebirth. If not, just report back what went wrong... ;)

Finally, you have to install the game content. Have a look at http://www.dxx-rebirth.com/game-content/. By default, the game will expect the data files in /usr/local/share/games/d1x-rebirth. The file INSTALL.txt should explain which data files are required...

Regards,
derhass
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

SSilver2k2
Posts: 179
Joined: Wed Jun 06, 2012 1:51 am
Location: United States

Re: Prepare for Descent

Sat Aug 11, 2012 12:58 am

It took about 25 minutes for Descent 1 and a little faster for Descent 2. My Pi is overclocked to 900Mhz.

Do you know where to get the shareware datafiles for Descent 2 (if needed)?

Also, with Descent 1, I get past the intro, but it crashes saying can't find joystick when the level tries to load. Any idea why?
My blog of various geeky things - http://blog.sheasilverman.com
PiPLAY - http://piplay.org
DeskCade.com - Mini Raspberry Pi Arcade Cabinet

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Sat Aug 11, 2012 1:30 am

SSilver2k2 wrote: Do you know where to get the shareware datafiles for Descent 2 (if needed)?
Look here: http://www.dxx-rebirth.com/game-content/ (Scroll down to Shareware/Demo Content)
SSilver2k2 wrote: Also, with Descent 1, I get past the intro, but it crashes saying can't find joystick when the level tries to load. Any idea why?
Hmm. During testing, I never had a joystick connected. Never got that message, though.
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Sat Aug 11, 2012 2:03 am

SSilver2k2 wrote: Also, with Descent 1, I get past the intro, but it crashes saying can't find joystick when the level tries to load. Any idea why?
I think you mean that libsdl message? Actually, this message is printed right when the game starts, before the intro. I don't think that it is connected to the crash.

You can try to run with -debug -verbose and see if this gives some insight into what's going on before the crash. IIRC, the -debug switch will also work in release builds, but it won't hurt if you rebuild with debug=1...
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

SSilver2k2
Posts: 179
Joined: Wed Jun 06, 2012 1:51 am
Location: United States

Re: Prepare for Descent

Sat Aug 11, 2012 4:39 am

Sounds like a plan.
My blog of various geeky things - http://blog.sheasilverman.com
PiPLAY - http://piplay.org
DeskCade.com - Mini Raspberry Pi Arcade Cabinet

CodenameV
Posts: 29
Joined: Sat Aug 11, 2012 11:42 am

Re: Prepare for Descent

Sat Aug 11, 2012 12:52 pm

Well I got the D1x to compile with no problem and it plays like a dream, so I moved onto d2x when attempting to compile I get an error message

Compiling main/ai2.c ...
main/ai2.c: In function âai_fire_laser_at_playerâ:
main/ai2.c:1024:1: error: unrecognizable insn:
(insn 532 531 533 7 (set (subreg:SI (reg:DI 315 [ Robot_info[D.11072_27].boss_flag ]) 0)
(sign_extend:SI (mem/s:QI (plus:SI (reg:SI 313)
(const_int 280 [0x118])) [0 Robot_info[D.11072_27].boss_flag+0 S1 A8]))) main/ai2.c:915 -1
(nil))
main/ai2.c:1024:1: internal compiler error: in extract_insn, at recog.c:2109
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cc4LxBw3.out file, please attach this to your bugreport.
scons: *** [main/ai2.o] Error 1
scons: building terminated because of errors.

I broke this down a little a the exact line causing the problem as stated in the ai_fire_laser_at_player subroutine

if (Boss_dying_start_time & Robot_info[obj->id].boss_flag)
return;

if i rem these out it will compile but when executed its blank screen time ( I sure this has nothing to do with it )

I did a quick search and found a reference to a level 2 optimization issue so I forced in -O1 but still the same problem.
so 2 questions
1 anyone have any ideas how to solve this
2 anyone have a precompiled binary for raspbian so I can test out my blank screen problem

thanks all
CodenameV

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Sat Aug 11, 2012 1:33 pm

CodenameV wrote:Well I got the D1x to compile with no problem and it plays like a dream, so I moved onto d2x when attempting to compile I get an error message

Compiling main/ai2.c ...
main/ai2.c: In function âai_fire_laser_at_playerâ:
main/ai2.c:1024:1: error: unrecognizable insn:
(insn 532 531 533 7 (set (subreg:SI (reg:DI 315 [ Robot_info[D.11072_27].boss_flag ]) 0)
(sign_extend:SI (mem/s:QI (plus:SI (reg:SI 313)
(const_int 280 [0x118])) [0 Robot_info[D.11072_27].boss_flag+0 S1 A8]))) main/ai2.c:915 -1
(nil))
main/ai2.c:1024:1: internal compiler error: in extract_insn, at recog.c:2109
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cc4LxBw3.out file, please attach this to your bugreport.
scons: *** [main/ai2.o] Error 1
scons: building terminated because of errors.
Hmpf, a gcc bug. I can confirm that this happens here too, when I use the default raspbian gcc-4.6. However, I did my testing with gcc-4.7 (also available in raspbian) and it works fine here. Also, I was successfully able to build with debug=1 (no optimizations) with the default gcc-4.6.
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

CodenameV
Posts: 29
Joined: Sat Aug 11, 2012 11:42 am

Re: Prepare for Descent

Sat Aug 11, 2012 3:11 pm

derhass wrote:
CodenameV wrote:Well I got the D1x to compile with no problem and it plays like a dream, so I moved onto d2x when attempting to compile I get an error message

Compiling main/ai2.c ...
main/ai2.c: In function âai_fire_laser_at_playerâ:
main/ai2.c:1024:1: error: unrecognizable insn:
(insn 532 531 533 7 (set (subreg:SI (reg:DI 315 [ Robot_info[D.11072_27].boss_flag ]) 0)
(sign_extend:SI (mem/s:QI (plus:SI (reg:SI 313)
(const_int 280 [0x118])) [0 Robot_info[D.11072_27].boss_flag+0 S1 A8]))) main/ai2.c:915 -1
(nil))
main/ai2.c:1024:1: internal compiler error: in extract_insn, at recog.c:2109
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cc4LxBw3.out file, please attach this to your bugreport.
scons: *** [main/ai2.o] Error 1
scons: building terminated because of errors.
Hmpf, a gcc bug. I can confirm that this happens here too, when I use the default raspbian gcc-4.6. However, I did my testing with gcc-4.7 (also available in raspbian) and it works fine here. Also, I was successfully able to build with debug=1 (no optimizations) with the default gcc-4.6.
Hi derhass, yep your correct I compiled it with the debug=1 option and went through with no errors, but still I have to display , d1x-rebirth works great could it be a problem with the patch ?? should I try it with gcc-4.7 ??? could you post your tested binary for me to test ???

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Sat Aug 11, 2012 3:19 pm

derhass wrote:However, I did my testing with gcc-4.7 (also available in raspbian) and it works fine here.
Or not...

gcc-4.7 with optimizations turned on seems to have some alignment issues, the game might crash with SIGBUS anytime, with the kernel complaing:

Code: Select all

[  183.220793] Alignment trap: not handling instruction edd16a01 at [<000c2acc>]
[  183.228520] Unhandled fault: alignment exception (0x011) at 0x00eed33a
I will investigate further on what is going on.

The current status is: d1x and d2x can be built unoptimized with gcc-4.6, but are slow, d1x can be built with optimization with gcc-4.6, d2x will trigger that compiler bug. Both can be built with gcc-4.7 and optimizations, but will not run (for long) due to the issue mentioned above. This is the kind of problems I did not expect... :roll:
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

CodenameV
Posts: 29
Joined: Sat Aug 11, 2012 11:42 am

Re: Prepare for Descent

Sat Aug 11, 2012 3:25 pm

derhass wrote:
derhass wrote:However, I did my testing with gcc-4.7 (also available in raspbian) and it works fine here.
Or not...

gcc-4.7 with optimizations turned on seems to have some alignment issues, the game might crash with SIGBUS anytime, with the kernel complaing:

Code: Select all

[  183.220793] Alignment trap: not handling instruction edd16a01 at [<000c2acc>]
[  183.228520] Unhandled fault: alignment exception (0x011) at 0x00eed33a
I will investigate further on what is going on.

The current status is: d1x and d2x can be built unoptimized with gcc-4.6, but are slow, d1x can be built with optimization with gcc-4.6, d2x will trigger that compiler bug. Both can be built with gcc-4.7 and optimizations, but will not run (for long) due to the issue mentioned above. This is the kind of problems I did not expect... :roll:

well on the upside Ive stopped being stupid and set my memory to 128/128 and guess what now I get a display :) , so now it just seems to be your issue of optimizations with gcc which is stopping full speed, although , I was running d1x-rebirth with graphic filters as high as i could go and it was running like a dream ( just the sound was a little intermitent) , but anyhow thanks for get this code to work on the PI almost my old fav's are on the PI duke nukem 3d , wolf 3d , quake 2 , and most of the major emulators , its all awesome work by those concerned.

CodenameV

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Sat Aug 11, 2012 3:30 pm

CodenameV wrote:Hi derhass, yep your correct I compiled it with the debug=1 option and went through with no errors, but still I have to display , d1x-rebirth works great could it be a problem with the patch ?? should I try it with gcc-4.7 ??? could you post your tested binary for me to test ???
Forget gcc-4.7 for now (see my other post). The patch should be OK. Actually, the patches are nearly identical, they only differ in line numbers and the SConstruct file.

When does the black screen occur? Directly when you start the game? d2 will try to play videos first (which work for me). Have you tried pressing ESC during the black screen? Also, you could try the -nomovies switch. Also try running with -debug -verbose.

Due to the compiler problems and further tests I'm doing right now, I've currently no working binaries lying around. But I will upload some as soon as I have something working again...
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Sat Aug 11, 2012 3:43 pm

CodenameV wrote: well on the upside Ive stopped being stupid and set my memory to 128/128 and guess what now I get a display :) , so now it just seems to be your issue of optimizations with gcc which is stopping full speed, although , I was running d1x-rebirth with graphic filters as high as i could go and it was running like a dream ( just the sound was a little intermitent) , but anyhow thanks for get this code to work on the PI almost my old fav's are on the PI duke nukem 3d , wolf 3d , quake 2 , and most of the major emulators , its all awesome work by those concerned.
Nice to hear that it is working now. For the sound: noticed that too, maybe I should increase the buffer size a bit. It was easy for me to ignore that issue so far because I currently do not have any speakers connected ;)

Actually, I myself was a bit shocked once I learned that 64MB VRAM was not enough for a game which originally ran on PCs with 4MB of RAM . The texture caching approach of the GL port seems to be a bit wasteful.
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Sat Aug 11, 2012 4:49 pm

CodenameV wrote: I broke this down a little a the exact line causing the problem as stated in the ai_fire_laser_at_player subroutine

if (Boss_dying_start_time & Robot_info[obj->id].boss_flag)
return;
So. I looked at the code here a bit and I think that
a) the compiler should not crash at this line and
b) that line is total bullshit anyways

Boss_dying_start_time is a 64bit integer timestamp (initialized to 0) and boss_flag not a flag but an int which encodes different boss types, with 0 being no boss at all.

I think they meant

Code: Select all

      if (Boss_dying_start_time && Robot_info[obj->id].boss_flag)
              return;
So, the compiler bug brought a game logic bug to attention. I will report this to the dxx-maintainer and try to build my PI port with that fix... :D
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

User avatar
derhass
Posts: 32
Joined: Thu Aug 09, 2012 4:33 pm
Location: Germany

Re: Prepare for Descent

Sat Aug 11, 2012 6:10 pm

OK for anyone who is interested:

Here are my release binaries built on raspbian/wheezy with the default gcc (4.6):
http://www-user.tu-chemnitz.de/~heinm/d ... rebirth.xz
http://www-user.tu-chemnitz.de/~heinm/d ... rebirth.xz
These are just the binaries, no .deb packages. Do not forget to set the x bit after decompressing the files. They expect the data files in /usr/local/share/games/d[12]x-rebirth. If you placed your files at another location, use the -hogdir switch.

Note: This is based on the 0.57.3 dxx-rebirth codebase plus the RPi patches and some additional changes which are not (yet) in the upstream version of dxx-rebirth. You can find all the patches that I applied here:
http://www-user.tu-chemnitz.de/~heinm/dxx/

Second note: I also updated the rpi patches slightly: they now explicitely link against -lbcm_host. (This solves some problems when using gold instead of ld).
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

SSilver2k2
Posts: 179
Joined: Wed Jun 06, 2012 1:51 am
Location: United States

Re: Prepare for Descent

Sun Aug 12, 2012 3:05 am

I just posted a tutorial on how to build Descent (as well as binaries).

http://blog.sheasilverman.com/2012/08/descent-tutorial/
My blog of various geeky things - http://blog.sheasilverman.com
PiPLAY - http://piplay.org
DeskCade.com - Mini Raspberry Pi Arcade Cabinet

Return to “Gaming”