Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
scifista42

Are sounds without DS prefix possible? (in vanilla)

Recommended Posts

With its "Strings" editor, DEHACKED allows you to rename sound names. But I haven't found a way to change or remove the default prefix for all sounds, which is DS. And also D_ for music entries. Is this possible to change somehow?

The reason why I need it: I've discovered a way how to load Heretic.wad as a PWAD for Doom in a way which doesn't trigger errors, and no graphics needed to be reincluded. I used a DEHACKED string-changing trickery and altered TEXTURE1/2 entries. A good way to bring Heretic sprites, palette and textures into Doom, isn't it? But as it seems, sounds would have to be reincluded anyway (Heretic sound names don't start with DS prefix). Am I right?

Let's talk just about vanilla (or limit-removing ports), not ZDoom and such.

Share this post


Link to post

I think you can edit DS through DeHackEd, but in that case the original DOOM sounds become invalid and must be readded with a PWAD using the Heretic prefix in the lumps. If I'm not mistaken, you have to edit d%c%s. D_ shows up as d_%s, and you'll have the same issue if you try to mix music from both games.

Although I don't remember how Heretic sounds were named, so if they don't have the S or P (%c), I think you have a problem. Heh, if you want to use the Heretic IWAD you could have a batch that calls DeuTex to check if a PWAD with the sounds is present and, if not, extracts the sounds, renames then with the DS prefix, packs then in a PWAD, and launches the game.

Share this post


Link to post

The reason the DS prefix for sounds is hardcoded is because they aren't necessarily DS. It can also be DP for the beeper version of the sounds.



Heretic does not have PC speaker sounds. Most sound lump names are only six character long, they do not have a prefix at all but they have room for one. Some sound lumps have seven characters, though.

Share this post


Link to post

Sounds in Heretic IWAD don't have any prefix. I've tried renaming d%c%s to just %s, which I thought would remove the prefix. But testing in PrBoom-plus, it doesn't work and no sound plays. Gez, why does it not work?

Share this post


Link to post

A short printf crash course: printf prints a strings with formatting, using format specifiers that start with %. (If you actually want to display the character %, you need to use %%.) The string is then followed by any number of arguments, which can be of any type. Normally, the type and number of arguments should correspond to the type and number of format specifiers (not counting %% of course), but this isn't enforced at compile-time, so you can easily crash an application by doing dumb things like:

printf("this is going to crash %s");
So here we use a printf variant (sprintf) which will give us the name of the sound lump to use based on two inputs: a single character for the sound type ('P' for PC speaker sound; 'S' for digitized sound) and a string for the sound name (like "POSSIT"). The code must have looked like this:
  sprintf(name, "d%c%s", sfxtype, sfxname);
(I say "must" because the PC speaker code was removed from the released source code, so you will not find d%c%s in it. Thanks, Bernd.)

What happens when you replace that by just %s? Then the code effectively is:
  sprintf(name, "%s", sfxtype, sfxname);
Yeah, the string specifier now corresponds to the format type character rather than to the string. The string isn't actually used for anything -- this is safe, if useless. (However, since strings are really arrays of characters, which means they really are pointers to the first character in an array, I believe it'll try to use sfxtype as a pointer to an array, which is very unsafe given the size difference between char type and pointer type, as well as the hazards of trying to access a random address.)

Anyway, the bottom line is that it has absolutely no change of working. What you want to use is the second parameter after the format string, and the only way to get it is by using the first parameter after it first.

Share this post


Link to post

Gez said:
stuff

Thanks for the explanation. So, does it mean that the string parameter I've changed simply doesn't matter in the called function? I'd need to change another parameter, which I can't and therefore it's impossible. Right?

(You know, I understand programming - being basically a self-student in this field. I just have low-to-now practical experience, so some things might not be obvious to me immediately.)

Share this post


Link to post

You'd need to change the order in which parameters are passed to the function, which is definitely not a thing that can be done with DeHackEd. If you want the function to actually work, you need to have a string that still contains %c before %s. And of course, you cannot make the string larger than the original ("d%c%s").

Share this post


Link to post

