Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML DOOM  (Read 23295 times)

0 Members and 1 Guest are viewing this topic.

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
SFML DOOM
« on: April 22, 2016, 09:25:21 pm »
DOOM, with SFML!

I was surprised to see nobody had done  this yet, so I've hacked apart the DOOM source to use SFML!

  • Uses SFML for window, events, audio, networking and graphics
  • Should be straightforward to build on any platform SFML supports
  • You can use controller or keyboard and mouse for input
  • Toggle fullscreen with ctrl+f
  • Uses the original software renderer and timidity for software audio synthesising
  • I've played with the shareware, DOOM and DOOM2 wads, as well as the E1M8b wad which John Romero recently released



Multiplayer works with the original command line params ("-net"), but I've only managed to get it to work on the local network.

If you have any questions or feedback fire away!

Source and release here: https://github.com/JonnyPtn/SFML-DOOM
« Last Edit: March 20, 2017, 06:25:49 pm by Jonny »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML DOOM
« Reply #1 on: April 25, 2016, 11:31:04 am »
It's a cute idea but for low level things like these I think SDL has became the default library.
Especially since Doom 1 and 2 are pure software renderers (unless one of ports or hacks changed that, but I never followed them).
To get 8 bit samples to 16 bit you could have just multiplied them by 256 and put in the 16 bit variable, not squared them.
It sadly doesn't work on Linux so I can't see it... :P
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML DOOM
« Reply #2 on: April 25, 2016, 11:36:52 am »
Nice! :)

It's a cute idea but for low level things like these I think SDL has became the default library.
So what? Everyone can use whatever they want, no need to restrict yourself to what anyone thinks is the "default" library, however you want to define such a thing anyways...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: SFML DOOM
« Reply #3 on: April 25, 2016, 11:51:39 am »
It's a cute idea but for low level things like these I think SDL has became the default library.

Funnily enough I think SDL DOOM was one of the very first source ports. I'm not particularly doing this with any purpose in mind, and certainly not looking to make any sort of competing DOOM source port. Just having a bit of fun and seeing where it goes. Hardware rendering would definitely be on the cards, but probably quite far down the line

Currently the main issue with Linux builds is that it needs to be a 32bit build, which I understand can be a bit of a pain? It's something I'm hoping to look at and rectify this week though.

And thanks for the tip on the audio, will try that instead!
edit: Just tried your tip on the audio, and it sounds worse (to me)? Line 365 of s_sound.cpp is the one to change if anyone wants to test. I'll try and grab some video footage to show you the difference
edit 2: They actually sound roughly the same, I guess I'd just forgotten how bad it sounded :P
« Last Edit: April 25, 2016, 11:59:49 am by Jonny »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML DOOM
« Reply #4 on: April 25, 2016, 01:08:50 pm »
I have 32 bit Linux.
The problem is that you use C++11 features but CMake doesn't set the right flag for them and if I do so myself then there are still some functions missing and many warnings like:
./d_englsh.hpp:24:72: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define QLPROMPT        "do you want to quickload the game named\n\n'%s'?\n\n"PRESSYN

i_sound.cpp:576:3: error: use of undeclared identifier '_write'; did you mean 'write'?
  _write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL);
  ^~~~~~
 
and so on (there is over 4000 lines of error log, maybe I missed some flag now :P).

Quote
Hardware rendering would definitely be on the cards, but probably quite far down the line
Even Doom 1 emulated in Doom 3 does it via pure software so it clearly isn't worthwhile or id would do it themselves then.
Maybe port Quake (or event better - Hexen 2!) to SFML if you want to play with GL.

Although the id tech technology is so widely proliferated (and so old and hack-y since most of it was written by a single person on computers not meant for gaming) that it seems SO not worthwhile. :-\
There are like 3 or 4 Radiants and a lot of games, ports, mods and forks of each engine at this point.
But of course if you have fun then it's all great.
And anything you learn is applicable - SFML and these engines are totally viable for indie or non commercial games.
I don't want to sound discouraging, just sharing my opinion, to me the id technology tree is just too daunting and too hardcore.
« Last Edit: April 25, 2016, 01:14:54 pm by FRex »
Back to C++ gamedev with SFML in May 2023

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: SFML DOOM
« Reply #5 on: April 25, 2016, 02:00:42 pm »
Maybe port Quake (or event better - Hexen 2!) to SFML if you want to play with GL.

I don't want to play with GL in particular

