home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / sys / hp300 / stand / ite_subr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-05  |  4.1 KB  |  131 lines

  1. /*
  2.  * Copyright (c) 1988 University of Utah.
  3.  * Copyright (c) 1990 The Regents of the University of California.
  4.  * All rights reserved.
  5.  *
  6.  * This code is derived from software contributed to Berkeley by
  7.  * the Systems Programming Group of the University of Utah Computer
  8.  * Science Department.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  * 3. All advertising materials mentioning features or use of this software
  19.  *    must display the following acknowledgement:
  20.  *    This product includes software developed by the University of
  21.  *    California, Berkeley and its contributors.
  22.  * 4. Neither the name of the University nor the names of its contributors
  23.  *    may be used to endorse or promote products derived from this software
  24.  *    without specific prior written permission.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36.  * SUCH DAMAGE.
  37.  *
  38.  * from: Utah $Hdr: ite_subr.c 1.1 89/02/17$
  39.  *
  40.  *    @(#)ite_subr.c    7.2 (Berkeley) 12/16/90
  41.  */
  42.  
  43. #include "samachdep.h"
  44.  
  45. #ifdef ITECONSOLE
  46.  
  47. #include "sys/param.h"
  48. #include "../dev/itevar.h"
  49. #include "../dev/itereg.h"
  50.  
  51. ite_devinfo(ip)
  52.     struct ite_softc *ip;
  53. {
  54.     struct fontinfo *fi;
  55.     struct font *fd;
  56.  
  57.     fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
  58.     fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
  59.  
  60.     ip->ftheight = fd->fh;
  61.     ip->ftwidth  = fd->fw;
  62.     ip->fbwidth  = ITEREGS->fbwidth_h << 8 | ITEREGS->fbwidth_l;
  63.     ip->fbheight = ITEREGS->fbheight_h << 8 | ITEREGS->fbheight_l;
  64.     ip->dwidth   = ITEREGS->dispwidth_h << 8 | ITEREGS->dispwidth_l;
  65.     ip->dheight  = ITEREGS->dispheight_h << 8 | ITEREGS->dispheight_l;
  66.     ip->rows     = ip->dheight / ip->ftheight;
  67.     ip->cols     = ip->dwidth / ip->ftwidth;
  68.  
  69.     if (ip->fbwidth > ip->dwidth) {
  70.         /*
  71.          * Stuff goes to right of display.
  72.          */
  73.         ip->fontx    = ip->dwidth;
  74.         ip->fonty    = 0;
  75.         ip->cpl      = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
  76.         ip->cblankx  = ip->dwidth;
  77.         ip->cblanky  = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
  78.     }
  79.     else {
  80.         /*
  81.          * Stuff goes below the display.
  82.          */
  83.         ip->fontx   = 0;
  84.         ip->fonty   = ip->dheight;
  85.         ip->cpl     = ip->fbwidth / ip->ftwidth;
  86.         ip->cblankx = 0;
  87.         ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
  88.     }
  89. }
  90.  
  91. ite_fontinit(ip)
  92.     register struct ite_softc *ip;
  93. {
  94.     struct fontinfo *fi;
  95.     struct font *fd;
  96.     register u_char *fbmem, *dp;
  97.     register int bn;
  98.     int c, l, b;
  99.  
  100.     fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
  101.     fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
  102.  
  103.     dp = fd->data;
  104.  
  105.     for (c = 0; c < 128; c++) {
  106.         fbmem = (u_char *) FBBASE +
  107.             (ip->fonty + (c / ip->cpl) * ip->ftheight) *
  108.             ip->fbwidth;
  109.         fbmem += ip->fontx + (c % ip->cpl) * ip->ftwidth;
  110.         for (l = 0; l < ip->ftheight; l++) {
  111.             bn = 7;
  112.             for (b = 0; b < ip->ftwidth; b++) {
  113.                 if ((1 << bn) & *dp)
  114.                     *fbmem++ = 1;
  115.                 else
  116.                     *fbmem++ = 0;
  117.                 if (--bn < 0) {
  118.                     bn = 7;
  119.                     dp += 2;
  120.                 }
  121.             }
  122.             if (bn < 7)
  123.                 dp += 2;
  124.             fbmem -= ip->ftwidth;
  125.             fbmem += ip->fbwidth;
  126.         }
  127.     }
  128.  
  129. }
  130. #endif
  131.