Jump to content

Variable sizes in original source


Scet

Recommended Posts

Hi everyone. I'm once again working on my C# port of Doom and have a few questions.

I've been going through the source code and am confused as to the difference between int and short. I know short is 2 bytes, the problem is with int, I thought it was 4 bytes, but in r_defs.h some of the structures stored in the WADs that use 2-byte fields are stored as ints. fixed_t is a typedef for int and vertex_t is stored as two fixed_ts yet in the WAD it's two shorts.

Another one I don't understand is angle_t:

typedef unsigned angle_t;

Is this unsigned short or unsigned int?

Thanks.

Share this post


Link to post

int and unsigned int are 4 bytes. Many values that are stored as shorts in the map are either extended internally or converted to 16.16 fixed point numbers which technically means, the value is shifted 16 bits left.

Share this post


Link to post

It's also worth bearing in mind that the "long" type is also 32 bits. Long is used in several places in the original source, but on some architectures (and in C#) long is 64 bits.

Share this post


Link to post

I asked because I've worked on some architectures (embedded systems and 16-bit DOS programs) where int was 2-bytes in C, but being used to C# I used int everywhere thinking it would be 4-bytes. Having been written for DOS I thought Doom might have the same problem so I had to be sure.

Thanks guys.

Share this post


Link to post

Yeah my attempts at making real-mode 3D fpses in 1995 were horribly aggravating, having to use very low res textures and wacky hz sounds (8000hz), and even then you're lucky to have it running at all with sound and 3d and not playing like wolfenstein, trying to respect the strict 640kb limit. I sure don't miss those times (in development). Doom would have not been possible without protected mode

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...