Direct vga memory acces 
Author Message
 Direct vga memory acces

In Pascal I could do this : var i : integer absolute $B800:0
to acces the vga memory, can this be done in c in some manner.

thanks



Tue, 20 Nov 2001 03:00:00 GMT  
 Direct vga memory acces

Quote:

>In pascal I could do this : var i : integer absolute $B800:0
>to acces the vga memory, can this be done in c in some manner.

No. You'll have to use extensions to the C language that are specific to
your system. Try asking this question in a group that discusses
programming for your OS or compiler.

Gergo

--
I value kindness to human beings first of all, and kindness to
animals.  I don't respect the law; I have a total irreverence for
anything connected with society except that which makes the roads
safer, the beer stronger, the food cheaper, and old men and women
warmer in the winter, and happier in the summer.
                -- Brendan Behan

GU d- s:+ a--- C++>$ UL+++ P>++ L+++ E>++ W+ N++ o? K- w--- !O !M !V
PS+ PE+ Y+ PGP+ t* 5+ X- R>+ tv++ b+>+++ DI+ D+ G>++ e* h! !r !y+



Tue, 20 Nov 2001 03:00:00 GMT  
 Direct vga memory acces

Bob schrieb:

Quote:
> In pascal I could do this : var i : integer absolute $B800:0
> to acces the vga memory, can this be done in c in some manner.

> thanks

The answer depends on the compiler, the following example should work
with   MSC for DOS with large memory model
and    TorboC for DOS with large memory model
and    WatcomC for DOS with flat memory model

#if defined _MSC_VER
    #if (_MSC_VER <= 600)
        #define FAR        _far
    #else
        #define FAR        __far
    #endif
#endif

#if defined __TURBOC__
    #define FAR far
#endif

#if defined __WATCOMC__
    #define FAR
#endif

typedef unsigned char  BYTE;    /* 8-bit unsigned entity
*/
typedef unsigned short WORD;    /* 16-bit unsigned number
*/

#if defined __WATCOMC__
    #define VGA_BASE   ((BYTE FAR *) 0x000A0000L)
    #define HGC_BASE   ((BYTE FAR *) 0x000B0000L)
    #define CGA_BASE   ((BYTE FAR *) 0x000B8000L)
    #define HGC_BASE_W ((WORD FAR *) 0x000B0000L)
    #define CGA_BASE_W ((WORD FAR *) 0x000B8000L)
#else
    #define VGA_BASE   ((BYTE FAR *) 0x000A0000L)
    #define HGC_BASE   ((BYTE FAR *) 0x000B0000L)
    #define CGA_BASE   ((BYTE FAR *) 0x000B8000L)
    #define HGC_BASE_W ((WORD FAR *) 0x000B0000L)
    #define CGA_BASE_W ((WORD FAR *) 0x000B8000L)
#endif

access to the CGA/VGA textmode memory:
WORD w   = CGA_BASE_W[line*80+column]

Anton



Wed, 21 Nov 2001 03:00:00 GMT  
 Direct vga memory acces

"Anton M. Kirchsteiger" schrieb:

Quote:
> Bob schrieb:

> > In pascal I could do this : var i : integer absolute $B800:0
> > to acces the vga memory, can this be done in c in some manner.

> > thanks

> The answer depends on the compiler, the following example should work
> with   MSC for DOS with large memory model
> and    TorboC for DOS with large memory model
> and    WatcomC for DOS with flat memory model

> #if defined _MSC_VER
>     #if (_MSC_VER <= 600)
>         #define FAR        _far
>     #else
>         #define FAR        __far
>     #endif
> #endif

> #if defined __TURBOC__
>     #define FAR far
> #endif

> #if defined __WATCOMC__
>     #define FAR
> #endif

> typedef unsigned char  BYTE;    /* 8-bit unsigned entity
> */
> typedef unsigned short WORD;    /* 16-bit unsigned number
> */

now it should work:

#if defined __WATCOMC__
    #define VGA_BASE   ((BYTE FAR *) 0x000A0000L)
    #define HGC_BASE   ((BYTE FAR *) 0x000B0000L)
    #define CGA_BASE   ((BYTE FAR *) 0x000B8000L)
    #define HGC_BASE_W ((WORD FAR *) 0x000B0000L)
    #define CGA_BASE_W ((WORD FAR *) 0x000B8000L)
#else
    #define VGA_BASE   ((BYTE FAR *) 0xA0000000L)
    #define HGC_BASE   ((BYTE FAR *) 0xB0000000L)
    #define CGA_BASE   ((BYTE FAR *) 0xB8000000L)
    #define HGC_BASE_W ((WORD FAR *) 0xB0000000L)
    #define CGA_BASE_W ((WORD FAR *) 0xB8000000L)
#endif

access to the CGA/VGA textmode memory (char+color code):
WORD w   = CGA_BASE_W[line*80+column]

Anton



Wed, 21 Nov 2001 03:00:00 GMT  
 Direct vga memory acces

Quote:

>In pascal I could do this : var i : integer absolute $B800:0
>to acces the vga memory, can this be done in c in some manner.

As far as I am aware there is no such feature in standard Pascal, what
you are probably referring to is some extension provided by the
particluar Pascal compiler you are using. The situation is similar in C,
compilers in environments where this sort of operation is useful will
probably provide some means to do it. A common approach is to use
C's standard feature of casting an integer value to a pointer (C doesn't
specify what the reslt will be but a particualr compiler can). Some
provide macros, e.g. _MK_FP(). You'll need to check your compiler
documentation to find out the particular form of support it provides
or ask in a newsgroup relating to your particular compiler.

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


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



Wed, 21 Nov 2001 03:00:00 GMT  
 Direct vga memory acces
Quote:


> >In pascal I could do this : var i : integer absolute $B800:0
> >to acces the vga memory, can this be done in c in some manner.

You could do this in c++ with an alias declaration.

Greetings!
Volker



Fri, 23 Nov 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. direct acces to the printer port

2. direct acces to the printer port

3. WRITING DIRECTLY TO VGA MEMORY

4. direct access to memory region where console-screen (win32) is located

5. Direct access memory from your application

6. Direct memory addressing in TURBO C/C++

7. Direct Memory Access!!!

8. Direct memory access from C

9. Direct memory reading

10. direct memory access

11. newbie question: accessing memory direct

12. newbie question: accessing memory direct (under NT)

 

 
Powered by phpBB® Forum Software