home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / dm14.lzh / screen.c < prev    next >
Text File  |  1996-07-07  |  3KB  |  158 lines

  1. /* screen.c screen functions for DISKMASTER.C */
  2. /* copyright (c) 1995 by Bob Devries          */
  3. /* email: bdevries@gil.ipswichcity.qld.gov.au */
  4.  
  5. #include <stdio.h>
  6. #include "screen.h"
  7.  
  8. clearscreen()
  9. {
  10.        printf("%c[2J",ESC);
  11. }
  12.  
  13. clearwin(xcoord,ycoord,xlen,ylen)
  14. int xcoord;
  15. int ycoord;
  16. int xlen;
  17. int ylen;
  18. {
  19.        register int y;    /* make this 'register' for more speed!! */
  20.        register int y_end;
  21.     
  22.        char *clr_lin, *string_str(), *malloc();
  23.        
  24.        clr_lin = malloc(xlen+1);
  25.        string_str(clr_lin, xlen, ' ');    /* moved to here, bvdp */
  26.        y_end=ycoord+ylen;
  27.  
  28. /*       gotoxy(xcoord,ycoord); */ /* redundant gotoxy() */
  29.        for(y = ycoord;y < y_end; y++) {
  30.               gotoxy(xcoord,y);
  31.               printf("%s", clr_lin);
  32.        }
  33.        free(clr_lin);
  34. }
  35.  
  36. char *string_str(Str, len, chr)
  37. char *Str;
  38. int len;
  39. char chr;
  40. {
  41.     char *string = Str;
  42.     while (len--) {
  43.         *(string++) = chr;
  44.     }
  45.     *string = '\0';
  46.     return(Str);
  47. }
  48.  
  49. gotoxy(xcoord,ycoord)
  50. int xcoord;
  51. int ycoord;
  52. {
  53.        printf("%c[%d;%dH",ESC,ycoord,xcoord);
  54. }
  55.  
  56. horiz_doub(xcoord,ycoord,length)
  57. int xcoord;
  58. int ycoord;
  59. int length;
  60. {
  61.        int x;
  62.        gotoxy(xcoord,ycoord);
  63.        for(x=0;x<length;x++)
  64.                putc(DHORZ_BAR,stdout);
  65. }
  66.  
  67. vert_doub(xcoord,ycoord,length)
  68. int xcoord;
  69. int ycoord;
  70. int length;
  71. {
  72.        int x;
  73.        for(x=0;x<length;x++) {
  74.               gotoxy(xcoord,ycoord+x);
  75.               putc(DVERT_BAR,stdout);
  76.        }
  77. }
  78.  
  79. corner(xcoord,ycoord,which)
  80. int xcoord;
  81. int ycoord;
  82. int which;
  83. {
  84.        gotoxy(xcoord,ycoord);
  85.        switch(which) {
  86.               case TL: putc(DTOP_LEFT,stdout); break;
  87.               case TR: putc(DTOP_RITE,stdout); break;
  88.               case BL: putc(DBOT_LEFT,stdout); break;
  89.               case BR: putc(DBOT_RITE,stdout); break;
  90.        }
  91. }
  92.  
  93. box_doub(xcoord,ycoord,xlen,ylen)
  94. int xcoord;
  95. int ycoord;
  96. int xlen;
  97. int ylen;
  98. {
  99.        corner(xcoord,ycoord,TL);
  100.        horiz_doub(xcoord+1,ycoord,xlen-2);
  101.        corner(xcoord+xlen-1,ycoord,TR);
  102.        vert_doub(xcoord,ycoord+1,ylen-2);
  103.        vert_doub(xcoord+xlen-1,ycoord+1,ylen-2);
  104.        corner(xcoord,ycoord+ylen-1,BL);
  105.        horiz_doub(xcoord+1,ycoord+ylen-1,xlen-2);
  106.        corner(xcoord+xlen-1,ycoord+ylen-1,BR);
  107. }
  108.  
  109. foreground(colour)     /* colours are 0-7 */
  110. int colour;
  111. {
  112. #ifdef MM1
  113.        FColor(1,colour);
  114. #else
  115.        colour += 0x30;
  116.        printf("%c[3%cm",ESC,colour);
  117. #endif
  118. }
  119.  
  120. background(colour)     /* colours are 0-7 */
  121. int colour;
  122. {
  123. #ifdef MM1
  124.        BColor(1,colour);
  125. #else
  126.        colour += 0x30;
  127.        printf("%c[4%cm",ESC,colour);
  128. #endif
  129. }
  130.  
  131. cleol()
  132. {
  133.        printf("%c[K",ESC);
  134. }
  135.  
  136. #ifdef MM1
  137.  
  138. SetPalette()
  139. {
  140.        Palette(1,0,0,0,0);         /* BLACK */
  141.        Palette(1,1,255,0,0);       /* RED */
  142.        Palette(1,2,0,255,0);       /* GREEN */
  143.        Palette(1,3,255,255,0);     /* YELLOW */
  144.        Palette(1,4,0,0,255);       /* BLUE */
  145.        Palette(1,5,255,0,255);     /* MAGENTA */
  146.        Palette(1,6,0,255,255);     /* CYAN */
  147.        Palette(1,7,255,255,255);   /* WHITE */
  148. }
  149.  
  150. RestPalette()
  151. {
  152.        DefColr(1);
  153. }
  154.  
  155. #endif
  156.  
  157. /* EOF screen.c */
  158.