home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / c / csr20a.arc / CSRPROMO.C < prev    next >
Text File  |  1987-01-10  |  10KB  |  384 lines

  1. /*
  2. **  C S R P R O M O . C
  3. **
  4. **  Promotional program to demonstrate what the C Spot Run
  5. **  library does and how to use it. 
  6. **
  7. **  Uses the C Spot Run C Add-On Library and was compiled with
  8. **  Microsoft C V3.0.
  9. **
  10. **  The C Spot Run C Add-On Library is always available at
  11. **  the listed BBS, and the author may be contacted as below.
  12. **
  13. **    C Spot Run
  14. **    New Dimension Software
  15. **    23 Pawtucket Dr.
  16. **    Cherry Hill, NJ 08003
  17. **    Voice: (609) 424-2595
  18. **     Data: (609) 354-9259  300-2400B  24hrs  (FidoNet 107/414)
  19. **
  20. **  Copyright 1986, 1987 Bob Pritchett
  21. **
  22. **  History in reverse order:
  23. **
  24. **  01/10/87  Final modifications for version 2.0.
  25. **
  26. **  09/17/86  Changing some colors, testing multi color in a window.
  27. **
  28. **  08/18/86  Some more small modifications.
  29. **
  30. **  08/06/86  Small modifications to work with new version.
  31. **
  32. **  05/24/86  Created using version 1.0 and a few routines
  33. **            from the not yet released version 1.1.  (V1.1a)
  34. **
  35. */
  36.  
  37. #include <stdio.h>
  38. #include <color.h>
  39. #include <csrsound.h>
  40.  
  41. static char *menu[] =
  42.  {
  43.   "  General Information  ",
  44.   "      Window Demo      ",
  45.   "       Directory       ",
  46.   "    Other Functions    ",
  47.   "   Programming Tools   ",
  48.   "      Exit to DOS      "
  49.  };
  50.  
  51. static char *tools[] =
  52.  {
  53.   "    CheckC    ",
  54.   "     FLine    ",
  55.   " Header Files "
  56.  };
  57.  
  58. static char *logo[] =
  59.  {
  60.   "   CCCC",
  61.   "  CC  CC",
  62.   " CC",
  63.   " CC   S P O T   R U N",
  64.   " CC",
  65.   "  CC  CC",
  66.   "   CCCC"
  67.  };
  68.  
  69. main()
  70.  {
  71.   int w;
  72.   int x;
  73.   int i;
  74.   dma(0);
  75.   save_cursor();
  76.   save_screen();
  77.   cls();
  78.   wcolor(LGRY_F+BLU_B,BLU_B);
  79.   w = wopen(4,26,19,53,1);
  80.   wcenter(w,1,"Introducing");
  81.   for ( x = 0; x < 7; ++x )
  82.       wputat(w,3+x,2,logo[x]);
  83.   wcenter(w,11,"A User-Supported");
  84.   wcenter(w,12,"C Add-On Library");
  85.   wmessage(w,"[ Any Key ]",0);
  86.   sound(C,30);
  87.   sound(D,30);
  88.   sound(E,30);
  89.   sound(F,30);
  90.   sound(G,30);
  91.   sound(A,30);
  92.   sound(B,30);
  93.   getch();
  94.   wclose(w);
  95.   while ( 1 )
  96.    {
  97.     mcolor(BLK_F+RED_B,WHT_F+BLU_B);
  98.     color(RED_F+WHT_B);
  99.     x = pop_menu(9,27,6,menu," C Spot Run ",3);
  100.     if ( x == -1 )
  101.        break;
  102.     else if ( x == 5 )
  103.        break;
  104.     else if ( x == 4 )
  105.        utilities();
  106.     else if ( x == 3 )
  107.        other();
  108.     else if ( x == 2 )
  109.        directory();
  110.     else if ( x == 1 )
  111.        wndwdemo();
  112.     else if ( x == 0 )
  113.        info();
  114.    }
  115.   wcloseall();
  116.   restore_screen();
  117.   restore_cursor();
  118.   exit(0);
  119.  }
  120.  
  121. other()
  122.  {
  123.   int w;
  124.   int w1;
  125.   int h;
  126.   int m;
  127.   int s;
  128.   int hn;
  129.   int dy;
  130.   int mn;
  131.   int yr;
  132.   int n;
  133.   color(BLK_F+GRN_B);
  134.   w = wopen(10,10,20,70,1);
  135.   wtitle(w,"< Other Functions >",0);
  136.   wk(w);
  137.   wcenter(w,1,"Why not add some sound to life?");
  138.   for ( s = 25; s < 1000; s += 5 )
  139.       sound(s,40);
  140.   dosver(&m,&n);
  141.   wcenterf(w,2,"You are running V%d.%d of DOS.\n",m,n);
  142.   wcenter(w,4,"And there are many more functions handling");
  143.   wcenter(w,5,"time, data, DOS and BIOS calls.");
  144.   w1 = wopen(2,61,5,78,3);
  145.   while ( ! kbhit() )
  146.    {
  147.     get_date(&dy,&mn,&yr);
  148.     get_time(&h,&m,&s,&hn);
  149.     whome(w1);
  150.     wprintf(w1," Date: %02d/%02d/%d\n",mn,dy,(yr-1900));
  151.     wprintf(w1," Time: %02d:%02d:%02d",h,m,s);
  152.     gotoxy(30,0);            /* Cursor Goes Away */
  153.     for ( s = 0; s < 20000; ++s )
  154.         ;
  155.    }
  156.   getch();
  157.   wcloseall();
  158.  }
  159.  
  160. info()
  161.  {
  162.   int w;
  163.   color(BOLD+RED_F+BLK_B);
  164.   w = wopen(4,9,19,71,3);
  165.   wcenter(w,1,"C Spot Run");
  166.   wcenter(w,3,"Version 1.1a  Copyright 1986 Bob Pritchett");
  167.   whline(w,5);
  168.   wcenter(w,7,"C Spot Run is a collection of routines and programming");
  169.   wcenter(w,8,"utilities for C programmers.  The purpose of this");
  170.   wcenter(w,9,"library is to provide low cost tools for programmers");
  171.   wcenter(w,10,"under the user-supported distribution concept.");
  172.   wcenter(w,11,"For more information, contact the author at the following");
  173.   wcenter(w,12,"address, or consult the C Spot Run manual.");
  174.   wk(w);
  175.   getch();
  176.   wclose(w);
  177.   w = wopen(7,28,17,52,3);
  178.   wtitle(w,"< Address >",0);
  179.   wcenter(w,1,"C Spot Run");
  180.   wcenter(w,3,"Bob Pritchett");
  181.   wcenter(w,4,"23 Pawtucket Dr.");
  182.   wcenter(w,5,"Cherry Hill, NJ 08003");
  183.   wcenter(w,7,"FidoNet 107/414");
  184.   wk(w);
  185.   getch();
  186.   wclose(w);
  187.  }
  188.  
  189. wk(num)
  190.  int num;
  191.  {
  192.   wmessage(num,"[ Press a Key ]",0);
  193.  }
  194.  
  195. wndwdemo()
  196.  {
  197.   int w;
  198.   int w2;
  199.   int w3;
  200.   wcolor(WHT_F+BLK_B,BOLD+GRN_F);
  201.   w = wopen(1,5,22,75,177);
  202.   wtitle(w," Do you do windows?... ",1);
  203.   wk(w);
  204.   wcenter(w,1,"With the C Spot Run window functions library, you have");
  205.   wcenter(w,2,"access to one of the most powerful windowing packages");
  206.   wcenter(w,3,"available, and by far one of the best priced.");
  207.   wcenter(w,4,"-- It's Free!! --");
  208.   wcenter(w,5,"That's right.  The object code, libraries, and utilities");
  209.   wcenter(w,6,"included in this package are absolutely free, and you may");
  210.   wcenter(w,7,"use them for any non-commercial purpose as long as credit");
  211.   wcenter(w,8,"is given.  For use in commercial applications, or to");
  212.   wcenter(w,9,"obtain the surce code, check in the included manual");
  213.   wcenter(w,10,"and contact the author.");
  214.   wcenter(w,12,"Speaking of credit, I'd like to thank Phillip A. Mongelluzzo");
  215.   wcenter(w,13,"whose source code taught me many of the techniques in this");
  216.   wcenter(w,14,"library, and who answered many questions for me.");
  217.   wcenter(w,16,"What follows is a small demonstration of some of the routines");
  218.   wcenter(w,17,"in the library, and a short explanation of each.  For a");
  219.   wcenter(w,18,"complete description, please consult your manual.");
  220.   getch();
  221.   wclose(w);
  222.   wcolor(BOLD+CYN_F+WHT_B,MAG_F);
  223.   w = wopen(5,7,22,70,4);
  224.   wprint(w,"Title anywhere with wtitle()...\n");
  225.   getch();
  226.   wtitle(w,"[ Left ]",1);
  227.   wtitle(w,"< Right ]",2);
  228.   wtitle(w,"< Center a Message >",0);
  229.   getch();
  230.   wprint(w,"Send a message with wmessage()...\n");
  231.   getch();
  232.   wmessage(w," Here... ",1);
  233.   wmessage(w," ...or here. ",2);
  234.   wk(w);
  235.   getch();
  236.   wprint(w,"We can skip around...");
  237.   wscolor(w,RED_F+WHT_B,MAG_F);
  238.   wgotoxy(w,6,6);
  239.   wprint(w,"+ To here at 6,6 with wgotoxy()...");
  240.   getch();
  241.   wputat(w,7,4,"+ Or to 7,4 with wpuat()...");
  242.   getch();
  243.   wcenter(w,8,"Or center a line with wcenter().");
  244.   wgotoxy(w,10,0);
  245.   wprint(w,"Of course all output is done through an assembly routine,\n");
  246.   wprint(w,"just as cursor movement is...  We do stick with C for this:\n");
  247.   wprint(w,"(Go on, hit a key...)\n");
  248.   getch();
  249.   wjump(w,1,1);
  250.   getch();
  251.   wprint(w,"(Hit a key...)");
  252.   getch();
  253.   wprint(w,"\f The windows are all in a linked format, and can be moved\n");
  254.   wprint(w,"from fore to background easily.  Any call that involves a non\n");
  255.   wprint(w,"active window will activate that window before performing\n");
  256.   wprint(w,"it's action.  You may also close the windows in any order\n");
  257.   wprint(w,"you wish.\n");
  258.   wprint(w," The wactivate(window) function will activate the window\n");
  259.   wprint(w,"specified by window, and place it on 'top' of any overlapping\n");
  260.   wprint(w,"windows.\n");
  261.   getch();
  262.   color(YEL_F+RED_B);
  263.   w2 = wopen(5,5,20,35,2);
  264.   getch();
  265.   w3 = wopen(5,40,20,75,1);
  266.   getch();
  267.   whline(w2,2);
  268.   whline(w2,8);
  269.   wvline(w3,4);
  270.   wvline(w3,10);
  271.   wvline(w3,16);
  272.   wk(w2);
  273.   wk(w3);
  274.   getch();
  275.   wactivate(w);
  276.   getch();
  277.   wactivate(w2);
  278.   getch();
  279.   wactivate(w);
  280.   wactivate(w3);
  281.   getch();
  282.   wcloseall();
  283.   wcolor(WHT_F+BLU_B,CYN_F+WHT_B);
  284.   w = wopen(5,10,20,70,4);
  285.   wprint(w,"\tOf course there is a wprintf() function...\n");
  286.   getch();
  287.   for ( w2 = 0; w2 < 50; ++w2 )
  288.       wprintf(w,"Counting up...%03d.\n",w2);
  289.   wprintf(w,"Counting up...%03d.",w2);
  290.   getch();
  291.   wk();
  292.   wprint(w,"\nWe can even set the scrolling boundaries...\n");
  293.   getch();
  294.   wcls(w);
  295.   wcenter(w,0,"Freeze this line.");
  296.   wcenter(w,wrow(w),"Freeze this also.");
  297.   wfreeze(w,1,wrow(w)-1);
  298.   whome(w);
  299.   for ( w2 = 0; w2 < 50; ++w2 )
  300.       wprintf(w,"Counting up...%03d.\n",w2);
  301.   wprintf(w,"Counting up...%03d.",w2);
  302.   getch();
  303.   wclose(w);
  304.  }
  305.  
  306. utilities()
  307.  {
  308.   int x;
  309.   while ( 1 )
  310.    {
  311.     color(MAG_F+BLK_B);
  312.     mcolor(CYN_F,RED_F+WHT_B);
  313.     x = pop_menu(10,10,3,tools," Tools ",1);
  314.     if ( x == -1 )
  315.        return(-1);
  316.     else if ( x == 0 )
  317.        checkc();
  318.     else if ( x == 1 )
  319.        fline();
  320.     else if ( x == 2 )
  321.        headers();
  322.    }
  323.  }
  324.  
  325. checkc()
  326.  {
  327.   int w;
  328.   color(BOLD+MAG_F+BLK_B);
  329.   w = wopen(7,4,19,66,2);
  330.   wcenter(w,1,"CheckC");
  331.   whline(w,3);
  332.   wcenter(w,5,"CheckC is a small C code checker that checks for unmatched");
  333.   wcenter(w,6,"( ) { } [ ] \" \' in C source code.  Working with multiple");
  334.   wcenter(w,7,"files at once and correctly counting special cases, such");
  335.   wcenter(w,8,"as escape characters, makes this utility a valuable");
  336.   wcenter(w,9,"addition to your C debugging tools.");
  337.   wk(w);
  338.   getch();
  339.   wclose(w);
  340.  }
  341.  
  342. fline()
  343.  {
  344.   int w;
  345.   color(BOLD+GRN_F+BLK_B);
  346.   w = wopen(7,6,19,74,2);
  347.   wcenter(w,1,"FLine");
  348.   whline(w,3);
  349.   wcenter(w,5,"FLine is a small utility that scans source code and places");
  350.   wcenter(w,6,"and lines begining with a non-whitespace character into the");
  351.   wcenter(w,7,"output file specified on the command line.  This provides");
  352.   wcenter(w,8,"a useful reference file containing all function declerations,");
  353.   wcenter(w,9,"preproccessor statements, global variables, and comments.");
  354.   wk(w);
  355.   getch();
  356.   wclose(w);
  357.  }
  358.  
  359. headers()
  360.  {
  361.   int w;
  362.   color(BOLD+RED_F+BLK_B);
  363.   w = wopen(5,7,16,76,2);
  364.   wcenter(w,1,"Header Files");
  365.   whline(w,3);
  366.   wcenter(w,5,"The C Spot Run library contains a number of header files");
  367.   wcenter(w,6,"designed to make programming easier.  Color, special keys,");
  368.   wcenter(w,7,"sound, and character codes are all covered in the different");
  369.   wcenter(w,8,"header files included here.");
  370.   wk(w);
  371.   getch();
  372.   wclose(w);
  373.  }
  374.  
  375. directory()
  376.  {
  377.   color(WHT_F+RED_B);
  378.   if ( num_drives() < 3 )
  379.      dirwin("A:","*.*");
  380.   else
  381.      dirwin("C:","*.*");
  382.  }
  383.  
  384.