home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / borland / jnfb88.arc / LCV1N2.ARC / C-BAR.C next >
C/C++ Source or Header  |  1980-01-01  |  3KB  |  120 lines

  1. /* Figure 1b -- C Functions */    
  2.  
  3. #include "defs.h"  /* Hercules #defines */
  4.  
  5. /* Put a character and its attribute anywhere on the screen. */
  6.  
  7. void putc_at_location(char ch, int x, int y, unsigned char attrib)
  8. {
  9. _pokeb(SCREEN_BASE,((y * SCREEN_WIDTH) + x) * 2,ch);        
  10.  
  11.        /* SCREEN_BASE = Address of the video adapter card;
  12.           ((y * SCREEN_WIDTH) + X) * 2 = offset address */
  13.  
  14. _pokeb (SCREEN_BASE,(((y * SCREEN_WIDTH) + x) * 2) + 1, attrib);
  15.  
  16. }
  17.  
  18. /* Draw a bar. If height = 0, don't draw the bar, 
  19.    just go to the next. Use different characters for 
  20.    different bars up to a maximum of 10 bars. Add more
  21.    bars by adding more case statements. */
  22.  
  23. void draw_bar_0(int no,int start_x, int height, int width)
  24. {
  25.     int i,j,end_x,end_y,start_y;
  26.  
  27.     switch (height){
  28.       case 0 :
  29.         break;           
  30.       default:
  31.       end_x = start_x + width;
  32.           end_y = 22 - height;
  33.       start_y = 22;
  34.         for (j = start_x; j <= end_x; ++j)
  35.           for (i = end_y; i <= start_y; ++i)
  36.             switch (no){
  37.             case 0 :        
  38.                     putc_at_location(0xB1, j,i, 7);
  39.                   break;
  40.         case 1 :
  41.                   putc_at_location(0xB2, j,i, 7);
  42.                     break;
  43.             case 2 :
  44.                   putc_at_location(0xB0, j,i, 7);
  45.                break;
  46.         case 3 :
  47.                   putc_at_location(0xB1, j,i, 7);
  48.                break;
  49.         case 4 :
  50.                   putc_at_location(0xB2, j,i, 7);
  51.                break;
  52.             case 5 :
  53.                   putc_at_location(0xB0, j,i, 7);
  54.                break;
  55.         case 6 :
  56.                   putc_at_location(0xB2, j,i, 7);
  57.                     break;
  58.             case 7 :
  59.                   putc_at_location(0xB0, j,i, 7);
  60.                break;
  61.         case 8 :
  62.                    putc_at_location(0xB1, j,i, 7);
  63.                break;
  64.         case 9 :
  65.                   putc_at_location(0xB2, j,i, 7);
  66.                break;
  67.             case 10 :
  68.                   putc_at_location(0xB0, j,i, 7);
  69.                break;
  70.             }
  71.         }
  72. }
  73.  
  74. /* Draw an inverse video x/y axis. */
  75.  
  76. void draw_axis_0()
  77. {
  78.     int x,y;
  79.     y = 23;
  80.     for (x = 1; x <= 73; ++x)       /* from 1,23 to 1,73 */
  81.            putc_at_location(0xdb,x,y,7);
  82.         x = 1;
  83.     for (y = 3; y <= 23; ++y)       /* from 3,1, to 23,1 */
  84.            putc_at_location(0xdb,x,y,7);
  85. }
  86.  
  87. /* Clear the screen by writing blanks to every 
  88.    screen location. */
  89.  
  90. void clear_screen_0()
  91.  
  92. {
  93. unsigned int x,y;
  94.   for (y = 0; y <=25; ++y)
  95.     for (x = 0; x <=80; ++x)
  96.       putc_at_location(' ',x,y,7);
  97. }
  98.  
  99. /* Remove or restore the cursor by writing to the 
  100.     6845 CRT Controller. */
  101.  
  102. void remove_cursor_0()
  103.  
  104. {
  105.   _outportb(0x3b4,10);         /* 0x3b4 = PC I/O address register 
  106.                                of the 6845; 
  107.                                10 = 6845 register which 
  108.                                defines cursor start */
  109.   _outportb(0x3b5,20);       /* 20 = code to turn cursor off */
  110. }
  111.  
  112. void restore_cursor_0()
  113. {
  114.   _outportb(0x3b4,10);       /* 0x3b4 = PC I/O address register 
  115.                                 of the 6845;
  116.                                 10 = 6845 register which 
  117.                                 defines cursor start */
  118.   _outportb(0x3b5,(CURSOR)); /* CURSOR = cursor end */
  119. }
  120.