Code: #include<stdio.h> #include<conio.h> #include<math.h> #include<stdlib.h> 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; main() { printf("hello"); getch(); savevdo(1,1,15,15,buffer); clrscr(); showvdo(1,1,15,15,buffer); getch(); } 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; 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; *vid=*(imager+count); *(vid+1)=*(imager+count+1); count++; }} } //there is no error regarding the base address 0xB800 this is not working i mean.......the screen is not at all copied and later displaye......plz help wid dis....... :nonod:
it would be kind of yours if u tell how to allocate space for buffer.....?if that means doing...........buffer=(int *)malloc(800).....then doing his too does not make any difference.......................
Have you checked that: (a) reading from memory starting at 0xB8000000 gives values that correspond to what's on screen, and (b) writing to memory starting at 0xB8000000 puts characters onto the screen that correspond to the numbers you stored? What operating system are you using (including the full version number)? Also, what compiler (again, including the full version number)? malloc is the way to create space and regardless - you must do this, and free() the memory after you've finished with it. If this doesn't make any difference, then the problem must be down to something else.
Also, why is buffer of type int and not char? I would have thought that it should be char. This could also be the problem, but try it first.
Or, if http://wiki.answers.com/Q/What_is_0xB8000000 is correct, then buffer should be int*, but vid should be int* (or int far *).
well im using windows xp professional basic version......dunno the number and Borland C++ 3.0 as my compiler...........................and the only thing that my code is able to do is that it can write anything to the sreen using the video memory...............but when we try to access data from the vdo memory by saving into an int *buffer NO ACCESS FROM IT TAKES PLACE and the screen is blank.............. like the following code shows the character 'g' with the appropriate attributes used usng video memory......... Code: #include<conio.h> #include<stdio.h> #include<stdlib.h> void savevdo(int sr,int er,int sc,int ec,int *imager); void showvdo(int sr,int er,int sc,int ec,int *imager); void write2screen(int row,int column,char c,int attb); int *buffer; main() { printf("Hello"); write2screen(5,5,'g',146); getch(); savevdo(1,1,48,48,buffer); clrscr(); getch(); showvdo(1,1,48,48,buffer); getch(); } void savevdo(int sr,int er,int sc,int ec,int *imager) { int i,j; int far *vid; int count=0; for(i=sr;i<=er;i++) {for(j=sc;j<=ec;j++) { vid=(int far*)0xB8000000+i*160+j*2; *(imager+count)=*vid; *(imager+count+1)=*(vid+1); count+=2; }} } 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 showvdo(int sr,int er,int sc,int ec,int *imager) { int i,j; int far *vid; int count=0; for(i=sr;i<=er;i++) {for(j=sc;j<=ec;j++) { vid=(int far*)0xB8000000+i*160+j*2; *vid=*(imager+count); *(vid+1)=*(imager+count+1); count++; }} }
Maybe it's write-only memory. Hence the other part of my question: have you checked (a) reading from memory starting at 0xB8000000 gives values that correspond to what's on screen Cos if you can't do that, then your program has no chance of working. The code appears to be fine, BUT it assumes you can both read and write 0xB8000000+. With XP the DOS box isn't really running MS-DOS - it's running an emulator. So writing to memory isn't necessarily going to work as you would expect on a simpler system that is just running MS-DOS. Try it on a PC that's only running DOS - you might find that works OK.
the error ws quite silly of me:goofy::smug:......i u look i have given the initial row and the final row as the same in the first part of the code which made all the difference...