|
|
DataMuseum.dkPresents historical artifacts from the history of: RegneCentralen RC759 "Piccoline" |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about RegneCentralen RC759 "Piccoline" Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 5632 (0x1600)
Types: TextFile
Names: »XLIB.C«
└─⟦33b70227c⟧ Bits:30003931/GEM_Develop_disk_3_CDOS.imd Disketter indleveret af Steffen Jensen (Piccolo/Piccoline)
└─⟦this⟧ »XLIB.C«
└─⟦f18477172⟧ Bits:30003931/GEM_Develop_disk_1_CDOS.imd Disketter indleveret af Steffen Jensen (Piccolo/Piccoline)
└─⟦this⟧ »SAMP\XLIB.C«
/*----------------------------------------------------------------------*/
/* The source code contained in this listing is a non-copyrighted */
/* work which can be freely used. In applications of the source code */
/* you are requested to acknowledge Digital Research, Inc. as the */
/* originator of this code. */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* xlib.c - transformation library. */
/* all funcs and vars begin with "x_" */
/*----------------------------------------------------------------------*/
#include "portab.h"
#include "machine.h"
GLOBAL WORD x_xmul = 1 ; /* scaling factors for x transformation */
GLOBAL WORD x_xdiv = 1 ;
GLOBAL WORD x_xtrans = 0 ; /* translate factor for x transformation */
GLOBAL WORD x_ymul = 1 ; /* scaling factors for x transformation */
GLOBAL WORD x_ydiv = 1 ;
GLOBAL WORD x_ytrans = 0 ; /* translate factor for x transformation */
/* multiplies two integers into a long, divides back into an integer. */
EXTERN WORD SMUL_DIV() ;
/*----------------------------------------------------------------------*/
/* return number of pixels in x-direction physically equal to "y" */
/* number of pixels in y-direction. */
WORD
x_ytox(y, dev_attr )
WORD y ;
WORD dev_attrÆÅ ;
æ
return( SMUL_DIV( y, dev_attrÆ 4 Å, dev_attrÆ 3 Å ) ) ;
å
/*----------------------------------------------------------------------*/
/* the following 8 functions can be implemented as #define macros if */
/* speed is essential and space is not. */
/*----------------------------------------------------------------------*/
/* transform an x-value from user space into device space. */
WORD
x_udx_xform( user_x )
WORD user_x ;
æ
return( SMUL_DIV( user_x, x_xmul, x_xdiv ) + x_xtrans) ;
å
/*----------------------------------------------------------------------*/
/* transform a y-value from user space into device space. */
WORD
x_udy_xform(user_y)
WORD user_y ;
æ
return( SMUL_DIV( user_y, x_ymul, x_ydiv ) + x_ytrans) ;
å
/*----------------------------------------------------------------------*/
/* transform a x-value from device space into user space. */
WORD
x_dux_xform( x )
WORD x ;
æ
return( SMUL_DIV( x - x_xtrans, x_xdiv, x_xmul ) ) ;
å
/*----------------------------------------------------------------------*/
/* transform an x-value from device space into user space. */
WORD
x_duy_xform( y )
WORD y ;
æ
return( SMUL_DIV( y - x_ytrans, x_ydiv, x_ymul ) ) ;
å
/*----------------------------------------------------------------------*/
/* scale an x-distance from user space into device space. */
WORD
x_udx_scale( user_dx )
WORD user_dx ;
æ
return( SMUL_DIV( user_dx, x_xmul, x_xdiv ) ) ;
å
/*----------------------------------------------------------------------*/
/* scale a y-distance from user space into device space. */
WORD
x_udy_scale( user_dy )
WORD user_dy ;
æ
return( SMUL_DIV( user_dy, x_ymul, x_ydiv ) ) ;
å
/*----------------------------------------------------------------------*/
/* scale an x-distance from device space into user space. */
WORD
x_dux_scale( dev_x )
WORD dev_x ;
æ
return( SMUL_DIV( dev_x, x_xdiv, x_xmul ) ) ;
å
/*----------------------------------------------------------------------*/
/* scale a x-distance from device space into user space. */
WORD
x_duy_scale( dev_y )
WORD dev_y ;
æ
return( SMUL_DIV( dev_y, x_ydiv, x_ymul ) ) ;
å
/*----------------------------------------------------------------------*/
/* set translation values, given widths and heights for both user and */
/* device space are set to non-zero. */
x_sxform( user_x, user_y, user_w, user_h, dev_x, dev_y, dev_w, dev_h )
WORD user_x, user_y, user_w, user_h, dev_x, dev_y, dev_w, dev_h ;
æ
if ( !(dev_w && dev_h && user_w && user_h) )
return(FALSE);
x_xmul = dev_w ;
x_xdiv = user_w ;
x_ymul = dev_h ;
x_ydiv = user_h ;
x_xtrans = dev_x - SMUL_DIV( user_x, x_xmul, x_xdiv ) ;
x_ytrans = dev_y - SMUL_DIV( user_y, x_ymul, x_ydiv ) ;
å /* x_set_xform */
/*----------------------------------------------------------------------*/
/* this procedure matches an aspect ratio on the device with one */
/* specified in user units. The match is done in physical units */
/* rather than pixels, so a square specified in user units will look */
/* square when displayed on the device. Calculating the aspect ratio */
/* match in this fashion takes care of devices with non-square pixels. */
VOID
x_saspect( user_w, user_h, dev_w, dev_h, dev_attr )
WORD user_w, user_h ;
WORD *dev_w, *dev_h ;
WORD dev_attrÆÅ ;
æ
LONG y_ratio, x_ratio ;
x_ratio = (LONG)(*dev_w) * (LONG)(dev_attrÆ 3 Å/10) * (LONG)(user_h/4) ;
y_ratio = (LONG)(*dev_h) * (LONG)(dev_attrÆ 4 Å/10) * (LONG)(user_w/4) ;
/* divide by ten to get pixel sizes back to VDI 1.x */
/* sizes so longs don't wrap to negative numbers */
if (y_ratio < x_ratio)
æ
*dev_w = SMUL_DIV( *dev_h, dev_attrÆ 4 Å, dev_attrÆ 3 Å ) ;
*dev_w = SMUL_DIV( *dev_w, user_w, user_h ) ;
å
else
æ
*dev_h = SMUL_DIV( *dev_w, dev_attrÆ 3 Å, dev_attrÆ 4 Å ) ;
*dev_h = SMUL_DIV( *dev_h, user_h, user_w ) ;
å
å /* x_saspect */
«eof»