home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / screen / 96col.arc / 96COL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-06  |  12.2 KB  |  311 lines

  1. /****************************************************************************
  2.  
  3.                               96 COLUMN WRITER
  4.  
  5.         This program is written in Microsoft C, version 3 or higher and
  6.         is designed to allow the writing of up to 96 characters on the
  7.         graphics screen of the IBM PC. 
  8.  
  9.         It uses the font already found in the IBM PC or compatible and uses
  10.         it to write the characters on the display.
  11.  
  12.         This program takes characters as entered from the keyboard and
  13.         displays them onto the screen in 96 column format.
  14.  
  15.         This routine may be made resident and used to replace the BIOS
  16.         INT10H TTY handler used by DOS when outputing data.
  17.  
  18.         The program can be adapted to other compilers by watching the
  19.         following points:
  20.  
  21.         The peekpv and pokepv routines will have to be changed as the
  22.                 Microsoft C Compiler allows far pointers (32 bits) and
  23.  
  24.         the font should be changed to a single font versus the IBM FAT font
  25.                 as the characters use double vertical lines so that they
  26.                 look nicer and
  27.  
  28.         the address of the IBM font which is at F000:FA6E should be checked
  29.                 to ensure it coincides with your system.
  30.  
  31. *******************************************************************************
  32.  
  33.         This program uses the shareware concept. If you find it useful, or if 
  34. you incorporate it in other programs, please ensure that the originating author 
  35. is acknowledged. You may also want to contribute $10 for this routine.
  36.  
  37. ******************************************************************************* 
  38.  
  39.         Peter P. Vekinis, 119 N. Harvard, Arlington Heights, IL 60004, USA
  40.  
  41. ******************************************************************************* 
  42.  
  43.         Copyright (C) 1986, 1987, 1988, 1989 Peter Vekinis
  44.  
  45. ******************************************************************************/
  46.  
  47. #define ERROR -1
  48. #define O_BINARY 0x8000
  49. #include <dos.h>
  50.  
  51. main()
  52. {
  53.         register i,j;
  54.         char *msg="Hello, this is 96 column mode. As you can see we can fit more than 80 columns in one line on the screen.";
  55.  
  56.         pcvsvm(6);              /* sets the video mode to high res graphics */
  57.  
  58.         read_font();            /* reads the font already dumped */
  59.  
  60.         for(i=0; *(msg+i) != 0; i++)
  61.                 shochat96(10,0+i,*(msg+i),0);
  62. }
  63.  
  64.  
  65. char norm_pt[2048];             /* the font area */
  66.  
  67. read_font()                     /* Copy font from ROM */
  68. {
  69.         register i;
  70.  
  71.         for(i=0; i<= 1024; i++)
  72.                 *(norm_pt+i)=(peekpv(0xf000,0xfa6e+i));
  73.  
  74. }
  75.  
  76.  
  77. shochat96(row,col,chr,atr)
  78. int row, col;
  79. char chr, atr;
  80. {
  81.         int i,j,chrloc, grow;
  82.         register col1, col2;
  83.         unsigned char k, k1;
  84.  
  85.         col1=(col * 6) / 8;
  86.         col2=(col * 6) % 8;
  87.         chrloc=chr << 3;
  88.         grow=(row * 320) + col1;
  89.  
  90.  
  91.         if(col2 == 0)
  92.         {
  93.                 k=peekpv(0xb800,grow);
  94.                 poken(0xb800,grow,(k & 0x03) | ((*(norm_pt+chrloc) & 0xfc)));
  95.                 k=peekpv(0xb800,grow+8192);
  96.                 poken(0xb800,grow+8192,(k & 0x03) | ((*(norm_pt+chrloc+1) & 
  97.                                 0xfc) ));
  98.                 k=peekpv(0xb800,grow+80);
  99.                 poken(0xb800,grow+80,(k & 0x03) | ((*(norm_pt+chrloc+2) & 
  100.                                 0xfc)));
  101.                 k=peekpv(0xb800,grow+8192+80);
  102.                 poken(0xb800,grow+8192+80,(k & 0x03) | ((*(norm_pt+chrloc+3) & 
  103.                                 0xfc)));
  104.                 k=peekpv(0xb800,grow+160);
  105.                 poken(0xb800,grow+160,(k & 0x03) | ((*(norm_pt+chrloc+4) & 
  106.                                 0xfc) ));
  107.                 k=peekpv(0xb800,grow+160+8192);
  108.                 poken(0xb800,grow+160+8192,(k & 0x03) | ((*(norm_pt+chrloc+5) &
  109.                                 0xfc)));
  110.                 k=peekpv(0xb800,grow+240);
  111.                 poken(0xb800,grow+240,(k & 0x03) | ((*(norm_pt+chrloc+6) & 
  112.                                 0xfc) ));
  113.                 k=peekpv(0xb800,grow+240+8192);
  114.                 poken(0xb800,grow+240+8192,(k & 0x03) | ((*(norm_pt+chrloc+7) & 
  115.                                 0xfc)));
  116.         }
  117.         else
  118.         if(col2 == 2)
  119.         {
  120.                 k=peekpv(0xb800,grow);
  121.                 poken(0xb800,grow,(k & 0xc0) | ((*(norm_pt+chrloc) & 0xfc) >> 
  122.                                 2));
  123.                 k=peekpv(0xb800,grow+8192);
  124.                 poken(0xb800,grow+8192,(k & 0xc0) | ((*(norm_pt+chrloc+1) & 
  125.                                 0xfc) >> 2));
  126.                 k=peekpv(0xb800,grow+80);
  127.                 poken(0xb800,grow+80,(k & 0xc0) | ((*(norm_pt+chrloc+2) & 
  128.                                 0xfc) >> 2));
  129.                 k=peekpv(0xb800,grow+8192+80);
  130.                 poken(0xb800,grow+8192+80,(k & 0xc0) | ((*(norm_pt+chrloc+3) & 
  131.                                 0xfc) >> 2));
  132.                 k=peekpv(0xb800,grow+160);
  133.                 poken(0xb800,grow+160,(k & 0xc0) | ((*(norm_pt+chrloc+4) & 
  134.                                 0xfc) >> 2));
  135.                 k=peekpv(0xb800,grow+160+8192);
  136.                 poken(0xb800,grow+160+8192,(k & 0xc0) | ((*(norm_pt+chrloc+5) &
  137.                                 0xfc) >> 2));
  138.                 k=peekpv(0xb800,grow+240);
  139.                 poken(0xb800,grow+240,(k & 0xc0) | ((*(norm_pt+chrloc+6) & 
  140.                                 0xfc) >> 2));
  141.                 k=peekpv(0xb800,grow+240+8192);
  142.                 poken(0xb800,grow+240+8192,(k & 0xc0) | ((*(norm_pt+chrloc+7) &
  143.                                 0xfc) >> 2));
  144.         }
  145.         else
  146.         if(col2 == 4)
  147.         {
  148.                 k=peekpv(0xb800,grow);
  149.                 poken(0xb800,grow,(k & 0xf0) | ((*(norm_pt+chrloc) & 0xf0) >> 
  150.                                 4));
  151.                 k=peekpv(0xb800,grow+1);
  152.                 poken(0xb800,grow+1,(k & 0x3f) | ((*(norm_pt+chrloc) & 0x0c) <<
  153.                                 4));
  154.                 k=peekpv(0xb800,grow+8192);
  155.                 poken(0xb800,grow+8192,(k & 0xf0) | ((*(norm_pt+chrloc+1) & 
  156.                                 0xf0) >> 4));
  157.                 k=peekpv(0xb800,grow+1+8192);
  158.                 poken(0xb800,grow+1+8192,(k & 0x3f) | ((*(norm_pt+chrloc+1) & 
  159.                                 0x0c) << 4));
  160.                 k=peekpv(0xb800,grow+80);
  161.                 poken(0xb800,grow+80,(k & 0xf0) | ((*(norm_pt+chrloc+2) & 
  162.                                 0xf0) >> 4));
  163.                 k=peekpv(0xb800,grow+1+80);
  164.                 poken(0xb800,grow+1+80,(k & 0x3f) | ((*(norm_pt+chrloc+2) & 
  165.                                 0x0c) << 4));
  166.                 k=peekpv(0xb800,grow+8192+80);
  167.                 poken(0xb800,grow+8192+80,(k & 0xf0) | ((*(norm_pt+chrloc+3) & 
  168.                                 0xf0) >> 4));
  169.                 k=peekpv(0xb800,grow+1+8192+80);
  170.                 poken(0xb800,grow+1+8192+80,(k & 0x3f) | ((*(norm_pt+chrloc+3) &
  171.                                 0x0c) << 4));
  172.                 k=peekpv(0xb800,grow+160);
  173.                 poken(0xb800,grow+160,(k & 0xf0) | ((*(norm_pt+chrloc+4) & 
  174.                                 0xf0) >> 4));
  175.                 k=peekpv(0xb800,grow+1+160);
  176.                 poken(0xb800,grow+1+160,(k & 0x3f) | ((*(norm_pt+chrloc+4) & 
  177.                                 0x0c) << 4));
  178.                 k=peekpv(0xb800,grow+160+8192);
  179.                 poken(0xb800,grow+160+8192,(k & 0xf0) | ((*(norm_pt+chrloc+5) & 
  180.                                 0xf0) >> 4));
  181.                 k=peekpv(0xb800,grow+1+160+8192);
  182.                 poken(0xb800,grow+1+160+8192,(k & 0x3f) | ((*(norm_pt+chrloc+5)
  183.                                 & 0x0c) << 4));
  184.                 k=peekpv(0xb800,grow+240);
  185.                 poken(0xb800,grow+240,(k & 0xf0) | ((*(norm_pt+chrloc+6) & 
  186.                                 0xf0) >> 4));
  187.                 k=peekpv(0xb800,grow+1+240);
  188.                 poken(0xb800,grow+1+240,(k & 0x3f) | ((*(norm_pt+chrloc+6) & 
  189.                                 0x0c) << 4));
  190.                 k=peekpv(0xb800,grow+8192+240);
  191.                 poken(0xb800,grow+8192+240,(k & 0xf0) | ((*(norm_pt+chrloc+7) &
  192.                                 0xf0) >> 4));
  193.                 k=peekpv(0xb800,grow+1+8192+240);
  194.                 poken(0xb800,grow+1+8192+240,(k & 0x3f) | ((*(norm_pt+chrloc+7)
  195.                                 & 0x0c) << 4));
  196.         }
  197.         else
  198.         if(col2 == 6)
  199.         {
  200.                 k=peekpv(0xb800,grow);
  201.                 poken(0xb800,grow,(k & 0xfc) | ((*(norm_pt+chrloc) & 0xc0) >> 
  202.                                 6));
  203.                 k=peekpv(0xb800,grow+1);
  204.                 poken(0xb800,grow+1,(k & 0x0f) | ((*(norm_pt+chrloc) & 0x3c) <<
  205.                                 2));
  206.                 k=peekpv(0xb800,grow+8192);
  207.                 poken(0xb800,grow+8192,(k & 0xfc) | ((*(norm_pt+chrloc+1) & 
  208.                                 0xc0) >> 6));
  209.                 k=peekpv(0xb800,grow+1+8192);
  210.                 poken(0xb800,grow+1+8192,(k & 0x0f) | ((*(norm_pt+chrloc+1) & 
  211.                                 0x3c) << 2));
  212.                 k=peekpv(0xb800,grow+80);
  213.                 poken(0xb800,grow+80,(k & 0xfc) | ((*(norm_pt+chrloc+2) & 
  214.                                 0xc0) >> 6));
  215.                 k=peekpv(0xb800,grow+1+80);
  216.                 poken(0xb800,grow+1+80,(k & 0x0f) | ((*(norm_pt+chrloc+2) & 
  217.                                 0x3c) << 2 ));
  218.                 k=peekpv(0xb800,grow+8192+80);
  219.                 poken(0xb800,grow+8192+80,(k & 0xfc) | ((*(norm_pt+chrloc+3) & 
  220.                              0xc0) >> 6));
  221.                 k=peekpv(0xb800,grow+1+8192+80);
  222.                 poken(0xb800,grow+1+8192+80,(k & 0x0f) | ((*(norm_pt+chrloc+3) 
  223.                              & 0x3c) << 2));
  224.                 k=peekpv(0xb800,grow+160);
  225.                 poken(0xb800,grow+160,(k & 0xfc) | ((*(norm_pt+chrloc+4) & 
  226.                              0xc0) >> 6));
  227.                 k=peekpv(0xb800,grow+1+160);
  228.                 poken(0xb800,grow+1+160,(k & 0x0f) | ((*(norm_pt+chrloc+4) & 
  229.                              0x3c) << 2));
  230.                 k=peekpv(0xb800,grow+160+8192);
  231.                 poken(0xb800,grow+160+8192,(k & 0xfc) | ((*(norm_pt+chrloc+5) &
  232.                              0xc0) >> 6));
  233.                 k=peekpv(0xb800,grow+1+160+8192);
  234.                 poken(0xb800,grow+1+160+8192,(k & 0x0f) | ((*(norm_pt+chrloc+5)
  235.                              & 0x3c) << 2));
  236.                 k=peekpv(0xb800,grow+240);
  237.                 poken(0xb800,grow+240,(k & 0xfc) | ((*(norm_pt+chrloc+6) & 
  238.                              0xc0) >> 6));
  239.                 k=peekpv(0xb800,grow+1+240);
  240.                 poken(0xb800,grow+1+240,(k & 0x0f) | ((*(norm_pt+chrloc+6) & 
  241.                              0x3c) << 2));
  242.                 k=peekpv(0xb800,grow+8192+240);
  243.                 poken(0xb800,grow+8192+240,(k & 0xfc) | ((*(norm_pt+chrloc+7) &
  244.                              0xc0) >> 6));
  245.                 k=peekpv(0xb800,grow+1+8192+240);
  246.                 poken(0xb800,grow+1+8192+240,(k & 0x0f) | ((*(norm_pt+chrloc+7)
  247.                              & 0x3c) << 2));
  248.         }
  249. }
  250.  
  251.  
  252. /******************************************************************
  253.  
  254.         The Peek byte function
  255.  
  256. *******************************************************************/
  257.  
  258. peekpv(seg,off)
  259. unsigned seg, off;
  260. {
  261.         unsigned long seg1, off1;
  262.         char k;
  263.         char far *screen;
  264.  
  265.         seg1=seg;
  266.         off1=off;
  267.         screen =((seg1 << 16) | off1);
  268.         k=*(screen);
  269.         return k;
  270. }
  271.  
  272. /*******************************************************************
  273.  
  274.         The poke byte function
  275.  
  276. ********************************************************************/
  277. poken(seg,off,byte)
  278. unsigned seg, off;
  279. char byte;
  280. {
  281.         long seg1, off1;
  282.         char far *screen;
  283.         seg1=seg;
  284.         off1=off;
  285.  
  286.         screen =((seg1 << 16) | off1);
  287.         *screen=byte;
  288. }
  289.  
  290. /*******************************************************************
  291.  
  292.         The setvideo mode
  293.  
  294. ********************************************************************/
  295. pcvsvm(mode)
  296. char mode;
  297. {
  298. union REGS regs;
  299.  
  300.         regs.h.ah=0;
  301.         regs.h.al=mode;
  302.         int86(0x10,®s,®s);
  303. }
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.