saving scree using video memry

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<dos.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
void write2screen(int row,int column,char c,int attb);
void writestring(int row,int column,char *c,int attb);
void savevdo(int sr,int er,int sc,int ec,int *imager);
void showvdo(int sr,int er,int sc,int ec,int *imager);
int *buffer;int *buffers;
void main()
{
gotoxy(5,6);
printf("fghhgf");
writestring(16,16,"dfggdfsdgf",146);
write2screen(10,8,'j',146);
buffer=(int*)malloc(800);buffers=(int*)malloc(400);
savevdo(1,1,20,20,buffer);
getch();
clrscr();
showvdo(1,1,20,20);
getch();
}

void write2screen(int row,int column,char c,int attb)
{
char far *vid;
vid=(char far*)0xB8000000+row*160+column*2;
*vid=c;
vid++;
*vid=attb;
}
void savevdo(int sr,int er,int sc,int ec,int *imager)
{
int i,j;
char far *vid;
int count=0;
for(i=sr;i<=er;i++)
{for(j=sc;j<=ec;j++)
{
vid=(char far*)0xB8000000+i*160+j*2;
*(imager+count)=*vid;
*(imager+count+1)=*(vid+1);
count+=2;
}}
}


void showvdo(int sr,int er,int sc,int ec,int *imager)

{
int i,j;

I just cant figure out y the above code isnt working???????????/can sumbdy help... plz
sumone plz answer.............
I can't help you but I wanted to inform you (if you didn't know that you use a deprecated header file conio.h and also some non standard c commands like gotoxy() and clrscr();.

getch(); is unnecessary and potentially dangerous (in your case I guess just useless).

Also as an advice try to inform your potential advisers about the purpose of your code, errors you are getting etc
@eypros..........the purpose is simple....to capture anything from the screen.......and then clear the screen and later display the stored screen......ihv used getch(); so that the user can control the event of capturing,clearing and then displaying.......any help wud be appreciated......
reply plz.................................??????????????????/
hello..nyone there..........>??????????????
That method worked in MS-DOS, but it doesn't in any of today's operating systems - at least not without mapping video memory into your own address space first.
wud u be kind enough to tell how it is to be done..?
all kind gurus of programming, please help this out???????
Topic archived. No new replies allowed.