Mail Archives: djgpp/1999/06/07/05:05:45
Bonifati wrote in message <7jdrj2$i3g$1 AT fe1 DOT cs DOT interbusiness DOT it>...
>i'm trying to convert some graphical demo programs in 320x200-256 written
>for Watcom under DJGPP. Since i need to access video memory directly, i've
>read djgppfaq.
>I copied a snippet of code from 18.4 section to define a selector for text
>video memory:
>
> int TxtVRAMSetupSelector (void)
> {
> static char selectorData[8] = {
> 0xff, 0x7f, 0x00, 0x80,
> 0x0b, 0xf3, 0x40, 0x00
> };
> int screenSelector = __dpmi_allocate_ldt_descriptors (1);
> if (__dpmi_set_descriptor (screenSelector, selectorData) < 0)
> abort ();
> return screenSelector;
> }
>
>and i modified like this:
>
> #include <dpmi.h>
>
> short video;
>
>int VideoVRAMSetupSelector (void)
>{
> static char selectorData[8] = {
> 0xff, 0xf9, 0x00, 0x00,
> 0x0a, 0xf3, 0x40, 0x00
> };
> int screenSelector = __dpmi_allocate_ldt_descriptors (1);
> if (__dpmi_set_descriptor (screenSelector, selectorData) < 0)
> abort ();
> return screenSelector;
>}
>
>void Create_Selector (void)
>{
> video = VideoVRAMSetupSelector();
> _farsetsel(video);
>}
>
>this code seems to work and i get useful GPFs if my program has bugs and
>tries to work out of the 64000 bytes of video memory (i.e. plotting a pixel
>with too big coordinates). My question (at last!) is:
>
>is this code completely correct?
I can't see any errors but there is a shorter way of doing it. _dos_ds is
already predefined as the selector, eg.
void clear_video (char col) {
_farsetsel (_dos_ds);
for (int i = 0; i < 64000; i++)
_farnspokeb(0xa0000 + i, col);
}
>Another thing: djgppfaq has a link to a tutorial about accessing the linear
>frame buffer, but i can't reach it:
>http://www.rt66.com/~brennan/djgpp/vbe.zip
>this ones are broken, too
>http://brennan.home.ml.org/djgpp/
>http://brennan.home.ml.org/djgpp/djgpp-asm.html
>
>where can i find some example,tutorial... especially about inline assembly
>optimizations i need to do? (GCC online docs are too difficult for me...)
Look at the docs page on http://www.delorie.com/djgpp/
Michael Stewart
- Raw text -