msm@vpnet.UUCP (Matt Minogue) (01/19/90)
I am a fairly new C programmer, just converting from Pascal. I need to access screen memory at 0xb800 ... in Pascal I would use the array MemW[], but I can't seem to find a function in my Turbo C library to do this. Any help appreciated...
bakke@plains.UUCP (Jeff Bakke) (01/24/90)
In article <25b6a0d3:4290comp.sys.ibm.pc@vpnet.UUCP> msm@vpnet.UUCP (Matt Minogue) writes: > > I am a fairly new C programmer, just converting from Pascal. I need to >access screen memory at 0xb800 ... in Pascal I would use the array MemW[], >but I can't seem to find a function in my Turbo C library to do this. Any >help appreciated... Its a lot simpler to do in C than in Pascal. Simple do this... set up a pointer to 0xB800 by unsigned int *display; ( or if you need byte size access ) unsigned short int *display; Then to access the byte at 0xB801 simply use value = *(display+1); /* if you set up display as a byte oriented pointer */ This should work fine. Unlike pascal you can add/sub/inc/dec pointers in C. Makes it much more flexible. Jeff Bakke bakke@plains.NoDak.edu
olsen@eecs.nwu.edu (Jeff S. Olsen) (01/25/90)
to set up a pointer to the screen in turbo-c, do this: #include <dos.h> typedef struct cell { char letter; char attrib; } CELL; main () { CELL far *screen; screen = MK_FP(0xb800,0x0000); /* this is for the color screen */ /* whatever you want here */ } you could just make the screen char far *screen if you wanted to deal with letter and attrib yourself. The important part is the "far" and the MK_FP which stands for make far pointer (which is a macro, so you must include dos.h). hope this helps. Jeff Olsen olsen@eecs.nwu.edu
semicon@watsci.uwaterloo.ca (Robert Adsett) (01/25/90)
In article <3181@plains.UUCP> bakke@plains.UUCP (Jeff Bakke) writes: >In article <25b6a0d3:4290comp.sys.ibm.pc@vpnet.UUCP> msm@vpnet.UUCP (Matt Minogue) writes: >> >> I am a fairly new C programmer, just converting from Pascal. I need to >>access screen memory at 0xb800 ... in Pascal I would use the array MemW[], >>but I can't seem to find a function in my Turbo C library to do this. Any >>help appreciated... > >Its a lot simpler to do in C than in Pascal. Simple do this... >set up a pointer to 0xB800 by > >unsigned int *display; >( or if you need byte size access ) >unsigned short int *display; Nope. 1) a short int is not byte sized it's word sized 2) To work in all models it should be a far pointer 3) the pointer is not initialized so it does not point at display memory It should be something like: #include <dos.h> unsigned char far *display = MK_FP( 0xb800, 0); Also take a look at gettext, puttext, movetext, getimage and putimage. They may already do what you want and you won't have to develop all the device specific code yourself. TC also has a set of routines that write directly to the screen. -- Robert Adsett <semicon@watsci.UWaterloo.ca> Dept. of Phys, Univ. of Waterloo, Waterloo Ont. Canada