the weird thing is the equates table says it's been set, says there's a reference to it at that address, but if I go to that address, there's nothing. just 0x3c4
OH GOODY I found a mistake in OSDEV
their docs on the PC gameport are incorrect
and I can't rename some local variables either!?
okay I've fixed OSDEV:
https://wiki.osdev.org/Game_port
They had the introduction of the gameport listed as "the PCjr" (it's from 1981, the PCjr came out in 1984... and didn't even have this gameport connector!) but more importantly, they had the order of the joystick axises wrong.
and the IBM Game Control Adapter is mentioned in the August 1981 IBM PC Technical Reference, so IBM clearly had the gameport ready at day one of the IBM PC, even if it was an optional add-in.
mind you, on the IBM PC, just about everything is an optional add-in. You get a keyboard and a cassette port for free: you want graphics/text, floppies, hard drives, serial/parallel ports? that's extra.
god. Duke Nukem 1 has so much copy-pasted code.
Like, there's a ton of hint dialog boxes like "You need the key to open this door!" or "you get more points if you catch the balloon"
you'd think they'd just have ShowMessage() and pass it a different string, but nope. it's a different function.
LEARN TO WRITE REUSABLE FUNCTIONS
interesting. there's 12 hint-variables which are used to make sure you don't get hinted for something you've used before.
One of them is still maintained, but not used. So there must have been another hintable thing that got dropped
although I'm looking at DN1, episode 1. Maybe it does do something in DN1E2 or DN1E3?
because yeah this was also the era where you'd have 3 separate executables for 3 separate episodes of the same game
like, it has a function that loops through all 16 color indices and sets them to black. it takes one parameters, which tells it how long to wait between each color is set, so it'll fade slowly to black, instead of being instant.
there's also an identical function that does the same, but sets it to white, instead.
so instead of fade_screen(COLOR_BLACK) and fade_screen(COLOR_WHITE), it's two separate functions!
naturally instead of a function like "adjust_duke_health(n)" there's a "give_duke_one_health_point" function
todd replogle: look, I know programmers who use function parameters and data-driven design, and they're all cowards
The game starts with these two screens.
There's a function to draw Dr Proton, a different function to draw Duke Nukem, a function to draw Proton's text, and another function to draw Duke's
the only difference between the "draw proton"/"draw duke" functions is what base address they draw from.
YOU CAN PASS ADDRESSES TO FUNCTIONS, TODD
there are 5 of these functions in total.
Exactly identical, except they point to different buffers for different fullscreen images
oh god please don't tell me there's a hidden cheat code that's been missed for... 32 years?
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
there is some extra code for checking the command line for another code, which I think would be "dn1 asp g" but I'm not sure what it does. something in the keyboard handler, it seems?
okay so the unused hint is supposedly for the teleporter, according to the modding wiki and cross-referencing with the load_game function:
https://moddingwiki.shikadi.net/wiki/Duke_1_Savegame_Formatgetting closer to my goal. I figured out where it sets the variable for duke's backflipping, at 3000:2499.
0 = not backflipping
1 = left
2 = right
Wait wait wait. Either I'm completely misremembering a key part of how one of my favorite dos games works, or this save system makes no sense
nope, not misremembering. See this message? You can only save games in the between-level hallways.
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!
and apparently the game ignores the camera position, but not the player position, which is relative to the player position that it didn't load.
so... if you set up a savegame so it puts you in an actual level instead of a hallway, does it load properly?
yep. you can have it load you right into a level. you can't save a game there, but you can restore one.
weird.
I was gonna say that it would make sense if they originally had a save system that let you save anywhere, but not exactly: some stuff is missing that'd let you have a real mid-level save.
it doesn't save your keys or if you have the access card, which means you could be trapped after reloading a mid-level save
but yeah: despite it technically being visible for 32 years, I never noticed that the game doesn't just save which hallway you're in.
It saves where the duke is relative to the hallway, even if not his actual position.
I just loaded two different saves of Duke in the first hallway. Didn't press any other buttons... but he appears in different places!
guess I'll have to find out where it shows the "you can only save in hallways, dummkopf!" dialog and see if there's an if(!in_hallway && !debug_mode)" before it
I found the part where it shows that dialogbox, it was tricky because it was in Dark Code, but I can't find what calls it for presumably exactly the same reason
it also means there's yet another dialog_box function that's identical to all the others except for a couple things that could be easily parameterized
segmented real mode DOS is so silly.
I know this function is a far call (not a "fall car", as my fingers somehow typed it) so I just need to look for JMP 208e:1bb0, right?
what if instead they JMP to 208F:1BA0? that's the same linear address!
or any of the 256 other possible addresses for the same fucking function?
> Exception while decompiling 208e:4094: Decompiler process died
this would be easier if Ghidra would STOP FUCKING CRASHING
oh god this code better not be jumping into the middle of an instruction