THIS IS A TOOL-ASSISTED SPEEDRUN.

IWAD: Doom 2
PWAD: 25sr50.wad
Map: D2All
Skill: Ultra-Violence
Category: UV-Speed
Exe: XDRE 2.22a
Time: 24:51
Author: almostmatt1

Comments: I expected a quick 30-minute meme run and instead got days of hex editing, scripting, demo format comparisons and code investigation. Jesus Christ.

This SR50 practice WAD involves running into a teleporter 1125 times. Simple! Just TAS the movement once, then copy+paste. Right?

First hurdle: Copying inputs. I didn't know XDRE could copy groups of inputs until after this was done, so I TASed one room and copied the inputs in a hex editor. Did this a bunch, added some level transition tics, so far so good.

Second hurdle: Map 3 desynced. Each Map 1 & 2 tele has its own identical room, but map 3 has 100 rooms with 10 tele lines: 9 single-use ones returning you to the start of the room, and one to take you to the next one. Each line has a different position so you get to some sooner or later, so I needed to re-do a 10-room chunk of movement to then copy+paste in a hex editor.

Third hurdle: Different map 3 desync. Despite there being 10 teleport lines I only hit 9 of them before going to the second room. Linedef IDs in order of appearance, and then in order of hitting them:
1069, 1030, 760, 763, 766, 720, 717, 723, 674, 677
1069, 1030, 763, 760, 766, 720, 723, 717, 677
A couple are out of order and one is skipped outright. I'm not going fast enough for a conventional linedef skip so I don't know what's going on. I just accepted the weirdness and moved on, might look into it another day.

Fourth hurdle: Complevel-specific headers. 25sr50.wad is MBF21 (cl21) but XDRE can't make cl21 demos. There are no cl21 line actions, and only a cl21-exclusive instakill floor effect if you miss a jump which isn't relevant here, so it's possible to make a cl2/3/4/9/11 demo in XDRE, but this would then have the wrong header. I made the TAS in cl11, made a cl21 demo and copied its header to my cl11 TAS. I went with cl11 as it has some slightly different wall interaction physics than prior complevels that matches MBF21 more closely, which I didn't think would matter here but I went with it just in case. So, it should sync. Should? Ooo, foreshadowing.

Fifth hurdle: Instant desync. After looking at some existing demos in a hex editor I learned cl21 encodes 5 bytes of data per tic instead of 4. Normally 5 bytes are only used for longtic demos but in cl21 its 5 bytes no matter what, so the existing demo just produced a jumbled mess of movements. The 5-byte format has an extra byte for more precise turning data, but since this is a shorttic demo the extra byte does nothing. So I wrote a little C program that took my old demo and inserted an inert 0x00 byte for each tic of movement to format the data correctly.

Sixth hurdle: It works! ... at first. Different map 3 desync. I'd used a trick on some of the different movement iterations where if the distance between you and the wall almost matches your momentum, you don't move towards it, staying in place and keeping your momentum. This pushed me closer to the tele linedef. However, I here learned that this behaviour doesn't occur in cl21, so I hit the wall, lost my speed, missed the tele, and desynced. Not sure why the bug normally happens, not sure why it doesn't happen here. To fix this I just needed to change the angle of 1 tic by 1 value so I wrote another tiny C program that found each instance of this particular movement and replaced the byte values as necessary.

Seventh hurdle. It works! ... at first. Different map 3 desync. Instead of teleporting 9 times in the second room, I teleport only SEVEN times, skipping linedefs 7, 8 and 9 before moving to the next room. Exact same map geometry and movement, new and unique movement weirdness. Because I'd copied the movement 9 times for each of the hundred rooms but each room doesn't need 9 iterations, this caused a desync.

No idea why the linedefs/rooms are so inconsistent and bizarre but that inconsistency spelled the end for my automation efforts so I then edited the nearly 45,000 copied map 3 frames manually. This absolutely turbo-sucked and I'd have never started this if I knew it's where I'd end up haha.
