Beginner programming advice for DOS?
Home › Forums › DOS Talk › DOS Development › Beginner programming advice for DOS?
- This topic has 22 replies, 9 voices, and was last updated 1 month, 1 week ago by TigerQuoll.
-
DaveParticipantJune 24, 2022 at 1:34 pm #6208Having followed the podcast for a little while has inspired me to have a go at a bit of programming. I remember doing some very simple things with BBC BASIC (Acorn Archimedes) when I was about 7 or 8, so I’ve started somewhere familiar with an Archimedes emulator and over the last few weeks written a handful of simple ASCII games, and played a bit with plotting sprites and drawing lines. I really feel like I’ve learning quite a bit, I’ve stopped using GOTOs! and more importantly I’m having fun.
What I’d really like to do is write something which will run in DOS. I think I want to use C and have had a little play in Visual Studio, but I don’t think I can compile from there and run straight in DOS – am I right in thinking I need either DJGPP or Open Watcom? Do any of you use either of these and may be able to give me a bit of guidance? I think I want to write in modern Windows but maybe it’s more straightforward to do it all in DOS?
Is anyone doing something similar, having a play but maybe not at a level where you’d be thinking about game jams etc? It’d be great to hear from you!
June 24, 2022 at 2:01 pm #6209DJGPP is actually pretty good. It does only work on 386+ models, because it needs a proper protected mode interface. But that also means you’re not limited by the 16bit nature of older CPUs. You’ll also get support for modern C++ (and C11).
If you want to go for 16bit code, be prepared for some extra weirdness in C (you’ll have to worry about “memory models” and segments, and all that). It can be very rewarding, but may be quite the culture shock for people who are used to writing 32 or 64 bit code for modern systems.
If you want to have a go at that, OpenWatcom is actually not bad, but it is less well maintained than DJGPP and has does show its age here and there, with only older standards being supported, the command line being somewhat crappy and some bugs that can make you question your sanity before you find out the compiler is to blame 😉
So for 16bit code, I’ve only really used assembly extensively, because of the aforementioned issues with OpenWatcom. But for simple stuff it’s probably good enough.
DaveParticipantJune 24, 2022 at 7:56 pm #6211Thanks rnlf! I’ve just gone through the DJGPP file picker and downloaded the suggested files, so hopefully I can make it past the first hurdle and get it all installed correctly. I’ll be honest, I already feel a bit out of my depth! But I’ll start with the basics and see how I get on. Maybe I should go back a step or two, get some real hardware, and see if I can get it to turn on..
June 24, 2022 at 11:18 pm #6213If you want to ease into programming for DOS, you could always start with QuickBasic 4.5
A surprising number of very good games have been made with it (I’m working on one now myself), and I still find it very easy and intuitive to use and learn.
It can also serve as a gateway to FreeBasic, which has a 32bit DOS compiler, is highly compatible with QBasic code and lets you link C libraries, so you can get your toes wet in C as well.
That’s the direction I’m heading down anyway. Food for thought!
DaveParticipantJune 24, 2022 at 11:28 pm #6215Ok I actually surprised myself and managed to do it. It took me a bit of figuring out, and I’m sure there’s a simpler way but it worked and I’m happy!
I took a helloworld.c written with Visual Studio and tried DJGPP, but it didn’t seem to like 64bit windows. As it happens though I have an old laptop running XP (purely to play Red Alert 2, sorry not DOS related), so copied DJGPP and the file I wanted to convert to a USB stick and moved everything over, and set the environment variables. Everything worked fine in XP, and the program ran in command prompt. I was pretty excited at this point, the last thing for me this evening was to get it to run in DOSbox at least. So after a bit of playing back in Windows 10 I discovered I needed to add in a DPMI host and it worked!
I know it’s not much, but it’s a lot more complicated than what I’ve been doing in RISC OS. I’m enjoying myself though and I’m looking forward to converting what I’ve learnt already in BASIC. I don’t have any real (DOS) hardware at the moment but I think it’ll definitely be on the cards at some point, I do fancy a 486 or maybe a socket 7. Certainly a lot cheaper than an Archimedes!
DaveParticipantJune 24, 2022 at 11:33 pm #6216Ah thanks TigerQuoll, I’ll check those out too! I actually took so long to type I didn’t see your reply until after I sent it..
June 25, 2022 at 11:32 am #6217Haha, glad to hear I’m not the only one that happens to!
DaveParticipantJuly 3, 2022 at 4:19 pm #6248After struggling a little with C, I gave QB 4.5 a go and it felt much more familiar, a few differences to work around but I’m not too far off where I was with BBC BASIC, so thanks again for the suggestion TigerQuoll
kdrnicParticipantJuly 3, 2022 at 4:29 pm #6249Hello,
If you intend to program in C for 32bit DOS I cannot recommend a combination of Allegro 4.2.2 and DJGPP highly enough.
It is a nice and well tried library of game routines, with graphic modes, image loading, keyboard mouse and joystick input, sound both WAV and MIDI, etc i.e. all you need for a game.
I have made several games with it in several states of unfinishedness.
One advantage is that both gcc and Allegro 4 are also available for modern Windows and Linux, so you can build applications that work on both a modern OS and on DOS.
The main issues I found with this are A) debugging in DOS sucks B) the executable size with Allegro is a bit a large (over 1 megabyte).
If you decide to play with Allegro and need some pointers you can find me on the IRC channel.
tamsin.lmParticipantJuly 14, 2022 at 2:50 am #6289If you wanna go old school, Borland Turbo C++ is available for download on the Internet Archive. It’s 16 bit only, which does mean the most restrictive environment, but your code will literally run on anything with an Intel processor. Defaults should mean you can put off getting into the nitty gritty of memory models. Of course, I might be a little biased as I’ve been using it since the 90s.
August 23, 2022 at 10:58 pm #6417I’ve just discovered a language called XPL0
http://www.xpl0.org/I haven’t had much time with it yet, but it looks like exactly the language I’ve always wanted. It’s got the power of C, but the syntax is a lot more like pascal, which means it should be a lot easier to learn.
There are 16 and 32 bit compilers for DOS, a really good manual and heaps of example programs.
DaveParticipantSeptember 3, 2022 at 2:20 pm #6456Ok so I finally have something resembling a game, it’s not much but I’m enjoying working within my own limitations.
I figured a mid 80s demake would be a good direction to go as I can keep the game low tech, so here’s my Farming Simulator ’85! I’m working on buying/selling mechanics at the moment, but naturally every time I add something another thing breaks..
Crops yield about 200lbs per tile, based roughly on 1000sq ft and a little google work, and at the moment the month advances every 10s although I’ll probably up that.
I’d like to add in buying of different crops, maybe silos to determine how much you can grow and have the player able to place them all where they like, but I may also get fed up and move on ha.Interested to see what you guys may be working on!
Attachments:
September 3, 2022 at 11:58 pm #6460Wow, that looks really awesome! I’d love to play your farming simulator demake when it’s ready. You say you haven’t really coded anything since you were a kid? Well, colour me impressed!
I’ve been working on a little Metroidvania for some time. Pace has slowed considerably in recent weeks, but I’m hoping I’ll get it done by the end of the year.
Programming is about 95% done (unless I figure out how to do key polling in QB, in which case I’ll probably ditch a fair chunk of code and rewrite it).
I still need to make about 60-70 % of the levels though…
DaveParticipantSeptember 4, 2022 at 10:58 pm #6470Thanks! Yeah I’d definitely say I’m a complete novice, so I’m quite pleased with how I’m getting on so far. It looks like yours is the real deal, I’d love to give it a go!
timewindParticipant
DaveParticipantOctober 6, 2022 at 3:46 pm #6548Thanks timewind – sorry for slow responses – I think I stumbled on that series before, it looks really helpful. Maybe it’s time to move over to C.
I did a little more on my cga farm, crops take time to grow, they can be sold to buy more crops or grain silos, more silos are needed for more crops. I like playing city builders so it was fun for me to make it possible to place things wherever, so I might add more things like that.
That said, I also now have 2 kids under 3 so if I do get any time to myself I tend to spend it sleeping, but if I do get a chance programming is the perfect way to unwind!
Attachments:
DaveParticipantJanuary 2, 2023 at 9:58 pm #70053 months later and I’ve not touched this, So I’ve put together an unpublished page on itch to kind of archive it for myself. You guys are more than welcome to have a look!
https://daveargles.itch.io/farming-simulator-1985?secret=Z6rLTko6LL98VvkWsq9rUX6gE
voxelParticipantJanuary 3, 2023 at 4:52 am #7012I saw a bottled dos-dev environment today. If you have visual studio code you can install this via the extensions tab, and it’ll download a full djgpp environment for you, even bundles dosbox-x for testing https://marketplace.visualstudio.com/items?itemName=badlogicgames.dos-dev
tamsin.lmParticipantFebruary 4, 2023 at 3:30 pm #7131Is there a process for reconfiguring this setup to use Open Watcom instead of djgpp?
finalpatchParticipantFebruary 9, 2023 at 1:03 pm #7149Free Pascal is actually a very good choice for DOS. You can use it write both 32-bit protected mode DOS programs or 16-bit real mode programs.
CasParticipantJune 3, 2023 at 10:33 pm #7454I’ve been using FreeBasic for a long time already. I usually program on the GNU/Linux platform, but then my programs are transparently compiled to Windows and DOS, including graphics. So I can recommend that too.
November 14, 2024 at 9:04 am #9192I’ve recently been using Power Basic.
It is a rebranded and updated Turbo Basic after the creator bought it back from Borland.
It’s highly compatible with Quick Basic, so it’s pretty easy to learn. But it is much more powerful, and has numerous features that I’ve felt are sorely missing in Quick Basic, and the compiled programs seem to run much quicker. (Which I understand has something to do with being compiled directly to machine language, not via p-code??)
The only criticism I have is that the IDE is a bit clunky.
Unless the usability of the IDE is a total dealbreaker for you, I don’t see any reason to use Quick Basic when you could be using Power Basic.Currently I’m working on a 40×25 text mode platform game. Hopefully I might actually finish this one!
Turns out I forshadowed in my last post, and I found out how to do key polling. Rewriting all that code was just too disheartening, and I totally stalled on “Forgotten Tunnels”.
The game I’m working on is much less ambitious, so see how I go…
You must be logged in to reply to this topic.
Home › Forums › DOS Talk › DOS Development › Beginner programming advice for DOS?