handmade.network » Forums » Getting into old school MS-DOS game programming
sudo459
4 posts
#15791 Getting into old school MS-DOS game programming
5 months ago Edited by sudo459 on July 17, 2018, 2:55 p.m. Reason: Initial post

Hey everyone,

I've decided to, purely as a hobby, start programming with (in?) MS-DOS. So far, it's incredibly difficult due to the lack of information, but I feel like I can manage. The main problem I seem to be having is that I feel a bit scared to run my programs. Since I'm using real hardware, crashes, at least I think, could potentially be devastating. Without the memory protection of modern OS's, and running in real mode, I worry how my program will misbehave if it overwrites memory. My question is, how likely is it, that if my program misbehaves it will damage my computer or cause data loss? And, in what ways could this happen?
mmozeiko
Mārtiņš Možeiko
1834 posts / 1 project
#15792 Getting into old school MS-DOS game programming
5 months ago

Damaging computer - no, that won't happen. Data loss - yes, that could happen. For example, when you would write to disk with wrong data, overwriting something important (either in your application, or OS files).

But I would really suggest to develop using DosBox. Yes, it's not a real hardware, but it will help you a lot. It's close enough to real hw, unless you are really pushing boundaries. But this last step could be done separately on real hw. Begin with easy stuff, use DosBox.
sudo459
4 posts
#15796 Getting into old school MS-DOS game programming
5 months ago

I see. Thanks. I do wonder, other than a safer environment, what does DOSBox offer as far as making it easier to develop on, other than of course different emulated hardware setups? Ive tinkered around with Watcom's debugger, and Ive had trouble getting it to do remote debugging in DOSBox. It would just crash both dosboxes. Granted, I havent tried it on real hardware either, yet. And dosbox to real doesnt work either, naturally.
mmozeiko
Mārtiņš Možeiko
1834 posts / 1 project
#15797 Getting into old school MS-DOS game programming
5 months ago Edited by Mārtiņš Možeiko on July 17, 2018, 10:18 p.m.

what does DOSBox offer as far as making it easier to develop on
Easier to recover form mistakes. Something locks up / terribly crashes? Just reset whole emulation. Restarting app will be much faster than whole PC.

Also it has some kind of integrated debugger, but I've never tried it: https://github.com/Henne/dosbox-s.../master/src/debug/debug.cpp#L1277

sudo459
4 posts
#15798 Getting into old school MS-DOS game programming
5 months ago

That DOSBox debugger looks interesting, I'll have to check it out. Thanks again. Also, I must have forgotten restart time. It's not much faster, but I could see how waiting a few more seconds to restart the program when doing a test could get annoying.
psyklic
Dan
2 posts
#16214 Getting into old school MS-DOS game programming
3 months, 2 weeks ago

I have done a lot of MS-DOS game programming. There is absolutely no reason to be scared running your programs. Whenever you write software for any platform, you only read/write to memory locations you know about -- DOS is no exception. The same goes when writing files to disk. You have the power to overwrite system files, but this is difficult to accidentally do.

When you accidentally buffer overflow, either it happens silently, causes a general protection fault (putting you back at the prompt), or rarely requires a restart. To do something dangerous, you would have to very precisely modify another program's RAM, which is extraordinarily unlikely.

The benefits of DOS are many -- your program has 100% processor control, it can call BIOS interrupts, and can even write directly to video memory. You can also experiment with self-modifying programs!
sudo459
4 posts
#16259 Getting into old school MS-DOS game programming
3 months, 1 week ago

I guess I'm used to "modern" memory protection and being able to directly access hardware and system memory gave me the feeling of "with great power come great responsibility". I love the prospect of being able to have near total control over my computer, and, as I explore, I'm learning a ton about what the computer actually does.
Thanks for this by the way, I'm glad I can program without fear of a run away loop damaging my computer! Of course, this doesn't mean I get to be sloppy with my programming...