Mario set up CMake and I haven't used it yet so I hadn't noticed the missing flag, that's easily fixed, and yeah you need to turn off every warning to get close to compiling. It's over 20 years old so to be expected!

Like I said, just doing it for fun. I'm fully aware of the difficulties, but couldn't really give a hoot to be honest.

I've been using SFML professionally (and unprofessionally) on a daily basis for almost 3 years, so I'm not really doing it to learn SFML, I'm doing because I'm interested in doom, and I enjoy a challenge.

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: SFML DOOM
« Reply #6 on: April 29, 2016, 01:29:33 pm »
Thumbs up for DOOM!  ;D
Thought about doing the same thing for Duke Nukem 3D, but after reading through the original source code for some hours I completely scrapped the idea, because D3D original source is a horrible mess. Maybe I should give the Doom Source a go ;)

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML DOOM
« Reply #7 on: April 29, 2016, 02:15:38 pm »
There exists a cleaner version of Duke than the original one if you want to give it a go: http://fabiensanglard.net/duke3d/chocolate_duke_nukem_3D.php
Back to C++ gamedev with SFML in May 2023

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: SFML DOOM
« Reply #8 on: April 29, 2016, 07:36:38 pm »
Haha I'd be surprised if you find the DOOM source much better. It does an awful lot of funky stuff which allowed it to run on PCs in the 90's. But I haven't seen Duke code so couldn't say for sure. That site looks really useful though FRex!

Made a lot of improvements to SFML-DOOM over the past week or two. It's a lot more stable and has  lot more things implemented. The only major things now are the networking (which I haven't attempted yet, but will get round to) and the music, which is giving me a real headache.

I also got it building on Linux 32bit too, so hopefully you shouldn't have any trouble if you want to give it another go FRex (hopefully I updated Cmake and everything correctly, let me know if not).

I've got some videos and stuff to add to the OP which I'll hopefully get round to in the next few days

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML DOOM
« Reply #9 on: April 30, 2016, 01:10:29 am »
It builds now without a problem but it sounds like the sound is totally busted especially the menu going down like blood when you start a new game sounds VERY bad and screechy. And is there no music at all in shareware version?
Back to C++ gamedev with SFML in May 2023

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: SFML DOOM
« Reply #10 on: April 30, 2016, 01:50:00 pm »
Yeah the sound is the main thing I want to get sorted before  tackling networking. Currently the sounds have no position so everything sounds like it's right in your face.

And yeah the music has been annoying me (that's what the weird screech on level load is meant to be...) haven't worked out how to tackle it yet but hopefully I'll work something out. I was hoping it would just be 8 bit samples like the sound effects but it seems a whole lot more complicated than that

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: SFML DOOM
« Reply #11 on: May 05, 2016, 11:17:44 pm »
Part of your sound problem is the fact that you're doing the upsampling wrong. :)

Basically, an 8 bit sample ranges from 0 to 255, so you've got 256 steps.
A 16 bit sample ranges from 0 to 65,025, so you've got 65,026 steps.

The upscaling has to be done in a very simple rule of three: s_16(x) = s_8(x) * f

f is the factor between 255 and 65,025, which essentially is 255 as well (and this is probably what confused you).

So, to fix the distorted sounds, change the scaling from "sample * sample" to "sample << 8". However, since this will get you ugly distortions (capping out on full volume), I'd suggest using "sample << 7 " instead.

While this won't get you smooth curves, you'll get perfect upsampling without new distortions the best way you can do without modifying the actual input.

Tried it locally, but didn't bother to write a pull request for this simple change, but this makes sound quality a lot better and you're now also able to differentiate the different death screams of enemies.

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: SFML DOOM
« Reply #12 on: May 05, 2016, 11:29:36 pm »
Yeah sounds awesome Mario, thanks!

I've got the correct sounds working now too except for the player direction so hopefully both things make a vast improvement!

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML DOOM
« Reply #13 on: May 06, 2016, 08:50:41 am »
You've made a small mistake (two opening brackets but three closing ones):
/home/frex/code/SFML-DOOM/s_sound.cpp: In function ‘void S_StartSoundAtVolume(void*, int, int)’:
/home/frex/code/SFML-DOOM/s_sound.cpp:359:57: error: expected ‘;’ before ‘)’ token
    newData.push_back(static_cast<sf::Int16>(data[i])<<7));
Back to C++ gamedev with SFML in May 2023

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: SFML DOOM
« Reply #14 on: May 06, 2016, 12:11:39 pm »
Ah thanks for pointing that out FRex, that'll teach me for being a doofus and committing without checking!