home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource4
/
268_01
/
demoibm.c
< prev
next >
Wrap
Text File
|
1987-05-23
|
19KB
|
843 lines
/* Demo4.c
*
* This program is designed to illustate some of the features contained
* in the UC4 library. It uses the 4 color medium resolution mode of the
* IBM PC and compatibles. A second version of the library is available
* to be used with the 16 color medium resolution mode (mode 9) on the
* Tandy 1000 computer.
*/
#include <uc.h>
int i;
main()
{
int start = 9;
sm(4);
backclr(1);
gothic('U',10,start+0,3);
gothic('n',10,start+25,3);
gothic('i',10,start+45,3);
gothic('c',10,start+60,3);
gothic('o',10,start+80,3);
gothic('r',10,start+100,3);
gothic('n',10,start+120,3);
gothic('S',10,start+150,3);
gothic('o',10,start+170,3);
gothic('f',10,start+190,3);
gothic('t',10,start+205,3);
gothic('w',10,start+220,3);
gothic('a',10,start+240,3);
gothic('r',10,start+260,3);
gothic('e',10,start+280,3);
raschar('P', 50, start + 70, 2, 2, 3);
raschar('r', 50, start + 90, 2, 2, 3);
raschar('e', 50, start + 110, 2, 2, 3);
raschar('s', 50, start + 130, 2, 2, 3);
raschar('e', 50, start + 150, 2, 2, 3);
raschar('n', 50, start + 170, 2, 2, 3);
raschar('t', 50, start + 190, 2, 2, 3);
raschar('s', 50, start + 210, 2, 2, 3);
victory();
unicorn();
greenslv();
atsay(24, 3, 2, 0,"Copyright (c) 1986 David A. Miller");
cntue();
waitkey();
sm(4); /* this resets the mode which in effect is a
clear screen command. */
backclr(9);
printf("\n\n\n A demonstration of IBM PC graphics\n");
printf(" using the 4 color med. resolution mode\n");
printf(" and the unicorn library of functions.\n");
printf(" This library is designed to work with \n");
printf(" the Microsoft C small model. It has\n");
printf(" been written using Microsoft C 4.0 \n");
printf(" and the Microsoft Assembler 4.0.\n");
printf(" Not all library functions are\n");
printf(" illustrated in this demo. The\n");
printf(" library is capable of many graphics\n");
printf(" concepts including points, lines,\n");
printf(" circles, ellipses (these may be \n");
printf(" rotated from the vertical or\n");
printf(" horizontal and colorful print\n");
printf(" including different fonts. We\n");
printf(" hope you enjoy the Unicorn library!\n\n");
printf(" Version 4.0 pre-release for Microsoft\n");
printf(" C small model.\n");
printf(" Copyright (C) 1986 David A. Miller\n");
atsay(23,8,2,0,"Press any key to continue");
waitkey();
sm(4); /* this resets the mode which in effect is a
clear screen command. */
backclr(14);
pg1();
waitkey();
sm(4);
backclr(1);
pg2();
cntue();
waitkey();
sm(4);
backclr(1);
pg3();
cntue();
waitkey();
sm(4);
backclr(9);
atom();
cntue();
waitkey();
sm(4);
backclr(1);
printf(" The next screen will demonstrate\n\n");
printf(" T U R T L E F U N C T I O N S");
burble(200, 300);
printf("\n\n\n\n\n The delay function is used to");
printf("\n slow down the display of lines\n");
cntue();
waitkey();
palette(0,5,8);
pg5();
cntue();
waitkey();
sm(4);
backclr(1);
script('P', 5, 100, 3);
script('a', 5, 116, 3);
script('l', 5, 132, 3);
script('e', 5, 148, 3);
script('t', 5, 164, 3);
script('t', 5, 180, 3);
script('e', 5, 196, 3);
redalert();
printf("\n\n\n\nThe following page illustrates\n");
printf("the palette command. This command\n");
printf("allows the programmer to control the\n");
printf("color set and background color with\n");
printf("one command. There are a total of 6\n");
printf("sets of three colors that may be \n");
printf("displayed. Three of these are normal;\n");
printf("while the other three are bright\n");
printf("versions of the basic three.\n");
printf("\n\n Press any key to continue\n");
waitkey();
pg6();
cntue();
waitkey();
sm(4);
backclr(9);
pg7();
cntue();
waitkey();
sm(4);
backclr(9);
pg8();
atsay(24,7,3,0, "Press any key to continue");
waitkey();
sm(4);
backclr(9);
pgf();
greenslv();
waitkey();
sm(3);
backclr(1);
} /* End of main program */
pg1()
{
burble(200,300);
atsay(10,5,2,0, "The next page will demonstrate");
atsay(11,5,2,0, "some of the simple graphics");
atsay(12,5,2,0, "primitives including dots,");
atsay(13,5,2,0, "lines, filled boxes and");
atsay(14,5,2,0, "rectangles. ");
atsay(20,5,3,0, "Press any key to continue");
}
pg2()
{
int i;
for(i=0; i <= 20; i++)
point(20, 10+i*2, i % 4);
box(50,20,80,50,1);
boxfill(54,24,76,46,2);
box1(50,80,80,110,2,1);
box2(50,140,80,170,3,1);
circle(65,240,50,1,1,3);
paint(65,240,2,3);
line(120,20,190,300,1);
line(190,20,120,300,2);
line(155,20,155,300,3);
}
pg3()
{
atsay(7,5,3,0, "The following screen will further");
atsay(8,5,3,0, "demonstrate the circle function");
atsay(9,5,3,0, "and introduce the rotated ellipse");
atsay(10,5,3,0, "function. The latter allows the");
atsay(11,5,3,0, "user to draw an ellipse with a");
atsay(12,5,3,0, "specified aspect and angle of");
atsay(13,5,3,0, "rotation.");
}
pg5()
{
turnright(150); /* Double Triangle */
pencolor(1);
forward(50);
delay(500);
turnright(120);
forward(50);
delay(500);
turnright(120);
forward(100);
delay(500);
turnleft(120);
forward(50);
delay(500);
turnleft(120);
forward(50);
turnright(180);
forward(50);
pencolor(0);
forward(50);
turnright(120);
pencolor(2);
delay(500);
forward(100);
turnright(60);
delay(500);
forward(100);
turnright(60);
delay(500);
forward(100);
turnright(60);
delay(500);
forward(100);
turnright(60);
delay(500);
forward(100);
turnright(60);
delay(500);
forward(97);
turnright(72);
forward(5);
pencolor(0);
forward(48);
turnright(96);
turnleft(72);
pencolor(3);
forward(90);
turnright(72);
forward(90);
turnright(72);
forward(90);
turnright(72);
forward(90);
turnright(73);
forward(90);
pencolor(0);
paint(90,160,3,1);
paint(110,160,3,1);
burble(100,200);
paint(40,160,2,3);
paint(182,160,1,2);
}
pg6()
{
palette(2,4,0);
house();
palette(0,5,0);
house();
palette(0,4,0);
palette(0,4,0);
house();
}
house()
{
for(i=0;i<=120;i++)
point(rand() / 165,rand() / 103, rand() / 8192);
line(180,0,180,319,1); /* grass line */
paint(183,10,1,1); /* grass */
line(150,50,120,110,1);
line(120,110,152,160,1);
line(140,70,180,70,1);
line(140,140,180,140,1);
line(180,70,180,140,1);
line(160,80,180,80,1);
line(160,95,180,95,1);
line(160,80,160,95,1);
line(150,110,170,110,1); /* Window */
line(150,120,170,120,1);
line(150,130,170,130,1);
line(150,110,150,130,1);
line(160,110,160,130,1);
line(170,110,170,130,1);
paint(155,115,2,1); /* color the widow panes */
paint(155,125,2,1);
paint(165,115,2,1);
paint(165,125,2,1);
paint(130,110,3,1); /* color the house */
line(130,100,130,120,2); /* lines in the house */
line(161,75,161,79,2);
line(155,86,155,97,2);
line(165,100,165,107,2);
line(161,72,161,78,2);
line(142,70,142,93,2);
line(147,100,147,116,2);
paint(170,90,2,1); /* color the door */
circle(170,90,2,1,1,1); /* knob */
paint(170,90,2,1); /* fill it */
line(114,124,128,124,2); /* chimney */
line(114,136,136,136,2);
line(114,124,114,136,2);
li