Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Linguica

joyb_speed 31

Recommended Posts

Why exactly was 31 the value that got doom(2).exe to turn on autorun? It seems like an awfully weird number to do so.

Share this post


Link to post

I say it was a dartboard. They figured that random values were best.

Share this post


Link to post

Ling, you're task for the day is to ask Romero that very question and report your answer on #zdoom :P

Share this post


Link to post

In short, it's an array overflow. Two snippets of code from g_game.c:
(1)

boolean         joyarray[5];
boolean*        joybuttons = &joyarray[1];              // allow [-1]
(2)
speed = gamekeydown[key_speed] || joybuttons[joybspeed];
(where joybspeed is initialised from joyb_speed in the .cfg file by code in m_misc.c)

From (1) joybuttons[joybspeed] i.e. joybuttons[31] is so far off the end of the array (and the stuff after it) that it's hitting on some code or data that is permanently non-zero. Precisely what that is could only be determined by disassembling executables. Anyway, then speed in (2) is permanently true, and you get always-run.

It wasn't a deliberate choice. It just happened to be true because of the way in which the compiler built the executable, and of course people editing illegal values into their .cfg files.

I haven't tried it but 666 might well work...

Share this post


Link to post

I don't think that 31 is needed, I used a value of 30 to set doom2 autorun when I used to play on DWANGO. Shit, no one told me about that for at least a year when I played, so I got so used to holding my left pinky on the shift key that I still do it.

Share this post


Link to post
RjY said:

In short, it's an array overflow. Two snippets of code from g_game.c:
(1)

boolean         joyarray[5];
boolean*        joybuttons = &joyarray[1];              // allow [-1]
(2)
speed = gamekeydown[key_speed] || joybuttons[joybspeed];
(where joybspeed is initialised from joyb_speed in the .cfg file by code in m_misc.c)

From (1) joybuttons[joybspeed] i.e. joybuttons[31] is so far off the end of the array (and the stuff after it) that it's hitting on some code or data that is permanently non-zero. Precisely what that is could only be determined by disassembling executables. Anyway, then speed in (2) is permanently true, and you get always-run.

It wasn't a deliberate choice. It just happened to be true because of the way in which the compiler built the executable, and of course people editing illegal values into their .cfg files.

I haven't tried it but 666 might well work...

That sounds about right. Too far (666) and you're likely to cause doom to crash, though. I seem to remember trying to get autorun to work in the final doom dos .exe, but I had to use a slightly different value for joyb_speed (it was like 32 instead of 31, something like that)

Share this post


Link to post

The difference is that joyb_speed 31 will cause autorun using DOOM II's doom2, but not with Final DOOM's. If you set it to 29 it will work on both engines. The Ultimate DOOM's EXE responds like DOOM II's.

Share this post


Link to post
Guest
This topic is now closed to further replies.
×