home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 102 / examples / ladybug1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-01-25  |  3.6 KB  |  80 lines

  1. /* Programmer's guide to GEM - 1986 - p.158 -listing 3.2 - CJPurcell Dec'86  */
  2. /* CTRLRC.C  -  MAIN DRIVER for draw_rc()  examples  using Mark Williams C   */
  3. /* to be tested in NDC and/or RC mode with or without GDOS for implications  */
  4. #include <portab.h>                       /* try <> and see ?? */
  5. #include <osbind.h>                       /* system constants  */
  6. #include <gemdefs.h>                      /* GEM-definition    */
  7. /* #include <obdefs.h>                    / * object definition*/
  8.  
  9. WORD contrl[12], intin[128], ptsin[128], intout[128], ptsout[128];
  10.  
  11. #define M_OFF 256
  12. #define RC_COORDS 2
  13. #define RIGHT_ALIGNED 2
  14. #define BOTTOM_ALIGNED 3
  15.  
  16. VOID main()                /* not GEMAIN as in ref. */
  17. {
  18.         WORD handle, work_in[11], work_out[57], max_w, max_h;
  19.         WORD ii;
  20.  
  21.         appl_init();                                    /* init AES for call */
  22.         handle = graf_handle( &ii,&ii,&ii,&ii );        /* get screen handle */
  23.         graf_mouse( M_OFF, NULL );                      /* hide mouse        */
  24.         v_clrwk( handle );                              /* clear workstation */
  25.  
  26.         for( ii=0; ii<11; ++ii ) work_in[ii]=1;         /* init work_in array*/
  27.         work_in[10] = RC_COORDS;                     /* using RC coordinates */
  28.         v_opnvwk( work_in, &handle, work_out );      /* open the workstation */
  29.  
  30.         max_w = work_out[0]; max_h = work_out[1];
  31.         draw_rc( handle,0,0,max_w,max_h );           /* do the examp.routine */
  32.  
  33.         vst_alignment( handle,RIGHT_ALIGNED,BOTTOM_ALIGNED,&ii,&ii );
  34.         v_gtext( handle,max_w,max_h,"Press any Key to Continue" );
  35.         evnt_keybd();                                   /* pause for viewing */
  36.         v_clsvwk( handle );                             /* close workstation */
  37.         appl_exit();                                    /* tell AES finished */
  38. }
  39.  
  40. /* ref. p.235 Listing 3.22 CPYTRAN1.C - Display a bit image bug on screen    */
  41.  
  42. #define ADDR        /*?*/
  43. #define MD_REPLACE    1
  44. #define ImageBytes    2                                 /* # bytes in raster */
  45. #define ImageRows     10                                /*   rows            */
  46. #define ImageBitWidth 11                                /* # significant bits*/
  47. WORD image[10] =  { 0x9200,0x4900,0x2480,0x3f80,0x7fd0,
  48.                     0x7fd0,0x3f80,0x2480,0x4900,0x9200 };
  49. VOID draw_rc( handle, dx, dy, swidth, sheight )
  50.         WORD  handle, dx, dy, swidth, sheight;
  51. {
  52.  
  53.         FDB  img_m , scr_m    ;
  54.         WORD pxy[8], colors[2];
  55.  
  56.         img_m.fd_addr             = ADDR( image )   ;
  57.         img_m.fd_w                = ImageBytes << 3 ;
  58.         img_m.fd_h                = ImageRows       ;
  59.         img_m.fd_wdwidth          = ImageBytes >> 1 ;
  60.         img_m.fd_stand            = 1               ;
  61.         img_m.fd_nplanes          = 1               ;
  62.         img_m.fd_r1 = img_m.fd_r2 = img_m.fd_r3 = 0 ;
  63.  
  64.         scr_m.fd_addr    =    0L ;          /* Screen FDB -> physical device */
  65.  
  66.         colors[0]  = 1  ; colors[1] = 0     ;       /*  Black and White      */
  67.  
  68.         vr_trnfm( handle, &img_m, &img_m )  ;       /* in place transform    */
  69.  
  70.         pxy[0]     = 0 ;
  71.         pxy[1]     = 0 ;
  72.         pxy[2]     = pxy[0] + ImageBitWidth -1 ;
  73.         pxy[3]     = pxy[1] + ImageRows - 1 ;
  74.         pxy[4]     = dx + swidth / 2 ;
  75.         pxy[5]     = dy + sheight / 2 ;
  76.         pxy[6]     = pxy[4] + ImageBitWidth ;
  77.         pxy[7]     = pxy[5] + ImageRows ;
  78.         vrt_cpyfm( handle, MD_REPLACE, pxy, &img_m, &scr_m, colors );/*BITBLT*/
  79. }                                                        /*CJPurcell 07Dec'86*/
  80.