DOS is now rarely used, and the programmers for developing programs under DOS are getting less and less. But I think DOS has a bigger flexibility than Windows. The programming difficulty under DOS is also much larger than Windows. After all, Windows has WINAPI to use, and DOS is very functional.
However, DOS can make programmers more contact with the computer underlying, from a sense, some Windows programmers are not at all, and the programming they do is just the simplest programming, only truly touching the underlying and The core can understand the essence of computers and programming.
This paper briefly tells the VGA direct written screen technology under DOS.
Direct writable is easy to implement under DOS, calling the 10h interrupt of the BIOS to enter video mode, for VGA, VESA display mode, the start address of the memory is A000: 0000H (is a 16-bit address) Meter offset form). It is easy to entert the video mode under the C compiler that supports the DOS program, and uses a FAR pointer to the first address of the video memory, then you can see what you want, such as drawing points. The following can be given example:
#define mode_vga13h 0x13 # Define mode_text 0x03
Void SetMode (CHAR MODE) // Sets the function {ASM MOV AH, 0x00 // call 00h function to set the video mode number of the video mode ASM MOV AL, the MODE / / AL register, here in 13H video mode Example ASM INT 0x10 // Call 10H Interrupt}
Char far * vediobuf = (char far *) 0xA0000000L; / / pointing to the pointer to the memory address
Void Putpixel (int x, int y, int C) function {* (vediobuf x 320 * y) = C;
INT getpixel (int x, int y) // Take the function {RETURN * (VEDIOBUF X 320 * Y);
Void main (void) {INT i; int J; // Set VGA13H video mode setmode (mode_vga13h); // Draw full screen for (i = 0; i <20; i ) for (j = 0) with a two cycle ; J <320; J ) PUTPIXEL (J, I, J); getCH (); // Returns DOS text mode setmode (MODE_TEXT);
The above is only given a very simple code of the direct written screen, and the VGA13H video mode is 320 * 200 * 256, that is, 320 * 200 real resolution 256 color maximum number of colors. This mode is now very backward, of course, you can also set other display mode, which can support a variety of high-resolution video modes in VESA standards, and the principles of programming are similar, pay attention to the paging Treatment.
The above implementation of a function of drawing points and a function of a point. On this basis, it is easy to write a graphical function such as painting, painting rectangle, painting circle and other graphics functions. For the display of BMP bitmap, just understand BMP files Structure, then display the bitmap according to the data drawing point in the bitmap, here is not given the program implementation, if you are interested, you can see the Lib for a VGA13h written before, can be downloaded on my website (HTTP) : //rockcarry.126.com).
The direct write screen of DOS is so simple, no effort, the above code is to run the C compiler (such as turbo C2.0) that supports the DOS program, and VC can only do Windows programs. It is almost impossible to write directly in the Windows program, no matter what language you use, this is not much related to the language, which is determined by the platform. The Windows platform introduces DirectX technology to overcome the shortcomings that cannot be directly written, to get high-speed graphics performance. DirectX cannot be strictly called direct written screen, but he brought a speed that is so fast, so DirectX technology is used in popular Windows games.
Direct written screen is fast because you can use it directly, and DirectX can also get a pointer to the memory through function call to achieve the purpose of the direct write screen.
In the easy language to implement direct write screens can only be DirectX technology, because Easy language can only build a Windows program (note that DOS programs and Windows console programs can not be mixed). Some of the direct write screens mentioned above are fake, and the performance is not much better. Direct written screens are just a pointer to the memory and then do it directly to the memory. You go to call the Windows API can also be called direct Write screen?
I also look forward to the language that can support DirectX technology in Easy language, and the language has now gradually strong, and DirectX is also necessary.
The above direct written screen, on the busbad, such as 286, should be able to reach the speed of about 300 frames, under Windows, if you don't have DirectX to reach this speed, the sky-lineless WinApi is not good, that is not called Direct write screen.
Programmed to the bottom, even the operating system is not, the program I have not called DOS, but only calls the BIOS function, BIOS is the motherboard, unless your computer has no motherboard, my code can not work . This is also the difficulty of the underlying programming. Everything is not ready, and there is only one CPU, a memory, some I / O devices, everything is created. This is also the fun of writing the underlying. Only at this time, you really become the owner of the computer, all of his behavior is set by you.
It may be different from the understanding of the direct written screen, but it is necessary to point out that the direct written screen is aware of the meaning of most people. Instead, the meaning of the direct written screen is not important, and the ultimate goal we have to achieve is to have a fast and efficient graphic performance. If you want to achieve this requirement, you may only use DirectDraw under Windows, calling WinApi, this I have tried, and it is confirmed for numerous game developers. If WinApi can be, I believe there will be no DirectX technology.
It should be acknowledged that the language is a fairly excellent programming language, the most direct reflection on "easy". And he is important to achieve his compiler technology, which may not find a few in China.
(Note: I wrote a VGA graphics library, you can download on my website, address: http://rockcarry.126.com)
Author: Chen Kai 2004.1.1 All Rights Reserved