delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/11/21:31:22

From: VANGEL AT VMREDIPN DOT IPN DOT MX
Message-Id: <199707120129.VAA10007@delorie.com>
Date: Fri, 11 Jul 97 20:22:06 EST
To: djgpp AT delorie DOT com
Subject: About RGB in VGA

Hi!!

In the Turbo C and Turbo C++, there are two functions for start the graphics
mode in 640 X 480 with RGB (0-255 colors) :

--> void far setrgbpalete(int colornum, int red, int green, int blue)

This function defines colors for IBM-8514 graphics card ..

--> void far setrgbcolor(int colornum, int red, int green, int blue)

And this function set palettes entries for VGA and IBM-8514 cards ........

I have the Graphics Card IBM-8514  ( VGA ) and I try to Start the Graphics
Mode for 320 X 240 in RGB with follow code ...  :

----------------------------------------------------------------------

/*** HARDWARE.C *******************************************\
 *  (MSDOS, i386+, VGA, DJGPPv1 or v2)                    *
 *    HW_open_screen         opening output surface;      *
\**********************************************************/

#include <pc.h>
#if DJGPP == 2
#include <sys/nearptr.h>                    /* v2  __djgpp stuff */
#endif

unsigned char *G_vram;                      /* points video ram */
unsigned char *HW_colourmap;                /* where drwaings go to */

/**********************************************************\
 *  Opening output surface and setting the palette.       *
 *  RETURNS: always 1.                                    *
\**********************************************************/

int HW_open_screen(char *display_name,
                   char *screen_name,
                   struct HW_colour palette256ู,
                   unsigned char *colourmap
                  )
{
 int i;
 unsigned char r,g,b;

#if DJGPP == 1
 G_vram=(unsigned char*)0xd0000000;
#endif
#if DJGPP == 2
 G_vram=(unsigned char*)0xa0000+__djgpp_conventional_base;
#endif

 HW_colourmap=colourmap;                    /* for later blits */

 asm("movb  $0x13,%%al":::"%al");           /* %al mode number */
 asm("xorb  %%ah,%%ah":::"%ah");            /* function #0 */
 asm("int   $0x10");

 for(i=0;i<256;i++)
 {
  r=(unsigned char)paletteiู.hw_r;
  g=(unsigned char)paletteiู.hw_g;
  b=(unsigned char)paletteiู.hw_b;

  asm("movb  %0,%%dh":: "g" (r):"%dh");     /* Red */
  asm("movb  %0,%%ch":: "g" (g):"%ch");     /* Green */
  asm("movb  %0,%%cl":: "g" (b):"%cl");     /* Blue */
  asm("movw  %0,%%ebx":: "g" (i):"%ebx");   /* Colour to set */
  asm("movw  $0x1010,%%ax":::"%ax");        /* function 0x10 subfun 0x10 */
  asm("int   $0x10");
 }
 return(1);
}

/**********************************************************\
 *  Colormap onto the screen.                             *
\**********************************************************/

void HW_blit(void)
{
#if DJGPP == 2
 __djgpp_nearptr_enable();
#endif
 HW_copy_int((int*)HW_colourmap,(int*)G_vram,HW_COLOURMAP_SIZE_INT);
#if DJGPP == 2
 __djgpp_nearptr_disable();
#endif
}



/**** HARDWARE.H  (Header file) ****************************/
#ifndef _HARDWARE_H_
#define _HARDWARE_H_

\**********************************************************/
 *  (MSDOS, i386+, VGA, DJGPP)                            *
\**********************************************************/

#define HW_copy_int(src,dst,lng)  asm("movl  %0,%%esi \n"             \
                                      "movl  %1,%%edi \n"             \
                                      "movl  %2,%%ecx \n"             \
                                      "cld \n"                        \
                                      "rep \n"                        \
                                      "movsl (%%esi),(%%edi) \n"      \
                                      ::"g" (src),"g" (dst),"g" (lng) \
                                      :"esi","edi","ecx"              \
                                     )

#define HW_SCREEN_X_SIZE         320
#define HW_SCREEN_Y_SIZE         200        /* number of pixels total */

#define HW_COLOURMAP_SIZE_CHAR 64000        /* bytes in the colourmap */
#define HW_COLOURMAP_SIZE_INT  16000        /* ints in the colourmap */

struct HW_colour                            /* describes colour */
{
 int hw_r;
 int hw_g;
 int hw_b;                                  /* intensity components */
};

int HW_open_screen(char *display_name,
                   char *screen_name,
                   struct HW_colour palette256ู,
                   unsigned char *colourmap
                  );
void HW_blit(void);

#endif

-----------------------------------------------------------------------


 The last code it's very good for start Graphics Mode 320 X 200 (RBG) ...
(By the way, Sergei Savchenko --> savs AT cs DOT mcgill DOT ca ( www.cs.mcgill.ca/~savs
... wrote it .......)

 But I want to write the code for start Graphics in Mode 640 X 480 (RGB)
how the function of Turbo C and Turbo C++ ....

Could anybody tell me how I can to start Mode 640 X 480 and RBG ...?

Which is the code about it ..?

Thanks in advance ....


บบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบ
บบบ     Victor Angel Huerta          บบบ
บบบ                                  บบบ
บบบ  Estudent of Engineer Electronic บบบ
บบบ                                  บบบ
บบบ   I.P.N.  Mexico D.F.            บบบ
บบบ   vangel AT vmredipn DOT ipn DOT mx         บบบ
บบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบบ

- Raw text -


  webmaster     delorie software   privacy  
  Copyright ฉ 2019   by DJ Delorie     Updated Jul 2019