Setting Pointer to Video memory

A

Alan Brown

Subject: Setting Pointer to Video memory
Newsgroups: Optus:comp.lang.c++.moderated

Hi People,

[Sorry for the cross-posting - my post seems not to have reached the other
group.]

I am trying to create a Help Screen in a program. I want to swap out the
video memory, use the screen, then swap back the original contents of the
screen.

The following is the relevant parts of a program that works -

---------------------------------------------------------

#include <dos.h>;
#include <conio.h>;
...
...
...

struct Scrn // struct for Screen memory
{
char n[4000];
};
...
...
...

void ScreenSwap() // Test swapping windows
{
ShowHeader("Screen Swapping");
int i;
Scrn dest;

for (i=0; i<4000; i++) // Write out Video memory to structure
{
dest.n = peekb(0xb800, 0000 + i);
}

getch(); // Pause...

textcolor(LIGHTRED); // Clear Screen to different colors
textbackground(BLACK);
clrscr();

getch(); // Pause...

for (i=0; i<4000; i++) // Read back from structure into Video memory
{
pokeb(0xb800, 0000 + i, dest.n);
}

getch();
}
...
...
...
---------------------------------------------------------

The above works. But I want to use 'memcopy' or 'memmove' instead. But I
am not able to set a pointer to an absolute address such as 0xB8000000.

If it is possible to do this I would be grateful if someone could help me
please.

Alan
 
R

Raymond Martineau

Subject: Setting Pointer to Video memory
Newsgroups: Optus:comp.lang.c++.moderated

Hi People,

[Sorry for the cross-posting - my post seems not to have reached the other
group.]

I am trying to create a Help Screen in a program. I want to swap out the
video memory, use the screen, then swap back the original contents of the
screen.
[...]
The above works. But I want to use 'memcopy' or 'memmove' instead. But I
am not able to set a pointer to an absolute address such as 0xB8000000.

The procedure for initializing an absolute address into a pointer (aside
from NULL) is system specific. For example, you might be able to use a
C-style or reinterpret_cast to convert an integer into a void pointer, but
other systems will not allow the user to directly access that memoey.

If a direct cast does not work, you will need to read the documentation
that came with your compiler (or at least try to find out how the your
compiler represents a pointer.)
 
A

Alan Brown

(e-mail address removed) (Raymond Martineau) wrote in
[Sorry for the cross-posting - my post seems not to have reached the
other group.]

I am trying to create a Help Screen in a program. I want to swap out
the video memory, use the screen, then swap back the original contents
of the screen.
[...]
The above works. But I want to use 'memcopy' or 'memmove' instead.
But I am not able to set a pointer to an absolute address such as
0xB8000000.

The procedure for initializing an absolute address into a pointer
(aside from NULL) is system specific. For example, you might be able
to use a C-style or reinterpret_cast to convert an integer into a void
pointer, but other systems will not allow the user to directly access
that memoey.

If a direct cast does not work, you will need to read the
documentation that came with your compiler (or at least try to find
out how the your compiler represents a pointer.)

Thanks for your reply.

I forgot to say that I am using Borland C++ 3.1 under Windows 98SE.

I will try what you suggest. I have no documentation for the compiler
other than the on-line help and some general reference manuals on C and C++

Since my code works OK there is not really a problem - I was looking for a
"neater" way of accessing Video memory.

Thanks again

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top