Mail Archives: djgpp/1998/01/22/18:18:01
This is a multi-part message in MIME format.
--------------45ABE89971
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Jeff W./DMT wrote:
> I tried, but to no avail:
>
> char GetChar(char x, char y)
> {
> //returns the character at (x,y)
> unsigned char *videoptr = (unsigned char *)0xB800;
>
> __djgpp_nearptr_enable();
> c = videoptr[160*(y-1) + 2*(x-1) + __djgpp_conventional_base];
> return c;
>
> }
Since you left out all header files (nearptr.h especially), your results
would have been confusing anyway. Since DJGPP is a 32-bit system, you
must use 32-bit addresses. The 32-bit absolute address of the color
text screen is 0xb8000. Here is an example based on the information
given in the DJGPP FAQ (which will answer a LOT of questions that
shouldn't be continually asked in the newsgroup):
--
Tony O'Bryan
http://www.geocities.com/SiliconValley/Park/7201
--------------45ABE89971
Content-Type: text/plain; charset=us-ascii; name="Test.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Test.c"
#include <dpmi.h>
#include <sys/farptr.h>
/*
* Uses DPMI services to setup a pointer to the color text screen. This is
* taken directly (really. It was cut and paste) from the DJGPP FAQ section
* 18.4.
*/
int TxtVRAMSetupSelector (void)
{
static char selectorData[8] = {0xff, 0xff, 0x00, 0x80,0x0b, 0xf3, 0x40, 0x00};
int screenSelector = __dpmi_allocate_ldt_descriptors (1);
if (__dpmi_set_descriptor (screenSelector, selectorData) < 0)
abort ();
return screenSelector;
}
/*
* Unneeded overhead, but it might be easier for you to follow.
*/
unsigned char GetChar(int ScreenSelector,int x,int y)
{
return _farpeekb(ScreenSelector,(y * 160) + (x * 2));
}
/*
* Tada!
*/
int main(void)
{
int Screen = TxtVRAMSetupSelector();
int Byte = GetChar(Screen,0,0);
return Byte;
}
--------------45ABE89971--
- Raw text -