home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 269_01 / demoibm.c < prev    next >
Text File  |  1987-05-17  |  20KB  |  844 lines

  1. /*                      Demo4.c
  2. *
  3. *    This program is designed to illustate some of the features contained
  4. *  in the UC4 library.  It uses the 4 color medium resolution mode of the
  5. *  IBM PC and compatibles.  A second version of the library is available
  6. *  to be used with the 16 color medium resolution mode (mode 9) on the
  7. *  Tandy 1000 computer.
  8. */
  9.  
  10. int i;
  11.  
  12. main()
  13. {
  14.  
  15.    int start = 9;
  16.  
  17.    sm(4);
  18.    backclr(1);
  19.  
  20.    gothic('U',10,start+0,3);
  21.    gothic('n',10,start+25,3);
  22.    gothic('i',10,start+45,3);
  23.    gothic('c',10,start+60,3);
  24.    gothic('o',10,start+80,3);
  25.    gothic('r',10,start+100,3);
  26.    gothic('n',10,start+120,3);
  27.  
  28.    gothic('S',10,start+150,3);
  29.    gothic('o',10,start+170,3);
  30.    gothic('f',10,start+190,3);
  31.    gothic('t',10,start+205,3);
  32.    gothic('w',10,start+220,3);
  33.    gothic('a',10,start+240,3);
  34.    gothic('r',10,start+260,3);
  35.    gothic('e',10,start+280,3);
  36.  
  37.    raschar('P', 50, start + 70, 2, 2, 3);
  38.    raschar('r', 50, start + 90, 2, 2, 3);
  39.    raschar('e', 50, start + 110, 2, 2, 3);
  40.    raschar('s', 50, start + 130, 2, 2, 3);
  41.    raschar('e', 50, start + 150, 2, 2, 3);
  42.    raschar('n', 50, start + 170, 2, 2, 3);
  43.    raschar('t', 50, start + 190, 2, 2, 3);
  44.    raschar('s', 50, start + 210, 2, 2, 3);
  45.    victory();
  46.    unicorn();
  47.    greenslv();
  48.    atsay(24, 3, 2, 0,"Copyright (c) 1986 David A. Miller");
  49.    cntue();
  50.    waitkey();
  51.    sm(4);       /* this resets the mode which in effect is a
  52.                    clear screen command.                      */
  53.    backclr(9);
  54.  
  55.    printf("\n\n\n  A demonstration of IBM PC graphics\n");
  56.    printf(" using the 4 color med. resolution mode\n");
  57.    printf(" and the unicorn library of functions.\n");
  58.    printf(" This library is designed to work with \n");
  59.    printf(" the Microsoft C small model. It has\n");
  60.    printf(" been written using Microsoft C 4.0 \n");
  61.    printf(" and the Microsoft Assembler 4.0.\n");
  62.    printf("    Not all library functions are\n");
  63.    printf(" illustrated in this demo.  The\n");
  64.    printf(" library is capable of many graphics\n");
  65.    printf(" concepts including points, lines,\n");
  66.    printf(" circles, ellipses (these may be \n");
  67.    printf(" rotated from the vertical or\n");
  68.    printf(" horizontal and colorful print\n");
  69.    printf(" including different fonts.  We\n");
  70.    printf(" hope you enjoy the Unicorn library!\n\n");
  71.    printf(" Version 4.0 pre-release for Microsoft\n");
  72.    printf(" C small model.\n");
  73.    printf("  Copyright (C) 1986 David A. Miller\n");
  74.    atsay(23,8,2,0,"Press any key to continue");
  75.    waitkey();
  76.    sm(4);       /* this resets the mode which in effect is a
  77.                    clear screen command.                      */
  78.    backclr(14);
  79.  
  80.  
  81.  
  82.    pg1();
  83.    waitkey();
  84.    sm(4);
  85.    backclr(1);
  86.  
  87.  
  88.  
  89.    pg2();
  90.    cntue();
  91.    waitkey();
  92.    sm(4);
  93.    backclr(1);
  94.  
  95.    pg3();
  96.    cntue();
  97.    waitkey();
  98.    sm(4);
  99.    backclr(9);
  100.  
  101.    atom();
  102.    cntue();
  103.    waitkey();
  104.    sm(4);
  105.    backclr(1);
  106.  
  107.    printf("   The next screen will demonstrate\n\n");
  108.    printf("    T U R T L E  F U N C T I O N S");
  109.  
  110.    burble(100, 300); 
  111.  
  112.    printf("\n\n\n\n\n   The delay function is used to");
  113.    printf("\n   slow down the display of lines\n");
  114.    cntue();
  115.    waitkey();
  116.    palette(0,5,8);
  117.  
  118.    pg5();
  119.    cntue();
  120.    waitkey();
  121.    sm(4);
  122.    backclr(1);
  123.  
  124.    script('P', 5, 100, 3);
  125.    script('a', 5, 116, 3);
  126.    script('l', 5, 132, 3);
  127.    script('e', 5, 148, 3);
  128.    script('t', 5, 164, 3);
  129.    script('t', 5, 180, 3);
  130.    script('e', 5, 196, 3);
  131.  
  132.    redalert();
  133.  
  134.    printf("\n\n\n\nThe following page illustrates\n");
  135.    printf("the palette command.  This command\n");
  136.    printf("allows the programmer to control the\n");
  137.    printf("color set and background color with\n");
  138.    printf("one command.  There are a total of 6\n");
  139.    printf("sets of three colors that may be \n");
  140.    printf("displayed.  Three of these are normal;\n");
  141.    printf("while the other three are bright\n");
  142.    printf("versions of the basic three.\n");
  143.    printf("\n\n     Press any key to continue\n");
  144.    waitkey();
  145.  
  146.    pg6();
  147.    cntue();
  148.    waitkey();
  149.    sm(4);
  150.    backclr(9);
  151.  
  152.  
  153.    pg7();
  154.    cntue();
  155.    waitkey();
  156.    sm(4);
  157.    backclr(9);
  158.  
  159.  
  160.    pg8();
  161.    atsay(24,7,3,0, "Press any key to continue");
  162.    waitkey();
  163.    sm(4);
  164.    backclr(9);
  165.  
  166.    pgf();
  167.    greenslv();
  168.    waitkey();
  169.    sm(3);
  170.    backclr(1);
  171.  
  172. }  /*  End of main program */
  173.  
  174.  
  175.  
  176. pg1()
  177. {
  178.    burble(200,300);
  179.  
  180.    atsay(10,5,2,0, "The next page will demonstrate");
  181.    atsay(11,5,2,0, "some of the simple graphics");
  182.    atsay(12,5,2,0, "primitives including dots,");
  183.    atsay(13,5,2,0, "lines, filled boxes and");
  184.    atsay(14,5,2,0, "rectangles. ");
  185.    atsay(20,5,3,0, "Press any key to continue");
  186. }
  187.  
  188. pg2()
  189. {
  190.    int i;
  191.  
  192.    for(i=0; i <= 20; i++)
  193.       point(20, 10+i*2, i % 4);
  194.    box(50,20,80,50,1);
  195.    boxfill(54,24,76,46,2);
  196.    box1(50,80,80,110,2,1);
  197.    box2(50,140,80,170,3,1);
  198.    circle(65,240,50,1,1,3);
  199.    paint(65,240,2,3);
  200.    line(120,20,190,300,1);
  201.    line(190,20,120,300,2);
  202.    line(155,20,155,300,3);
  203. }
  204.  
  205. pg3()
  206. {
  207.    atsay(7,5,3,0, "The following screen will further");
  208.    atsay(8,5,3,0, "demonstrate the circle function");
  209.    atsay(9,5,3,0, "and introduce the rotated ellipse");
  210.    atsay(10,5,3,0, "function.  The latter allows the");
  211.    atsay(11,5,3,0, "user to draw an ellipse with a");
  212.    atsay(12,5,3,0, "specified aspect and angle of");
  213.    atsay(13,5,3,0, "rotation.");
  214. }
  215.  
  216. pg5()
  217. {
  218.  
  219.    turnright(150);     /*  Double Triangle  */
  220.  
  221.    pencolor(1);
  222.  
  223.    forward(50);
  224.  
  225.    delay(500);
  226.    turnright(120);
  227.    forward(50);
  228.    delay(500);
  229.    turnright(120);
  230.    forward(100);
  231.    delay(500);
  232.    turnleft(120);
  233.    forward(50);
  234.    delay(500);
  235.    turnleft(120);
  236.    forward(50);
  237.  
  238.    turnright(180);
  239.    forward(50);
  240.  
  241.    pencolor(0);
  242.    
  243.    forward(50);
  244.    turnright(120);
  245.    pencolor(2);
  246.    delay(500);
  247.    forward(100);
  248.    turnright(60);
  249.    delay(500);
  250.    forward(100);
  251.    turnright(60);
  252.    delay(500);
  253.    forward(100);
  254.    turnright(60);
  255.    delay(500);
  256.    forward(100);
  257.    turnright(60);
  258.    delay(500);
  259.    forward(100);
  260.    turnright(60);
  261.    delay(500);
  262.    forward(97);
  263.  
  264.    turnright(72);
  265.    forward(5);
  266.    pencolor(0);
  267.    forward(48);
  268.    turnright(96);
  269.  
  270.    turnleft(72);
  271.    pencolor(3);
  272.    forward(90);
  273.    turnright(72);
  274.    forward(90);
  275.    turnright(72);
  276.    forward(90);
  277.    turnright(72);
  278.    forward(90);
  279.    turnright(73);
  280.    forward(90);
  281.    pencolor(0);
  282.  
  283.    paint(90,160,3,1);
  284.    paint(110,160,3,1);
  285.  
  286.    burble(300,400);
  287.  
  288.    paint(40,160,2,3);
  289.    paint(182,160,1,2);
  290.  
  291.  }
  292.  
  293.  
  294.  
  295.  
  296. pg6()
  297. {
  298.    palette(2,4,0);
  299.    house();
  300.  
  301.    palette(0,5,0);
  302.    house();
  303.  
  304.    palette(0,4,0);
  305.    palette(0,4,0);
  306.    house();
  307.  
  308. }
  309.  
  310. house()
  311. {
  312.    for(i=0;i<=120;i++)
  313.       point(rand() / 165,rand() / 103, rand() / 8192);
  314.  
  315.    line(180,0,180,319,1);        /* grass line */
  316.    paint(183,10,1,1);            /*   grass */
  317.    line(150,50,120,110,1);
  318.    line(120,110,152,160,1);
  319.  
  320.    line(140,70,180,70,1);
  321.    line(140,140,180,140,1);
  322.    line(180,70,180,140,1);
  323.  
  324.    line(160,80,180,80,1);
  325.    line(160,95,180,95,1);
  326.    line(160,80,160,95,1);
  327.  
  328.  
  329.    line(150,110,170,110,1);       /* Window */
  330.    line(150,120,170,120,1);
  331.    line(150,130,170,130,1);
  332.    line(150,110,150,130,1);
  333.    line(160,110,160,130,1);
  334.    line(170,110,170,130,1);
  335.    paint(155,115,2,1);             /* color the widow panes */
  336.    paint(155,125,2,1);
  337.    paint(165,115,2,1);
  338.    paint(165,125,2,1);
  339.    paint(130,110,3,1);            /* color the house  */
  340.  
  341.    line(130,100,130,120,2);       /* lines in the house */
  342.    line(161,75,161,79,2);
  343.    line(155,86,155,97,2);
  344.    line(165,100,165,107,2);
  345.    line(161,72,161,78,2);
  346.    line(142,70,142,93,2);
  347.    line(147,100,147,116,2);
  348.  
  349.    paint(170,90,2,1);             /*  color the door   */
  350.    circle(170,90,2,1,1,1);        /*    knob           */
  351.    paint(170,90,2,1);             /*   fill it         */
  352.    line(114,124,128,124,2);       /*   chimney         */
  353.    line(114,136,136,136,2);
  354.    line(114,124,114,136,2);
  355.    line(128,124,136,