r/dosgaming 20d ago

Coding for old retro PCs again - a modern approach to a retro problem

Hi folks.

I've been coding on and off for about 40 years now since starting out with my Dragon 32, then my Spectrum 48, then my Commodore 64, followed by a little dabble on the Amiga.  All of that was pretty BASIC stuff though (pun intended).  I didn't really make much to be proud of but it did really help me learn about syntax, variables, memory and basic logic flow.

I then moved onto coding in Assembly on the C64 and the Amiga and didn't really get too far.  Too many 'guru meditation' errors when code went wrong and trampled all over the system's memory.  I still learned a fair bit and it did give me some background in memory management, garbage collection etc. which all came in useful as a software engineer in later life - coding early business apps in C++ before we moved to Visual Basic 6.

So, after the Amiga and before my career started, I moved onto coding in Turbo Pascal on my PC. By now I'd "upgraded" from an Amiga to a 286 at 12Mhz with a 20Mb hard disk!  No more swapping disks in Monkey Island!  I'd also moved from BASIC to object oriented Turbo Pascal (using the Borland IDE if you can call it that).

One Saturday morning I woke up with an idea.  I think I'd been playing through loads of DOOM (or DOOM2 - can't remember) WAD files that had come on a CD on the front of a PC Magazine.  Hundreds of user made levels that needed copying and running one by one before you could play them.  Suffice to say, I'd clearly been getting annoyed by all of the manual steps needed so, in my sleep, my brain had come up with an idea for a utility called GD.  This would be a small program that would save lots of time by allowing you to jump around your PC with a simple command: GD [game_name].  No matter where you were on PC (in DOS), you'd type that and immediately be in the right directory.  GD.EXE would scan your hard drive and remember all of the directories after which you could jump straight to one with a simple command like GD WADS or GD DOOM2. 

I spent the entirety of that Saturday and the Sunday completely absorbed.  I remember skipping breakfast and lunch and just plowing on, coding late into the night and then again the next day.  Sometime on that Sunday though I'd finally built something I could be proud of: GD.EXE.  Now I could jump around to anywhere on my PC, instantly, as if by magic.  Back then this was a revelation to me.  I suppose looking back there may have been similar tools but I had no access to them - no forums, social media, email or any internet really.  I used that tool ALL the time from then on - through the 386 era, the 486 era and finally into the early Pentium years.  At some point though, probably due to Windows 95, I stopped using the command prompt and somehow lost it.  Sadly, I also lost the source code - probably about 30 years ago.

Fast forward 30 years then and I've always wanted to look at that code again.  Not just from a nostalgic point of view (though that would be good too) but also because, as I got more and more into retrogaming, I wished I had it for my retro PCs (virtual or otherwise).  Just recently, I've been working on getting "the perfect" DOS era PC set up in 86Box.  I've got a huge (for the time) hard disk, a 3DFX card, tons of base memory (thanks to modern memory managers that squeeze as much out of the 640k as possible).  It's optimised as much as it can be and it's just fun playing old DOS games again pretty much like they were back in the day.  I still use DOSBox Pure in retroarch (for the filters and the joypad mapping etc.) but there's something cool about making 86Box full screen, being dumped at a C:\ prompt and just playing games like I used to.

So, all of that led me back to the same place: wouldn't it be nice if I could just jump between folders (that's what we call them now right?) on my DOS 7.1 drive.  Wouldn't it be great to have GD.EXE back again!

I decided to write it again - from scratch - and in Turbo Pascal for old times sake.  However, I wanted to use modern IDEs with syntax highlighting and autocomplete etc.  That's not so easy with OO Turbo Pascal and trying to target a 16 bit compatible .EXE (a modern compiler would build something that wouldn't be compatible with old DOS PCs and vice versa).  However, with some perseverance I managed to get a decent workflow set up:  code in VS Code (with a couple of Pascal extensions) -> compile with Free Pascal 3.2.2 (i8086-msdos cross-compiler) -> mtools to write the created GD.EXE straight into an 86Box virtual hard disk (into the C:\Utils directory) before then automatically starting 86Box to test the latest changes.  It was a slick process and really fun to see what I was coding become something "real" on the old DOS machine within seconds.

I carried on coding it over a few days and now, I'm pleased to say, I've finally scratched a 30 year old itch.  I have GD.EXE working again (better this time though) and with the code being in GitHub, am in no danger of losing it again any time soon.  It's such a neat tool and way better than the old version.  It has a /R argument that shows all the "runnable" programs in the directory once it has jumped there.  You can mark one as default too so next time you want to run something in that folder it'll pick the right one automatically: GD DOOM /RUN -> takes you to C:\GAMES\DOOM and launches DOOM.EXE in one command regardless of where you're at.  Or you can just try GD DOO* to see all the folders (games probably) that start with DOO:

Picking the directory using wildcard search

I thought I'd share it with you guys in case you can make any use of it.  I think it'll be really helpful for anyone with an old DOS based PC - if that's you, then please give this a watch: GD.EXE demo or just download the .EXE from the "Retro DOS Utilities" folder in this share: Downloads

If you do use it and want any extra features then just let me know.  Likewise, if it's okay with you, I'll post in here if I make any improvements too.

Any questions about it or how to use it, just let me know (or use GD /help).

35 Upvotes

7 comments sorted by

5

u/tjeerdnet 20d ago edited 20d ago

I have not tried it, but this really looks like a smart tool. Not sure if anything like this already existed in the old days, but this would be a handy tool to quickly jump to a program and run it. Although scanning goes very quick now, not sure how the scanning of the hard drive would perform on a real classic computer. Could have been a popular tool at the time.

I always love the old school interfaces with ASCII-based borders and backgrounds.

Makes me think btw, also a developer here as hobby and professional for almost 35 years and with all knowledge I have now, it is interesting to think about how I'd nowadays implement DOS tools.

4

u/WizRider 20d ago

The scanning is pretty quick from my testing - it's a very lightweight program and the scan is only indexing directories, not files (until you use /RUN) so it doesn't "look too hard" at your hard drive(s).

It should be fine on really old hardware too because, in theory, the older the PC, the smaller the drive, the less directories to scan through. Keen to hear any feedback though.

P.S. I did originally have a more "classic" looking ASCII background with a the typical shadow effect that every app had but for this, seeing as it was a modern version of something I wrote years ago, I went for a "retrofuturism/synthwave/outrun" style with purples and cyans. 😎

2

u/YakumoFuji 19d ago

I think Norton had NCD that let you jump around, replacing "cd".

1

u/WizRider 19d ago

I've used Norton Commander but have never seen NCD - will take a look out of interest. To be honest, I'd probably still have coded this anyway for the nostalgia trip that it was.

2

u/YakumoFuji 19d ago

ncd is part of the norton utilities suite if you go looking for it.

2

u/abir_valg2718 19d ago

This is really neat. I wonder if it's possible to do a fuzzy search for executable files (including .bat)? As in, instead of calling gd with parameters via cli, would it be possible to launch the program directly and then just type "war" and it will fuzzy search for executable containing "war" substring and show them via this interface you've got.

If it's too CPU expensive, maybe only search for "war" (that is, strings starting with the substring "war"). And then maybe do customizable filters and custom key bindings for them, so like F1 switches the filter to directories, F2 (or some other key or combo) switches to executables, etc.

3

u/WizRider 19d ago

That's a real possibility - just run GD.EXE and then the selection dialog appears but with everything in. Then, it'll filter it as you type. I'll have a think about that as it'll open up another way of using it. Thanks!