Introduction
This article explains how to use the Visual Screen Display (VSD) in Turbo C/C++ software using the C language.
Our Monitor Screen is divided into 80 columns and 25 rows and that means that 80 characters can be arranged in a single row.
The starting address defines 1 row and 1 column in memory. We can use the Turbo C/C++ software that provides the facility to use it for creating a graphical compatible application, but it's only one display page and all the work is done on a single page.
Declaration
The variable name contains the first address of the VSD.
Address |
Row |
Column |
b800:0000 |
print character |
0,0 |
b800:0001 |
print color |
0,0 |
b800:0002 |
print character |
0,1 |
b800:0003 |
print color |
0,1 |
- #include<stdio.h>
- #include<conio.h>
- #include<dos.h>
- void main()
- {
- char far *VSD =(char far *) 0xb8000000;
- int rows=1 ;
- clrscr();
- for(int i=0 ;i<256 ;i+=2)
- {
- *(VSD+i)='O';
- *(VSD+i+1)=i;
- delay(100);
- }
- getch();
- }
See the preceding code seriously, here two lines are important.
In the first line, “i=0” means that it's an EVEN value. So when we increase the value of the “i” variable by 2 every time, then *( VSD + i) =’O’;
Print the character on the screen.
And at that time the odd value of the “i” variable defines the print foreground color and the background color depending on address, but always remember that background color starts from “BLACK COLOR”.
Our screen has 80*25 =2000 characters that can print on a display.
So when we want to start, then start it by printing a character to 2 rows then we want to add 2*80=160.
Where:
2 defines 1 bit for the character and 1 bit for the color 1+1=2.
80 defines the total characters in a single row.
VSD =VSD +160;
- #include<stdio.h>
- #include<conio.h>
- #include<dos.h>
- void main()
- {
- char far *VSD =(char far *) 0xb8000000;
- int rows=1,i ;
- VSD = VSD +160;
- clrscr();
- for(int i=0 ;i<256 ;i+=2)
- {
- *(VSD+i)='O';
- *(VSD+i+1)=i;
- delay(100);
- }
- getch();
- }
But remember, when your VSD variable reaches row 2 you want to go again on row 1. So you will subtract 160 from the VSD variable.
VSD = VSD – 160;So if we want to reach anywhere in the screen, then the addition and subtraction is used with the VSD variable.
The Turbo C/C++ software is developed using this concept.
When you create an .exe file, after running the code that .exe file can run with GUI compatibility, but on the other hand when you use the Graphics header and BGI files for creating any type of GUI .exe file that are not compatible.
You can create anything with the VSD concept easily. It's main feature is compatibility with all Windows OS.
My Project on VSDI am giving you two files, one is the .c file and other one is the .h file. Copy those files into the directory “C:\TC\Bin”.
After copying of files, run tc.exe and open the window.c file to execute it.
You will see the same type of editor such as the Turbo software.
It supports only the shortcut keys such as “Alt + Red color character in menu” after opening any menu press any arrow key and for closing the menu press the “Esc button”.
Arrow keys mean “Alt + Red Character”.
It also includes “Alt+F press enter” and you will see the Green color editor.
You can close this editor using “Alt+F3” and to quit press “Alt + x”. But it has many errors and I have shown you how to work on VSD.
Thank you.