Ejemplo n.º 1
0
int32	_get_device_format( int16 vdi_handle )
{
	int32	format;
	int16	work_out[272];
	
	vq_scrninfo( vdi_handle, work_out );							/* Pixelwerte erfragen */

	if (( work_out[0] == -1 ) && ( work_out[2] == 4 ))			/* VGA-Karte mit 4 separaten Ebenen? */
		format = PX_PLANES + PX_4BIT;
	else																		/* kein Sonderfall */
	{
		format = 0;
		format |= ((int32) work_out[0] ) << 16;					/* Pixelformat */
		format |= work_out[2];											/* Bits pro Pixel */
	}
	
	if ( work_out[2] <= 8 )
	{
		format |= PX_1COMP;												/* 1 Komponente pro Pixel */
		format |= work_out[2] << 8;									/* benutzte Bits pro Pixel */
	}
	else																		/* Direct Color */
	{
		int16	used_bits;
		int16	red_bits;
		int16	green_bits;
		int16	blue_bits;
		
		red_bits = work_out[8];
		green_bits = work_out[9];
		blue_bits = work_out[10];
		
		used_bits = red_bits + green_bits + blue_bits;			/* benutzte Bits pro Pixel */

		if ( work_out[16 + red_bits - 1] < work_out[48 + blue_bits - 1] )	/* umdrehte Bytereihenfolge? */
		{
			format |= PX_REVERSED;
		
			if ( used_bits < work_out[2] )
				format |= PX_xFIRST;										/* unbenutze Bits stehen vor den Farbwerten */
		}
		else																	/* normale Bytereihenfolge */
		{
			if ( work_out[16 + red_bits - 1] < ( work_out[2] - 1 ))
				format |= PX_xFIRST;										/* unbenutze Bits stehen vor den Farbwerten */
			else if ( used_bits == 15 )								/* Geier? */
				used_bits = 16;											/* wie rrrr rggg gggb bbbb behandeln */
		}

		format |= PX_3COMP;												/* 3 Farbkomponenten pro Pixel */
		format |= used_bits << 8;										/* benutzte Bits pro Pixel */
	}

	return( format );
}
Ejemplo n.º 2
0
static void VDI_ReadExtInfo(_THIS, short *work_out)
{
    unsigned long EdDI_version;
    unsigned long cookie_EdDI;
    Uint32 num_colours;
    Uint16 clut_type, num_bits;

    /* Read EdDI informations */
    if  (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) {
        return;
    }

    EdDI_version = Atari_get_EdDI_version( (void *)cookie_EdDI);

    vq_scrninfo(VDI_handle, work_out);

    VDI_format = work_out[0];
    clut_type = work_out[1];
    num_bits = work_out[2];
    num_colours = *((Uint32 *) &work_out[3]);

    /* With EdDI>=1.1, we can have screen pitch, address and format
     * so we can directly write to screen without using vro_cpyfm
     */
    if (EdDI_version >= EDDI_11) {
        VDI_pitch = work_out[5];
        VDI_screen = (void *) *((unsigned long *) &work_out[6]);

        switch(num_colours) {
        case 32768UL:
            if (work_out[14] & (1<<7)) {
                /* Little endian */
                if (work_out[14] & (1<<1)) {
                    /* Falcon */
                    VDI_alphamask = 1 << 13;
                    VDI_redmask = 31 << 3;
                    VDI_greenmask = (3 << 14) | 7;
                    VDI_bluemask = 31 << 8;
                } else {
                    /* Others */
                    VDI_alphamask = 1 << 7;
                    VDI_redmask = 31 << 2;
                    VDI_greenmask = (7 << 13) | 3;
                    VDI_bluemask = 31 << 8;
                }
            } else {
                /* Big endian */
                if (work_out[14] & (1<<1)) {
                    /* Falcon */
                    VDI_alphamask = 1 << 5;
                    VDI_redmask = 31 << 11;
                    VDI_greenmask = 31 << 6;
                    VDI_bluemask = 31;
                } else {
                    /* Others */
                    VDI_alphamask = 1 << 15;
                    VDI_redmask = 31 << 10;
                    VDI_greenmask = 31 << 5;
                    VDI_bluemask = 31;
                }
            }
            break;
        case 65536UL:
            if (work_out[14] & (1<<7)) {
                /* Little endian */
                VDI_alphamask = 0;
                VDI_redmask = 31 << 3;
                VDI_greenmask = (7 << 13) | 7;
                VDI_bluemask = 31 << 8;
            } else {
                /* Big endian */
                VDI_alphamask = 0;
                VDI_redmask = 31 << 11;
                VDI_greenmask = 63 << 5;
                VDI_bluemask = 31;
            }
            break;
        case 16777216UL:
            if (work_out[14] & (1<<7)) {
                /* Little endian */
                switch(num_bits) {
                case 24:
                    VDI_alphamask = 0;
                    VDI_redmask = 255;
                    VDI_greenmask = 255 << 8;
                    VDI_bluemask = 255 << 16;
                    break;
                case 32:
                    VDI_alphamask = 255;
                    VDI_redmask = 255 << 8;
                    VDI_greenmask = 255 << 16;
                    VDI_bluemask = 255 << 24;
                    break;
                }
            } else {
                /* Big endian */
                switch(num_bits) {
                case 24:
                    VDI_alphamask = 0;
                    VDI_redmask = 255 << 16;
                    VDI_greenmask = 255 << 8;
                    VDI_bluemask = 255;
                    break;
                case 32:
                    VDI_alphamask = 255 << 24;
                    VDI_redmask = 255 << 16;
                    VDI_greenmask = 255 << 8;
                    VDI_bluemask = 255;
                    break;
                }
            }
            break;
        }
    }

    switch(clut_type) {
    case VDI_CLUT_HARDWARE:
    {
        int i;
        Uint16 *tmp_p;

        tmp_p = (Uint16 *)&work_out[16];

        for (i=0; i<256; i++) {
            vdi_index[*tmp_p++] = i;
        }
    }
    break;
    case VDI_CLUT_SOFTWARE:
        if (EdDI_version < EDDI_11) {
            int component; /* red, green, blue, alpha, overlay */
            int num_bit;
            unsigned short *tmp_p;

            /* We can build masks with info here */
            tmp_p = (unsigned short *) &work_out[16];
            for (component=0; component<5; component++) {
                for (num_bit=0; num_bit<16; num_bit++) {
                    unsigned short valeur;

                    valeur = *tmp_p++;

                    if (valeur == 0xffff) {
                        continue;
                    }

                    switch(component) {
                    case 0:
                        VDI_redmask |= 1<< valeur;
                        break;
                    case 1:
                        VDI_greenmask |= 1<< valeur;
                        break;
                    case 2:
                        VDI_bluemask |= 1<< valeur;
                        break;
                    case 3:
                        VDI_alphamask |= 1<< valeur;
                        break;
                    }
                }
            }
        }

        /* Remove lower green bits for Intel endian screen */
        if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) {
            VDI_greenmask &= ~(7<<13);
        }
        break;
    case VDI_CLUT_NONE:
        break;
    }
}
Ejemplo n.º 3
0
int16	default_colors( int16 vdi_handle, COLOR_RGB *gslct )
{
	int32	no_colors;
	int16	work_out[272];
	int16	rgb_in[3];
	int16	index;
	
	vq_scrninfo( vdi_handle, work_out );							/* Pixelwerte erfragen */
	no_colors = *(int32 *) ( work_out + 3 );						/* Farbanzahl */

	for ( index = 0; index < 16; index++ )							/* neue Systemfarben, die f�r besseres Dithern sorgen */
	{
		rgb_in[0] = system_colors[index][0];
		rgb_in[1] = system_colors[index][1];
		rgb_in[2] = system_colors[index][2];
		vs_color( vdi_handle, index, rgb_in );
	}

	if ( no_colors >= 256 )												/* 256 Farben oder Direct Color? */
	{
		int16	gslct_red;
		int16	gslct_green;
		int16	gslct_blue;
		int16	red;
		int16	green;
		int16	blue;
		int16	gray;
		
		if ( gslct )
		{
			gslct_red = (int16) (((int32) gslct->red + 6553 ) / 13107 ) * 200;	/* Farbe innerhalb des 6*6*6-W�rfels ausw�hlen */
			gslct_green = (int16) (((int32) gslct->green + 6553 ) / 13107 ) * 200;
			gslct_blue = (int16) (((int32) gslct->blue + 6553 ) / 13107 ) * 200;
		}
		else																	/* Selektionsfarbe von Hellgrau: Voreinstellung */
		{
			gslct_red = 200;
			gslct_green = 200;
			gslct_blue = 600;
		}
		
		index = 16;

		for ( red = 0; red < 6; red++ )								/* VDI-Index 16 - 229: 6*6*6 Farbw�rfel (ohne Schwarz und Wei� => 214 Farbt�ne) */
		{
			for ( green = 0; green < 6; green++ )
			{
				for ( blue = 0; blue < 6; blue++ )
				{
					if ((( red != green ) || ( red != blue )) || (( red != 0 ) && ( red != 5 )))	/* nicht Schwarz und und nicht Wei�? */
					{
						rgb_in[0] = ( red * 1000 ) / 5;
						rgb_in[1] = ( green * 1000 ) / 5;
						rgb_in[2] = ( blue * 1000 ) / 5;
						if (( rgb_in[0] == gslct_red ) && ( rgb_in[1] == gslct_green ) && ( rgb_in[2] == gslct_blue )) /* Selektionsfarbe f�r Hellgrau? */
						{
							rgb_in[0] = 0;
							rgb_in[1] = 0;
							rgb_in[2] = scale[2];
						}
						
						vs_color( vdi_handle, index, rgb_in );
						index++;
					}
				}
			}
		}

		for ( red = 0; red < 7; red++ )								/* VDI-Index 230 - 236: 7 Rott�ne */
		{
			rgb_in[0] = scale[red];
			rgb_in[1] = 0;
			rgb_in[2] = 0;
			vs_color( vdi_handle, index, rgb_in );
			index++;
		}

		for ( green = 0; green < 7; green++ )						/* VDI-Index 237 - 243: 7 Gr�nt�ne */
		{
			rgb_in[0] = 0;
			rgb_in[1] = scale[green];
			rgb_in[2] = 0;
			vs_color( vdi_handle, index, rgb_in );
			index++;
		}

		for ( blue = 6; blue >= 0; blue-- )							/* VDI-Index 244 - 250: 6 Blaut�ne und die Selektionsfarbe */
		{
			if ( index == 248 )											/* Selektionsfarbe von Hellgrau? */
			{
				rgb_in[0] = gslct_red;
				rgb_in[1] = gslct_green;
				rgb_in[2] = gslct_blue;
			}
			else																/* Blauverlauf setzen */
			{
				rgb_in[0] = 0;
				rgb_in[1] = 0;
				rgb_in[2] = scale[blue];
			}
			vs_color( vdi_handle, index, rgb_in );
			index++;
		}

		for ( gray = 0; gray < 7; gray++ )							/* VDI-Index 251 - 255: 5 Graut�ne (die 16 Systemfarben enhalten zwei weitere Graut�ne) */
		{
			if (( scale[gray] != 502 ) && ( scale[gray] != 902 ))	/* Hellgrau und 50%grau werden aus den Systemfarben genommen */
			{
				rgb_in[0] = scale[gray];
				rgb_in[1] = scale[gray];
				rgb_in[2] = scale[gray];
				vs_color( vdi_handle, index, rgb_in );
				index++;
			}
		}
	}
	return( 1 );
}
Ejemplo n.º 4
0
/*----------------------------------------------------------------------------------------*/
COLOR_MAP	*_create_cmap( int16 vdi_handle )
{
	COLOR_MAP	*cmap;
	int32	length;
	int32	no_colors;
	int16	work_out[272];
	
	vq_scrninfo( vdi_handle, work_out );							/* Pixelwerte erfragen */
	no_colors = *(int32 *) ( work_out + 3 );						/* Farbanzahl */
	
	if (( no_colors == 0 ) || ( no_colors > 256 ))				/* Direct Color, Dummy-Palette erzeugen? */
	{
		int16	i;

		for ( i = 0; i < 256; i++ )
			work_out[16 + i] = i;
			
		no_colors = 256;
	}

	length = sizeof( COLOR_MAP ) + ( no_colors * sizeof( COLOR_ENTRY ));
	cmap = Malloc_sys( length );
	
	if ( cmap )
	{
		cmap->magic = 'cmap';
		cmap->length = length;											/* L�nge der Farbtabelle */
		cmap->format = 0;
		cmap->reserved = 0;
		
		cmap->map_id = 0;
		cmap->color_space = CSPACE_RGB;
		cmap->flags = CSPACE_3COMPONENTS;
		cmap->no_colors = no_colors;									/* Anzahl der Farben */

		cmap->reserved1 = 0;
		cmap->reserved2 = 0;
		cmap->reserved3 = 0;
		cmap->reserved4 = 0;
		
		while ( no_colors > 0 )
		{
			int16	rgb_out[3];
			COLOR_ENTRY	*entry;
			int16	value;

			no_colors--;
			vq_color( vdi_handle, (int16) no_colors, 1, rgb_out ); 
			value = work_out[16 + no_colors];						/* Pixelwert */

			entry = cmap->colors + value;								/* Eintrag in der Farbtabelle */
			entry->rgb.red = (((int32) rgb_out[0] << 8 ) - rgb_out[0] ) / 1000L;
			entry->rgb.red += entry->rgb.red << 8;
			entry->rgb.green = (((int32) rgb_out[1] << 8 ) - rgb_out[1] ) / 1000L;
			entry->rgb.green += entry->rgb.green << 8;
			entry->rgb.blue = (((int32) rgb_out[2] << 8 ) - rgb_out[2] ) / 1000L;
			entry->rgb.blue += entry->rgb.blue << 8;
			entry->rgb.reserved = value;
		}
	}

	return( cmap );
}
Ejemplo n.º 5
0
static void VDI_ReadExtInfo(_THIS, short *work_out)
{
	unsigned long EdDI_version;
	long cookie_EdDI;
	Uint16 clut_type;

	
	if  (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) {
		return;
	}
	
	EdDI_version = Atari_get_EdDI_version( (void *)cookie_EdDI);

	vq_scrninfo(VDI_handle, work_out);

	VDI_format = work_out[0];
	clut_type = work_out[1];

	if (EdDI_version >= EDDI_11) {
		VDI_pitch = work_out[5];
		VDI_screen = (void *) *((unsigned long *) &work_out[6]);
	}

	switch(clut_type) {
		case VDI_CLUT_HARDWARE:
			{
				int i;
				Uint16 *tmp_p;

				tmp_p = (Uint16 *)&work_out[16];

				for (i=0;i<256;i++) {
					vdi_index[*tmp_p++] = i;
				}
			}
			break;
		case VDI_CLUT_SOFTWARE:
			{
				int component; 
				int num_bit;
				unsigned short *tmp_p;

				
				tmp_p = (unsigned short *) &work_out[16];
				for (component=0;component<5;component++) {
					for (num_bit=0;num_bit<16;num_bit++) {
						unsigned short valeur;

						valeur = *tmp_p++;

						if (valeur == 0xffff) {
							continue;
						}

						switch(component) {
							case 0:
								VDI_redmask |= 1<< valeur;
								break;
							case 1:
								VDI_greenmask |= 1<< valeur;
								break;
							case 2:
								VDI_bluemask |= 1<< valeur;
								break;
							case 3:
								VDI_alphamask |= 1<< valeur;
								break;
						}
					}
				}
			}

			
			if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) {
				VDI_greenmask &= ~(7<<13);
			}
			break;
		case VDI_CLUT_NONE:
			break;
	}
}