This is xsim.c in view mode; [Download] [Up]
/*
* xanim_x11.c
*
* Copyright (C) 1990,1991,1992,1993,1994 by Mark Podlipec.
* All rights reserved.
*
* This software may be freely copied, modified and redistributed without
* fee for non-commerical purposes provided that this copyright notice is
* preserved intact on all copies and modified copies.
*
* There is no warranty or other guarantee of fitness of this software.
* It is provided solely "as is". The author(s) disclaim(s) all
* responsibility and liability with respect to this software's usage
* or its effect upon hardware or computer systems.
*
*/
#include "xanim.h"
ULONG X11_Get_True_Color(r,g,b,bits)
register ULONG r,g,b,bits;
{
register ULONG temp,temp_color;
temp = (x11_red_bits >= bits)?(r << (x11_red_bits - bits))
:(r >> (bits - x11_red_bits));
temp_color = (temp << x11_red_shift) & x11_red_mask;
temp = (x11_green_bits >= bits)?(g << (x11_green_bits - bits))
:(g >> (bits - x11_green_bits));
temp_color |= (temp << x11_green_shift) & x11_green_mask;
temp = (x11_blue_bits >= bits)?(b << (x11_blue_bits - bits))
:(b >> (bits - x11_blue_bits));
temp_color |= (temp << x11_blue_shift) & x11_blue_mask;
return(temp_color);
}
ULONG X11_Get_Line_Size(xsize)
ULONG xsize;
{
ULONG line_size;
if (x11_display_type == XA_MONOCHROME)
line_size = X11_Get_Bitmap_Width(xsize) / 8;
else line_size = xsize * x11_bytes_pixel;
return(line_size);
}
void X11_Pre_Setup(argcp, argv,xa_user_visual,xa_user_class)
int *argcp;
char *argv[];
LONG xa_user_visual;
LONG xa_user_class;
{
LONG i,vis_num,vis_i;
/* setup up X11 variables */
x11_depth = 24;
x11_class = TrueColor;
x11_cmap_size = 256;
/* Make sure x11_cmap_size is power of two */
{
ULONG size;
size = 0x01; x11_disp_bits = 0;
while(size <= x11_cmap_size) { size <<= 1; x11_disp_bits++; }
size >>=1; x11_disp_bits--;
x11_cmap_size = 0x01 << x11_disp_bits;
}
x11_bit_order = X11_LSB;
x11_bitmap_unit = 3;
x11_depth_mask = (0x01 << x11_depth) - 1;
x11_cmap_type = 0;
if (x11_depth == 1)
{
x11_display_type = XA_MONOCHROME;
x11_bytes_pixel = 1; x11_bitmap_pad = x11_bitmap_unit;
x11_cmap_flag = FALSE;
x11_black = 0;
x11_white = 1;
x11_bits_per_pixel = 1;
x11_byte_order = x11_bit_order;
}
else
{
if (x11_depth > 16)
{ x11_bytes_pixel = 4; x11_bitmap_pad = 32; }
else if (x11_depth > 8)
{ x11_bytes_pixel = 2; x11_bitmap_pad = 16; }
else { x11_bytes_pixel = 1; x11_bitmap_pad = 8; }
x11_bits_per_pixel = x11_depth;
switch(x11_class)
{
case StaticGray:
x11_display_type = XA_STATICGRAY;
x11_cmap_flag = FALSE;
break;
case GrayScale:
x11_display_type = XA_GRAYSCALE;
x11_cmap_flag = TRUE;
break;
case StaticColor:
x11_display_type = XA_STATICCOLOR;
x11_cmap_flag = FALSE;
break;
case PseudoColor:
x11_display_type = XA_PSEUDOCOLOR;
x11_cmap_flag = TRUE;
break;
case TrueColor:
x11_display_type = XA_TRUECOLOR;
x11_cmap_flag = FALSE;
break;
case DirectColor:
x11_display_type = XA_DIRECTCOLOR;
x11_cmap_flag = FALSE;
break;
default:
fprintf(stderr,"Unkown x11_class %lx\n",x11_class);
TheEnd();
}
}
x11_red_mask = 255;
x11_green_mask = 255<<8;
x11_blue_mask = 255<<16;
x11_red_shift = 0;
x11_green_shift = 8;
x11_blue_shift = 16;
x11_red_bits = 8;
x11_green_bits = 8;
x11_blue_bits = 8;
xa_cmap = (ColorReg *) malloc( x11_cmap_size * sizeof(ColorReg) );
if (xa_cmap==0) fprintf(stderr,"X11 CMAP: couldn't malloc\n");
if (x11_verbose_flag == TRUE)
{
fprintf(stderr,"Selected Visual: ");
fprintf(stderr,"NEXTSTEP");
fprintf(stderr," (%lx) \n",x11_display_type);
fprintf(stderr," depth= %ld class= %ld cmap size=%ld(%ld) bytes_pixel=%ld\n",
x11_depth, x11_class, x11_cmap_size, x11_disp_bits, x11_bytes_pixel );
if (x11_display_type & XA_X11_TRUE)
{
fprintf(stderr," X11 Color Masks =%lx %lx %lx\n",
x11_red_mask,x11_green_mask ,x11_blue_mask);
fprintf(stderr," X11 Color Shifts=%ld %ld %ld\n",
x11_red_shift, x11_green_shift, x11_blue_shift );
fprintf(stderr," X11 Color Sizes =%ld %ld %ld\n",
x11_red_bits,x11_green_bits ,x11_blue_bits);
}
else if (x11_display_type == XA_MONOCHROME)
{
fprintf(stderr," Bit Order = %lx bitmapunit = %lx\n",
x11_bit_order,x11_bitmap_unit);
}
fprintf(stderr,"\n");
}
/* kludges */
if ( (!(x11_display_type & XA_X11_TRUE))
&& (x11_depth == 24) && (x11_cmap_size <= 256) ) x11_kludge_1 = TRUE;
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.