From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro and video acces memory Date: Tue, 18 Feb 1997 19:52:05 +0000 Organization: None Distribution: world Message-ID: <$umsMKAlhgCzEwA2@talula.demon.co.uk> References: <01bc1c55$dc985560$1314c00a AT graga-ii> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 70 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Kynnay Software writes: >Enough of that, i just have two questions for anyone wishing to answer me : Hmm. There are three sorts of people in the world: the ones that can count, and the ones that can't... So what happened to the second question? :-) >How can i acces to the physical adresse of the screen in SVGA when >initialising with Allegro ? The screen BITMAP don't give me the linear >adresse i need to use my assembly procs, just a segment.I'm not sure of the >way for using it. In C, use the farptr functions (these are described in the libc docs). In asm, load the selector into a spare segment register (%fs is good, or %es if you are going to use string instructions, but remember you need to restore %es if you change it). The addresses stored in the bitmap structure should then be used with this selector. For example, here is a simplified version of the putpixel function from gfx8.s (it uses some strange macros from asmdefs.h, but you should be able to get the idea): .globl __linear_putpixel .align 4 __linear_putpixel: pushl %ebp movl %esp, %ebp pushw %es movl ARG1, %edx /* load bitmap pointer into edx */ movl ARG2, %ecx /* load x pos into ecx */ movl ARG3, %eax /* load y pos into eax */ movw BMP_SEG(%edx), %es /* load segment selector into es */ /* this is a macro which does bank switching using the bitmap * in edx and the line number in eax, and leaves a pointer to * the start address of the line (relative to the bitmap's * segment selector) in eax. */ WRITE_BANK() movl ARG4, %dl /* load color into dl */ movb %dl, %es:(%eax, %ecx) /* write the pixel to the screen */ popw %es movl %ebp, %esp popl %ebp ret If you don't like using far pointers in this way, it is possible to use the functions in sys/nearptr.h to obtain a normal pointer to any physical address (IMHO this approach is more trouble than it is worth, but I'm sure many people will disagree with that :-) Getting a pointer to the screen that will work with these routines is quite a bit more work, but still possible. As of Allegro 2.2, the GFX_DRIVER structure contains a vid_phys_base field, which is where the video memory is located. This will usually be in the low meg, in which case you can treat it as an offset into conventional memory, but if the card is using a linear framebuffer mode it may point just about anywhere. If this is the case you'll need to map the address range into linear memory before you can access it: this should be done with the __dpmi_physical_address_mapping() function (for an example, look at the files vesa.c and dpmi.c from Allegro). /* * Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ * Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'. */