I'm a little curious what exactly would happen if the format "%.*s" is used. A quick test with modern GCC and passing a char as the precision value seems to work fine, but this sounds extremely compiler dependent. The idea is to use the type as the maximum string size ('s' or 'S' is way larger than 8 so it's effectively discarded).

Share this post


Link to post

Gez said:
Most sound lump names are only six character long, they do not have a prefix at all but they have room for one. Some sound lumps have seven characters, though.

At least that should be good enough for a modification or translation script where Doom's D is removed but the P and S are retained or added, because in DeHackEd, 8 character names would have caused an issue, but not necessarily 7, as the vanilla string for the longer DOOM sound names has a maximum length of 7 (4 to 7).

Share this post


Link to post

I've got lost in fraggle's and Blzut3's posts, apparently I didn't really comprehend the thing with "format". Changing d%c%s to %.0s%s via DEHACKED and then testing in PrBoom-plus didn't allow me to play Heretic sounds without a prefix. I apologize if I'm breaking your debate about purely coding-related hypothesis, but I am still primarily interested in my practical possibilities with DEHACKED only. If you're still willing to help me out and know the solution or impossibility of a solution, please state it clearly enough so I can comprehend it too. Besides, I certainly thank you for all the interesting related info. Even though I understand just partially, I'm glad I could get a bit of newer knowledge, as I'm actually interested in coding.

Share this post


Link to post

You cannot change d%c%s to %.0s%s because the latter is longer than the former.

You can do that in a patch that'll be accepted by PrBoom+ and other ports, but it doesn't matter because they're ports.

DeHackEd only works on the original executable. It's all it's designed to do. DeHackEd support in ports is limited to recognizing what one is trying to change, and then parsing the change and applying it at run-time. It's enough for changing map names, item pickup strings, end of episode text, and so on; but not to change stuff that isn't typically changed by mods, such as the internal format string used to retrieve sound lump names.

And this is especially true because ports do not have the same format string for this as vanilla Doom does! Remember how I said this was different in the released source code, thanks to Bernd Kreimeier's interference?

In short: even if what you want to do might be possible, it would only be possible with the vanilla exe in DOSBox, not with PrBoom+.

Share this post


Link to post

OK, thanks, I get it now. I guess reincluding/replacing sounds would be the safest solution, although I admit I'd like to avoid that situation if possible.

Share this post


Link to post

May I ask what you're trying to do? If you want to somehow use DeHackEd to turn PrBoom+ into some sort of demo-friendly and limit-removing Heretic port, you're going to run in to a lot more issues. Enemy behavior based on codepointers that don't exist in Doom (and vice-versa), powerup effects not available (to say nothing about inventory management mechanics), differences in map format (linedef types and sector types don't correspond), etc.

Share this post


Link to post

No, I'm viewing it from plain superficial modder's point of view. My intention was to create a mod for Doom engine that would make use of Heretic graphics without illegally ripping them. With my own custom DEHACKED and maps. I've already been able to create a simple map with Heretic textures and make functional new weapons using Heretic sprites using this technique (no graphic rips, just loading Heretic.wad as a PWAD, along with my own mod's PWAD). I'm just experimenting. But the sounds actually have proven to be an insurmountable problem, so I needed to reinclude them anyway.

It's kind of a downgrade from Heretic engine, I realize. On the other hand I thought it'd be cool to make such a Doom mod for PrBoom-plus as primary target port. To take advantage of the differences between Doom and Heretic engine, and also because it would address Doom players in the first place, who are familiar with Doom mechanics. I like meddling with DEHACKED and making such obscurities, too. I've planned how to make Heretic monsters more challenging and therefore achieve more Doom-like gameplay. Can't promise I'll ever finish the idea to the end, though.

Share this post


Link to post

Did you try my version of the string? It's within the length requirements, and unless the reason fraggle suggested the longer version is Watcom C not supporting %.*s, it could work. You'll of course have to patch the actual vanilla exe for the reasons Gez mentions.

I don't know how many ports wouldn't be able to support the string, but I'm more just curious if it would work at all for vanilla.

Share this post


Link to post

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
Sign in to follow this  
×