Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

DJGPP and mode13h

Here's my code for setting the mode to mode13, I'm getting some weird run-time errors...it compiles fine on DJGPP tho, PLEASE HELP:


#include

#include


#define MODE13 0x13

#define TEXT 0x03


void setGFX(int mode)

{

union REGS inregs,outregs;


inregs.h.ah = 0;

inregs.h.al = (unsigned char)mode;


_int86(0x10, &inregs, &outregs);

} // end setGFX


void main()

{

unsigned char *buffer = (unsigned char *)0xA0000000L;

int index;


// Set gfx mode

setGFX(MODE13);


// Fill screen

for (index = 0; index < 64000; index++)

{

buffer[index] = 5;

} // end for


// Wait for keypress

while(!kbhit()){} // end while


// Set txt mode

setGFX(TEXT);


} // end main





Comments

  • : void main()

    : {

    : unsigned char *buffer = (unsigned char *)0xA0000000L;

    : int index;


    : // Set gfx mode

    : setGFX(MODE13);


    : // Fill screen

    : for (index = 0; index < 64000; index++)

    : {

    : buffer[index] = 5;

    : } // end for


    : } // end main


    You can't access DOS memory ( < 1 MEG) in DJGPP like this. There is a big difference between your linear ptr 0xa0000 and the physical memory address 0xa0000. Without going into too much detail, you cannot create a ptr to a physical memory address wihtout using the DPMI. DJGPP does have some built in selectors and functions that WILL access the VGA memory, but they are somewhat slow, and I'd say that if you're just starting 32bit programming (which it looks like you are), start off with a library like Allegro that handles all this crap for you, or get a copy of Watcom, which allows you to address physical memory < 1 MEG like you've done here.


    Rock


  • : : void main()

    : : {

    : : unsigned char *buffer = (unsigned char *)0xA0000000L;

    : : int index;


    : : // Set gfx mode

    : : setGFX(MODE13);


    : : // Fill screen

    : : for (index = 0; index < 64000; index++)

    : : {

    : : buffer[index] = 5;

    : : } // end for


    : : } // end main


    : You can't access DOS memory ( < 1 MEG) in DJGPP like this. There is a big difference between your linear ptr 0xa0000 and the physical memory address 0xa0000. Without going into too much detail, you cannot create a ptr to a physical memory address wihtout using the DPMI. DJGPP does have some built in selectors and functions that WILL access the VGA memory, but they are somewhat slow, and I'd say that if you're just starting 32bit programming (which it looks like you are), start off with a library like Allegro that handles all this crap for you, or get a copy of Watcom, which allows you to address physical memory < 1 MEG like you've done here.


    Really most people should use graphics libraries unless they are pressed for speed or simply abhor the syntax of the library's functions.


    -Xotor-


Sign In or Register to comment.