Never give up
Did Bill Gates really say “640 KB should be enough for everyone”? Her story is rather vague, but most often it is attributed to Bill, so perhaps he did say that.
He was often ridiculed for it. The idea of a total memory space of only 640 KB in size is ridiculous by modern standards. Even the executable files of most installers will not fit in this size.
For comparison: the calculator in Windows 10 takes up 16.2 MB of RAM in idle state - almost 26 times more than the amount of memory available to DOS programs in the 1980s.
')
Strange things
Would you believe me if I say that there is still an active community using this outdated platform and developing software for it?
Probably your first question will be “But why?” And I understand you well. Let's take a look at some groups that are still interested in investing in DOS.
Legacy systems developersToday, there are still many programs that run in DOS. Industrial control programs, point-of-sale systems and scientific tools are just some of the examples of applications that use DOS even today. Over time, most of these programs have been ported to other systems or completely rewritten, but some are still preserved.
Real time non-cost systemsDOS is essentially a real-time operating system (RTOS). She was not specifically designed for this purpose, but her minimalistic design allows her to be attributed to other similar systems.
RTOS are characterized by a predictable delay in software and hardware queries. Since DOS has a minimal API without internal multitasking, the stability of operating system call delays is quite high.
Although there are already more advanced examples of real-time systems with improved design and developed specifically for this purpose, the thinnest DOS interface between the application and the equipment gives it an advantage in this area of use. Since systems such as FreeDOS (which I will discuss below) are open source and distributed free of charge, they are a good alternative to other RTOS.
Nostalgic video gamesModern video games are awesome. They require immense power of 3D, but the graphics, sound and gameplay are sometimes so realistic that they can be confused with reality. Virtual reality equipment further enhances this feeling, allowing players to fully immerse themselves in the game environment.
But despite all this progress, many gamers who were children in the 80s and early 90s remember fondly the times when primitive (by modern standards) graphics and synth sounds made them fill in the gaps with their own imaginations.
Despite the fact that the hardware has left the limitations of the DOS era far behind, there is still an active scene for DOS gamers. Driven by nostalgia and a love for programming, developers write games that run on older systems, including PCs, which were originally shipped with DOS.
If you think that this market is limited to a handful of retirees trying to return to their technological childhood, then you are mistaken.
David Murray , better known on YouTube as
The 8-bit Guy , has more than half a million subscribers who weekly explore the territory of nostalgic computer hardware. He even wrote a real-time strategy for Commodore 64 called
PlanetX2 . The project was such a success that David sold out all the physical reserves of the carriers with the game and plans to create a sequel for the DOS platform.
Run DOS
There are many ways to start DOS. You may even have a computer where you can run it right now. But since we want to work closely with this operating system, we will use the way in which free software is used that runs on almost any computer.
First, let's talk a little about the license. According to some reports, Microsoft made MS-DOS 6.22 public domain, but I could not find confirmation of this. Since the software can be easily downloaded from fairly secure online sources, I am not in favor of installing something that could violate copying rights. Even if you have a legally acquired copy (and I suspect that many have it), installing it on a virtual machine can be a legally risky act.
To simplify installation, we will use FreeDOS. FreeDOS is an open source clone of DOS written by Jim Hall. Jim began development in June 1994, when Microsoft announced that it would no longer sell and support MS-DOS. A few weeks later, Pat Willini and Tim Norman joined the project. In just a few months, version 0.01 appeared. Today, we are using version 1.2 released on Christmas Day 2016.
First we go to the
FreeDOS website and download the ISO image of the standard installer on CD-ROM. You can also download the USB version, but taking into account differences in hardware, BIOS, etc. we will not consider this method here. Instead, we will use virtualization.
I tested FreeDOS with both
VirtualBox Oracle and
VMware Workstation / Player . Both products work well, but VMware provides slightly better BIOS emulation and emulates the PC speaker used in many DOS games. In the examples below, I will use VMware Workstation, but in principle any system will do.
The default installation options for FreeDOS are VirtualBox and VMware. It may surprise you how little RAM and disk space are allocated. I usually create a two GB drive for DOS, but the default 512 MB will be enough.
Installing FreeDOS is simple; all you have to do is boot into a virtual machine from an ISO image (an ISO file request will be issued at startup or when creating a virtual machine) and follow the on-screen prompts. After FreeDOS splits the disk and reboots, choose Install to Hard Disk again. Choose "Full Installation" or "Full Installation with Sources" if you like to see how everything works. You are reading this article, so most likely it is, then why not install the source?
After installation, you will need to reboot. This time, instead of selecting “Install to Hard Disk” in the CD boot menu, select “Boot from System Hard Disk”. The default Jemmex (with no EMS) is quite suitable for standard downloads, especially if you want to develop.
Technically, the FreeDOS system is ready to work, but still completely "naked." In this state, it is convenient to run games and DOS programs, but it is not entirely suitable for development, because we do not have important tools.
Cute fdimples
Now it’s time to install some software in FreeDOS. The OS contains a wonderful FDimples package management system. To use it, enter:
fdimples
. — , . , , , .
.. , ENTER — . , Development. TAB, OK, ENTER.
C++
, ? C++ , GNU Compiler Collection DOS.
, DOS CWSDPMI 32- . 640 . , !
, :
mkdir C:\src
mkdir c:\src\hello
rhide c:\src\hello\hello.cpp
RHIDE. Visual Studio, . Borland Turbo-C, .
.:
#include <iostream>
using namespace std;
int main() {
cout << “Hello, World!\n”;
return 0;
}
«Run» ( ALT+R, R CTRL+F9). , . , , . - RHIDE, !
- . :
mkdir c:\src\example
rhide c:\src\example\example.cpp
, , VGA 320x200x256.
#include <iostream>
#include <dpmi.h>
#include <unistd.h>
#include <go32.h>
#include <sys/farptr.h>
#include <stdlib.h>
#include <dos.h>
#define COLOR_WHITE 15
#define MAX_WIDTH 320
#define MAX_HEIGHT 200
using namespace std;
void set_video_mode(int mode) {
//
__dpmi_regs r;
// AX
r.x.ax = mode;
// int 10 ( BIOS)
__dpmi_int(0x10, &r);
}
void put_pixel(int x, int y, int c) {
// VGA A000, .
_farpokeb(_dos_ds, 0xA0000+y*320+x, c);
}
void clear_pixel(int x, int y) {
// 0,
_farpokeb(_dos_ds, 0xA0000+y*320+x, 0);
}
void draw_effect() {
// x y
int x = 0;
int y = 0;
// y_max
for (y = 0; y < MAX_HEIGHT, y++) {
for (x=0; x < MAX_WIDTH, x++) {
put_pixel(x, y, rand()%(15+1));
}
}
}
int main() {
// 13h (320x200x256)
set_video_mode(0x13);
//
draw_effect();
// ENTER
cin.ignore();
//
set_video_mode(3);
return 0;
}
. , . , .
#include <iostream>
#include <dpmi.h>
#include <unistd.h>
#include <go32.h>
#include <sys/farptr.h>
#include <stdlib.h>
#include <dos.h>
#define COLOR_WHITE 15
#define MAX_WIDTH 320
#define MAX_HEIGHT 200
#define KEY_ESC 283
#define KEY_UP 18432
#define KEY_DOWN 20480
#define KEY_LEFT 19200
#define KEY_RIGHT 19712
using namespace std;
void set_video_mode(int mode) {
// s
__dpmi_regs r;
// AX
r.x.ax = mode;
// int 10 ( BIOS)
__dpmi_int(0x10, &r);
}
void put_pixel(int x, int y, int c) {
// VGA A000, .
_farpokeb(_dos_ds, 0xA0000+y*320+x, c);
}
void clear_pixel(int x, int y) {
// 0,
_farpokeb(_dos_ds, 0xA0000+y*320+x, 0);
}
int get_key() {
//
__dpmi_regs r;
// AH 00h BIOS
r.x.ax = 0x0000;
// int 16 ( BIOS)
__dpmi_int(0x16, &r);
// AX ( -)
return r.x.ax;
}
int main() {
// 13h (320x200x256)
set_video_mode(0x13);
//
int running = 1;
int curkey;
//
int char_x = MAX_WIDTH / 2;
int char_y = MAX_WIDTH / 2;
while (running) {
//
curkey = get_key();
// ,
clear_pixel(char_x, char_y);
switch (curkey) {
case KEY_ESC:
// ESC,
running = 0;
break;
case KEY_UP:
char_y--;
break;
case KEY_DOWN:
char_y++;
break;
case KEY_LEFT:
char_x--;
break;
case KEY_RIGHT:
char_x++;
break;
}
// ""
put_pixel(char_x, char_y, COLOR_WHITE);
}
//
set_video_mode(3);
return 0;
}
, , . .
, INT 16. , , . INT 16 AH = 01 , . . , .
, put_pixel clear_pixel , , . memcpy(). - :
#include <sys/movedata.h>
char buffer[320x200];
int i;
// ,
//
dosmemput(buffer, 320*200, 0xA0000);
/ , . , , — , .
, C++ — , , . . DOS BASIC , .
. , , C++, , DJGPP.
, , , , . DOS , 640 . , 640 . DOS- TSR ( ) 600 .
, , DOS EMS ( ). 600 , , 1 . DOS CWSDPMI !
, . DOS — . «», DJGPP .
, . . DOS, VGA (, , - ) C.
C++ , (, , ) . 4 ( , ), JPG . .
, . , .
— . .