From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Video pointer with Allegro Date: Mon, 5 May 1997 13:25:03 +0100 Organization: None Distribution: world Message-ID: References: <336e2d98 DOT 427920 AT nntp DOT netcomuk DOT co DOT uk> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 59 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk William McGugan writes: >How do you create a pointer to vesa2 linear memory? I want to be able >to pass it to an assembler function. Look at the section titled "Video memory access" in allegro.txt. If you are sure you are using a VESA2 linear mode, screen->line[0] is the address of the start of video memory, and that is a far pointer relative to screen->seg (use the functions in sys/farptr.h to access it). If your code might be running in a banked SVGA mode, you need to call the function bmp_write_line(screen, linenumber) to get the start address for each horizontal line you want to access. If you want to use the nearptr hack rather than far pointers, you'll need to do a bit of DPMI magic to get the pointer into the correct format, eg: #include #include int main() { unsigned char *screenmemory; unsigned long screen_base_addr; int x; /* initialise Allegro. You must use a linear mode, this will * _not_ work in banked video modes!!! */ allegro_init(); install_keyboard(); set_gfx_mode(GFX_VESA2L, 640, 480, 0, 0); set_pallete(desktop_palette); /* enable near pointers */ __djgpp_nearptr_enable(); /* get the base address of the video memory selector */ __dpmi_get_segment_base_address(screen->seg, &screen_base_addr); /* get a pointer to the video memory */ screenmemory = (unsigned char *)(screen_base_addr + screen->line[0] - __djgpp_base_address); /* draw a horizontal line across the screen */ for (x=0; x