home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.1 / JimmDemos / DemoSource / huge.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.1 KB  |  131 lines

  1. /* huge.c -- get huge bitmap for overcan experiments
  2.  * Copyright (c) 1988, I and I Computing and Commodore-Amiga, Inc.
  3.  *
  4.  *
  5.  * Executables based on this information may be used in software
  6.  * for Commodore Amiga computers.  All other rights reserved.
  7.  *
  8.  * This information is provided "as is"; no warranties are made.
  9.  * All use is at your own risk, and no liability or responsibility is assumed.
  10.  */
  11.  
  12. #include "sysall.h"
  13. #include "oscan.h"
  14.  
  15. #define HRULEY        (150L)
  16. #define VRULEX        (300L)
  17. #define VRULESTART    (2)            /* start VRULE at 200    */
  18.  
  19. #define HASHHEIGHT    (20L)        /* size of hash marks    */
  20. #define HASHWIDTH    (20L)    
  21.  
  22. struct BitMap *
  23. getHugeBitMap( numplanes )
  24. int                numplanes;
  25. {
  26.     struct BitMap    *bmap;
  27.     int                plane;
  28.  
  29.     if ( numplanes < 1 ) numplanes = 1;
  30.     if ( numplanes > 4 ) numplanes = 4;
  31.  
  32.     bmap = (struct BitMap *)
  33.         AllocMem( (LONG) sizeof ( struct BitMap ), (ULONG) MEMF_CLEAR );
  34.  
  35.     if ( bmap )
  36.     {
  37.         InitBitMap( bmap, (LONG) numplanes, HUGEWIDTH, HUGEHEIGHT );
  38.         for ( plane = 0; plane < numplanes; ++plane )
  39.         {
  40.             if (!(bmap->Planes[ plane ] = AllocRaster( HUGEWIDTH, HUGEHEIGHT )))
  41.             {
  42.                 printf(" cannot get raster: %d\n", plane );
  43.                 freeHugeBitMap( bmap );
  44.                 return ( NULL );
  45.             }
  46.         }
  47.     }
  48.     return ( bmap );
  49. }
  50.  
  51. freeHugeBitMap( bmap )
  52. struct BitMap *bmap;
  53. {
  54.     int        plane;
  55.  
  56.     if ( bmap )
  57.     {
  58.         plane = bmap->Depth;
  59.         while ( plane-- )
  60.         {
  61.             if ( bmap->Planes[ plane ] )
  62.             {
  63.                 FreeRaster( bmap->Planes[plane], HUGEWIDTH, HUGEHEIGHT );
  64.             }
  65.         }
  66.         FreeMem( bmap, (LONG) sizeof ( struct BitMap ) );
  67.     }
  68. }
  69.  
  70. UBYTE    posbuff[ 20 ];
  71.  
  72. drawHugeBitMap( rp )
  73. struct RastPort *rp;
  74. {
  75.     int        hunnert;
  76.     int        pos;
  77.     int        endpos;
  78.     int        tlength;
  79.  
  80.     /* draw horizontal counters and hashmarks */
  81.     SetAPen( rp, 1L );
  82.     Move( rp, 0L, (LONG) HRULEY + HASHHEIGHT / 2 );
  83.     Draw( rp, (LONG) HUGEWIDTH - 1, (LONG) HRULEY + HASHHEIGHT / 2 );
  84.  
  85.     for (hunnert = 0; (endpos = (hunnert+1) * 100) <= HUGEWIDTH; ++hunnert)
  86.     {
  87.         /* tall hashmark at X00    */
  88.         pos = hunnert * 100;
  89.         SetAPen( rp, 3L );
  90.         Move( rp, (LONG) pos, HRULEY );
  91.         Draw( rp, (LONG) pos, HRULEY  + 2 * HASHHEIGHT);
  92.  
  93.         while (  (pos += 10) < endpos )
  94.         {
  95.             Move( rp, (LONG) pos, HRULEY );
  96.             Draw( rp, (LONG) pos, HRULEY  + HASHHEIGHT);
  97.         }
  98.  
  99.         sprintf( posbuff, "%d", endpos);
  100.         tlength = TextLength( rp, posbuff, (LONG) strlen( posbuff ) );
  101.         SetAPen( rp, 7L );
  102.         Move( rp, (LONG) endpos - tlength - 1,
  103.             HRULEY  + 2 * HASHHEIGHT);
  104.         Text( rp, posbuff, (LONG) strlen( posbuff ) );
  105.     }
  106.  
  107.     /* draw vertical counters */
  108.     Move( rp, VRULEX + HASHWIDTH / 2, (LONG) VRULESTART * 100 );
  109.     Draw( rp, VRULEX + HASHWIDTH / 2, (LONG) HUGEHEIGHT - 1 );
  110.  
  111.     for (hunnert = VRULESTART;
  112.         (endpos = (hunnert + 1) * 100) <= HUGEHEIGHT; ++hunnert)
  113.     {
  114.         /* wide hashmark at X00    */
  115.         pos = hunnert * 100;
  116.         Move( rp, VRULEX, (LONG) pos);
  117.         Draw( rp,  VRULEX  + 2 * HASHWIDTH, (LONG) pos);
  118.  
  119.         while (  (pos += 10) < endpos )
  120.         {
  121.             Move( rp, VRULEX, (LONG) pos);
  122.             Draw( rp,  VRULEX  + HASHWIDTH, (LONG) pos);
  123.         }
  124.  
  125.         sprintf( posbuff, "%d", endpos);
  126.         tlength = TextLength( rp, posbuff, (LONG) strlen( posbuff ) );
  127.         Move( rp, VRULEX - tlength - 1, (LONG) endpos - 1);
  128.         Text( rp, posbuff, (LONG) strlen( posbuff ) );
  129.     }
  130. }
  131.