Something like this should work:

#include <asm/io.h>

void setPalette( uchar  *thePalette )
{
        uchar  stat;

        outb(0x14,0x3d6);
        stat    = inb( 0x3D7 ) & 0x8F; 
        outb(stat | 0x50,0x3D7);

        while ( inb( 0x3D7 ) & 0x08 )
                continue;

        outb(0,0x3C8);

        asm volatile ("rep ; outsb" :: 
                "c" (768), "S" (thePalette) :
                "ecx", "esi");
}

Note you had the order of the operands for outb backwards.

Note also that you have to compile with some optimization for in/out to
work.

        -pat


On Tue, 5 Jun 2001, Kevin D. Quitt wrote:

> The built-in routine to set the palette takes 8 milliseconds on my machine;
> this is way too slow - it is possible to write the palette entirely during
> the vertical blanking period.  This code works for DOS:
> 
>       push    ds
>       mov     dx, 0x3D6               // Select XR14
>       mov     al, 0x14
>       out     dx, al
> 
>       mov     dx, 0x3D7               // Enable VSYNC, Retrace, and HSYNC
>       in      al, dx
>       and     al, 0x8F
>       or      al, 0x50
> 
>       out     dx, al
>       in      al, dx
> 
>       mov     dx, 0x3DA               // Wait for Vertical retrace
> 
>   loop0:
> 
>       in      al, dx
>       and     al, 0x08
>       jz      loop0
> 
>       mov     dx, 0x3C8               // Send the palette
>       mov     al, 0
>       out     dx, al
>       mov     cx, 768
>       lds     si, pal
>       mov     dx, 0x3C9
>       rep     outsb
>       pop     ds
> 
> I've translated it to:
> 
> void setPalette( uchar *thePalette )
>   {
>     uchar   stat;
> 
>     outb( 0x3D6, 0x14 );                // Select XR14
>     stat    = inb( 0x3D7 ) & 0x8F;      // Enable VSYNC, Retrace, and HSYNC
>     outb( 0x3D7, stat | 0x50 );
> 
>     while ( inb( 0x3D7 ) & 0x08 )
>         continue;
> 
>     outb( 0x3C8, 0 );                   // Send the palette
> 
>     /* How do I put in the in-line assembly here? */
> 
>   }
> 
> 
> 
> 
> --
>  _
> Kevin D. Quitt                                                     [EMAIL PROTECTED]
>                     96.37% of all statistics are made up
> 
> 
> 
> ------------------------------------------------------------------
> Unsubscribe:  To:   [EMAIL PROTECTED]
>               Body: unsubscribe linux-svgalib
> 


------------------------------------------------------------------
Unsubscribe:  To:   [EMAIL PROTECTED]
              Body: unsubscribe linux-svgalib

Reply via email to