home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / setcpu_400.lzh / SetCPU / coolhand.c < prev    next >
C/C++ Source or Header  |  1990-11-03  |  8KB  |  187 lines

  1. /*
  2.     SetCPU V1.60
  3.     by Dave Haynie, April 13, 1990
  4.     Released to the Public Domain
  5.  
  6.     COOLHAND MODULE
  7.  
  8.     This module contains the code used to display a cool looking 
  9.     KickStart prompt hand on the screen.
  10. */
  11.  
  12. #include "setcpu.h"
  13.  
  14. /* ====================================================================== */
  15.  
  16. /* This is the KickStart hand design as in the A1000.  Only, Intuition makes
  17.    it considerably easier to build than they way the Kernel ROM does it. */
  18.    
  19. /* Define the vectors.  The hand is a drawing composed of a series of line
  20.    vectors.  Intuition provides a handy structure, called a boarder, that'll
  21.    render this whole mess with a single function call. */
  22.  
  23. static WORD vect1[] = {  0,  0, 23,  0, 23, 22, 78, 22, 78,  0, 90,  0,101, 11,
  24.                        101, 83, 92, 83, 92, 45, 29, 45, 27, 43, 18, 43, 17, 45,
  25.                         10, 45, 10, 54,  0, 61,  0,  0 };
  26. static WORD vect2[] = {  0,  0,  0,-62, 93,-62,105,-50,105, 23, 53, 23, 53, 28,
  27.                         49, 36, 45, 41, 41, 44, 35, 53, 27, 57, 27, 68,-23, 68,
  28.                        -23, 37,-24, 37,-24,  9,-20,  3,-13, -3,-12, -7, -8,-14,
  29.                         -3,-17,  0,-18,  0,-18, -3,-16, -7,-14,-11, -7,-12, -3,
  30.                        -19,  3,-23,  9,-23, 36,-22, 37,-22, 67,  7, 67,  7, 46,
  31.                         15, 46, 19, 44, 19, 23, 17, 20, 17, 10, 32, -3, 32,-15,
  32.                         29,-17, 26,-17, 29,-14, 29, -7, 28, -6, 21, -6, 18, -9,
  33.                          9, -2, -3,  4,-15, 13,-15, 12, -3,  3, -7,  2,-10, -1,
  34.                         -7,  1, -3,  2,  0,  0 };
  35. static WORD vect3[] = {  0,  0,  2, -7, 10, -6, 11, -3, 11,  4,  4,  4,  0,  0 };
  36. static WORD vect4[] = {  0,  0,  0,-10, 15,-23, 15,-35, 74,-35, 74,  2,  1,  2,
  37.                          0, -2 };
  38. static WORD vect5[] = {  0,  0, 51,  0, 51, 21,  0, 21,  0,  0 };
  39. static WORD vect6[] = {  0,  0, 11,  0, 11, 14,  0, 14,  0,  0 };
  40. static WORD vect7[] = {  0,  0,  7,  0,  7, 12,  0, 12,  0,  0 };
  41. static WORD vect8[] = {  0,  0,  3,  0,  3,  2,  0,  6,  0,  0 };
  42. static WORD vect9[] = {  0,  0,  0,-20,  7,-20, 12,-25, 12,-34, 16,-32, 24,-32,
  43.                         24,-30, 28,-25, 32,-25, 32,-23, 26,-14, 18,-11, 18,  0,
  44.                          0,  0 };
  45. static WORD vect10[] = { 0,  0,  0,  5,  5,  2,  0,  0 };
  46. static WORD vect11[] = { 0,  0, -4,  2, -4, -3, 17, -3,  7,  7,  6,  7,  8,  5,
  47.                          3,  0,  0,  0 };
  48.  
  49. static WORD vect12[] = { 0,  0,  7,  0,  7,  5,  3, 13,  0, 17, -5, 18, -8, 18,
  50.                        -11, 14,-11, 11,  0,  0 };
  51.  
  52. static WORD vect13[] = { 0,  0,  0,  3,  2,  6,  2,  6,  8,  5,  9,  2,  5, -1,
  53.                          0,  0 };
  54. static WORD vect14[] = { 0,  0,  8,  2, 10, -1,  6, -5,  3, -5,  0, -3,  0,  0 };
  55. static WORD vect15[] = { 0,  0, 11, 11, 11, 83 };
  56.  
  57. static struct Border HandLines[] = {
  58.    { 105, 51,1,0,JAM1,18, &vect1[0], &HandLines[1] },
  59.    { 103,112,1,0,JAM1,59, &vect2[0], &HandLines[2] },
  60.    { 120,101,1,0,JAM1, 7, &vect3[0], &HandLines[3] },
  61.    { 121,132,1,0,JAM1, 8, &vect4[0], &HandLines[4] },
  62.    { 130, 51,1,0,JAM1, 5, &vect5[0], &HandLines[5] },
  63.    { 166, 54,1,0,JAM1, 5, &vect6[0], &HandLines[6] },
  64.    { 168, 55,1,0,JAM1, 5, &vect7[0], &HandLines[7] },
  65.    { 117, 97,1,0,JAM1, 5, &vect8[0], &HandLines[8] },
  66.    { 111,179,1,0,JAM1,15, &vect9[0], &HandLines[9] },
  67.    { 123,135,1,0,JAM1, 4,&vect10[0],&HandLines[10] },
  68.    { 127,138,1,0,JAM1, 9,&vect11[0],&HandLines[11] },
  69.    { 148,135,1,0,JAM1,10,&vect12[0],&HandLines[12] },
  70.    { 138,146,1,0,JAM1, 8,&vect13[0],&HandLines[13] },
  71.    { 124,144,1,0,JAM1, 7,&vect14[0],&HandLines[14] },   
  72.    { 196, 51,1,0,JAM1, 3,&vect15[0],NULL },
  73. };
  74.  
  75. /* This is a list of area fills to perform; the first number is the "A" pen
  76.    to set, the next two numbers are the screen position to start filling
  77.    from. */
  78.  
  79. static WORD FillList[][3] = {
  80.    { 2, 107,109 }, { 3, 132, 71 }, { 2, 169, 66 }, { 1, 104, 51 },
  81.    { 1, 129, 51 }, { 1, 167, 55 }, { 1, 176, 67 }, { 1, 182, 55 },
  82.    { 1, 196,134 }, { 1, 145,136 }, { 1, 116, 97 }
  83. };
  84.  
  85. #define FILLCNT    11
  86.  
  87. /* Finally, I've got a few images to render, which I do using the standard
  88.    Intuition Image structures. */
  89.  
  90. UWORD image0[] = {    /* AMIGA */
  91.    0x1f9f,0xfe3f,0xff77,0xfe7c, 0x070c,0xef8f,0x1e71,0xdc30,
  92.    0x07f8,0xe7ce,0x1cf3,0x1fe0, 0x0731,0xf3ce,0x1df6,0x1cc0,
  93.    0x0760,0x03dc,0x3ffc,0x1d80, 0x07c0,0x879c,0x3f78,0x1f00,
  94.    0x0780,0xcf78,0x7e78,0x1e00, 0x0700,0xfeff,0xfc7c,0x1c00,
  95.    0x1001,0x8220,0x4050,0x0004, 0x0404,0x8889,0x1210,0x5010,
  96.    0x0408,0x2448,0x1090,0x1020, 0x0410,0x1042,0x0510,0x1040,
  97.    0x0420,0x0050,0x2690,0x1080, 0x0440,0x0484,0x0900,0x1100,
  98.    0x0480,0x4960,0x4208,0x1200, 0x0500,0x0683,0x8404,0x1400,
  99. };
  100.  
  101. UWORD image1[] = {    /* Kick */
  102.    0xc71f,0x1e63,0x8000, 0x6631,0x8c63,0x0000, 0x3e01,0x8c33,0x0000, 
  103.    0x6631,0x8c1f,0x0000, 0xc61f,0x0e33,0x0000, 0x0600,0x0063,0x0000,
  104.    0x0700,0x0c63,0x8000
  105. };
  106.  
  107. UWORD image2[] = {    /* Start */
  108.    0x703c,0xdc38,0x3e00, 0x9818,0x664c,0x6000, 0x1998,0x780c,0x3c00,
  109.    0x19b8,0x600c,0x0600, 0x7cdc,0x3c3e,0x7c00, 0x1800,0x000c,0x0000,
  110.    0x1000,0x0008,0x0000
  111. };
  112.  
  113. struct Image NameImage[] = {
  114.    { 126,122,64,8,2,&image0[0],3,0,&NameImage[1] },
  115.    { 144,112,48,7,1,&image1[0],2,0,&NameImage[2] },
  116.    { 140,102,48,7,1,&image2[0],2,0,NULL }   
  117. };
  118.  
  119. /* Here's the color scheme. */
  120.  
  121. static WORD coolColor[] = { 0x0fff,0x0000,0x077c,0x0bbb };
  122.  
  123. /* ====================================================================== */
  124.  
  125. /* This section contains data for the mechanics of the CoolHand. */
  126.  
  127. static struct NewScreen newScreen = {
  128.    0,0,320,200,2,0,1,0,CUSTOMSCREEN,NULL,NULL,NULL,NULL
  129. };
  130.  
  131. static struct NewWindow newWindow = {
  132.    0,0,320,200,2,0,0,BORDERLESS|ACTIVATE,NULL,NULL,NULL,NULL,NULL,0,0,0,0,
  133.    CUSTOMSCREEN
  134. };
  135.  
  136. static struct Screen    *coolScreen;
  137. static struct Window    *coolWindow, *coolShade;
  138.  
  139. struct GfxBase        *GfxBase;
  140. struct IntuitionBase    *IntuitionBase;
  141.  
  142. /* ====================================================================== */
  143.  
  144. /* This is the main section.  Since I consider the CoolHand prompt the end
  145.    of this life and the beginning of the next, I'm not going to worry about
  146.    freeing stuff up. */
  147.    
  148. struct Window *CoolHand() {
  149.    struct RastPort *rp;
  150.    struct ViewPort *vp;
  151.    struct Image *image;
  152.    LONG size;
  153.    UWORD i,*bits,*pointer;
  154.    BOOL ok = TRUE;
  155.  
  156.    GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L);
  157.    IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L);
  158.    if (!GfxBase || !IntuitionBase) return;
  159.    if (!(coolScreen = OpenScreen(&newScreen))) return;
  160.    ShowTitle(coolScreen,0L);
  161.    LoadRGB4(vp = &coolScreen->ViewPort,&coolColor[0],4L);
  162.    newWindow.Screen = coolScreen;
  163.    pointer = (UWORD *)AllocMem(64L,MEMF_CHIP|MEMF_CLEAR);
  164.    if (!(coolShade = OpenWindow(&newWindow))) return;
  165.    if (!(coolWindow = OpenWindow(&newWindow))) return;
  166.    WindowToFront(coolShade);
  167.    SetPointer(coolWindow,pointer,2L,2L,0L,0L);
  168.    Delay(25L);
  169.    DrawBorder(rp = coolWindow->RPort,&HandLines[0],0L,0L);
  170.  
  171.    SetOPen(rp,1L);
  172.    for (i = 0; i < FILLCNT; ++i) {
  173.       SetAPen(rp,(long)FillList[i][0]);
  174.       Flood(rp,0L,(long)FillList[i][1],(long)FillList[i][2]);
  175.    }
  176.    for (image = &NameImage[0]; image; image = image->NextImage) {
  177.       size = (LONG) (((image->Width+15)/16)*image->Height)*2*image->Depth;
  178.       movmem((char *)image->ImageData,
  179.              (char *)(bits = (UWORD *)AllocMem(size,MEMF_CHIP)),
  180.              (int)size);
  181.       image->ImageData = bits;
  182.    }
  183.    DrawImage(rp,&NameImage[0],0L,0L);
  184.    CloseWindow(coolShade);
  185.    return coolWindow;
  186. }
  187.