the only difference between the "draw proton"/"draw duke" functions is what base address they draw from.
YOU CAN PASS ADDRESSES TO FUNCTIONS, TODD
Nope! it's known, it's just slightly mis-documented and tricky to pull off.
If you press the fire button (not alt!) and release F6 on the main menu, after launching the game with "dn1 asp", you can play the demo level
so why in the fuck does the game save your position in the level and the camera position?
You'll always be in the hallway! you can't be anywhere else!
yep. you can have it load you right into a level. you can't save a game there, but you can restore one.
weird.
> Exception while decompiling 208e:4094: Decompiler process died
this would be easier if Ghidra would STOP FUCKING CRASHING
so you can't use this trick.
now I think they could have solved this in another way: make the save function save the state of duke as he entered the level. They already save that for restoring the player when you die
oh interesting.
the game does reuse a dialog box!
just one of them: The main-hallway hints and Dr. Proton's security-camera taunts? They're literally the same system, with the two sets of text intertwined.
So sometimes a function fill be like void foobar(int a, int b, char far * string)
and ghidra will be like "oh it takes 4 parameters!"
honestly real mode x86 is such an abomination of nonsense that we should pretend it doesn't exist.
if only for the minor problem that nearly all PC software and games were written in it for like 12 years
ugh. I don't know what this function even does but I can already tell that the only difference between two adjacent functions is which pointers they use.
TODD, PARAMETERS. PARAMETERS TODD
I'm really doubting the function duplications has anything to do with aggressive compiler optimizations because there's one very small function to determine if something is onscreen or not. It's a couple additions and 4 compares. prime inlining material!
it's not inlined. it's far-called from 148 locations
oh god it even does it for static things like doors
apparently every frame it loops through the doors array and checks if the player is standing in front of them and then checks if the player is pushing the up key
@foone My recollection (I'm old) was that C compilers tended to go overboard with optimization back then, which is why ANSI has so much UB - the compiler makers didn't want to let go, and saw optimization as a way to distinguish themselves from their rivals.
That said, the 'far call to something inlineable' thing was likely to be because optimization happened within the scope of the file the compiler was compiling. If the function you were calling was in different .c file, then it wouldn't get optimized away. The fact it's a far call to that function strongly suggests, to me, that it was. TBH I don't know how current compilers do it, I'd have thought the same applies, as otherwise linking would break but the world's changed a lot in 40 years.
(Please correct me if I'm wrong, I know you do this kind of thing for breakfast, it's just I recall optimization being very, very, controversial during the 1980s, and it affecting the ANSI C standard in very negative ways.)
