home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / msysjour / vol03 / 05 / msctsr / tsrbios.c < prev    next >
Text File  |  1988-08-31  |  2KB  |  65 lines

  1.  
  2. /* Figure 5. Simple video BIOS routines. */
  3.  
  4.    /*
  5.     * a couple of BIOS routines for tsrs
  6.     */
  7.    #include "tsrbios.h"
  8.    #include <dos.h>
  9.  
  10.    #define BIOS_VIDEOINT 0x10
  11.    #define BIOS_VIDEOINT_RDCH 0x8
  12.    #define BIOS_VIDEOINT_WRCH 0x9
  13.    #define BIOS_CURSOR_ARRAY (int far *)(0x450)
  14.    #define BIOS_VIDEO_PAGE_NUM (char far *)(0x462)
  15.  
  16.    union REGS regs;
  17.  
  18.    scr_swapmsg(msg, savbuf, row, col)
  19.    unsigned char *msg, *savbuf;
  20.    {
  21.          unsigned val;
  22.  
  23.          while(*msg) {
  24.                *savbuf++ = val = scr_read_ch(row, col);
  25.                val &= 0xff00;    /* preserve attribute */
  26.                val |= *msg++;
  27.                scr_write_ch(val, row, col++);
  28.          }
  29.          *savbuf = 0;
  30.    }
  31.  
  32.    unsigned scr_read_ch(row, col)
  33.    int row, col;
  34.    {
  35.          /* poke cursor val into bios loc */
  36.          *scr_get_curs_addr() = row<<8 | col;
  37.  
  38.          /* use bios int to get char */
  39.          regs.h.ah = BIOS_VIDEOINT_RDCH;
  40.          regs.h.bh = *BIOS_VIDEO_PAGE_NUM;
  41.          int86(BIOS_VIDEOINT, ®s, ®s);
  42.          return regs.x.ax;
  43.    }
  44.  
  45.    void scr_write_ch(ch, row, col)
  46.    unsigned ch;
  47.    int row, col;
  48.    {
  49.          /* poke cursor val into bios loc */
  50.          *scr_get_curs_addr() = row<<8 | col;
  51.  
  52.          /* use bios int to get char */
  53.          regs.h.ah = BIOS_VIDEOINT_WRCH;
  54.          regs.h.al = ch;   /* char */
  55.          regs.x.cx = 1;    /* one char */
  56.          regs.h.bh = *BIOS_VIDEO_PAGE_NUM;
  57.          regs.h.bl = ch>>8;      /* attr */
  58.          int86(BIOS_VIDEOINT, ®s, ®s);
  59.    }
  60.  
  61.    int far * scr_get_curs_addr()
  62.    {
  63.          return BIOS_CURSOR_ARRAY + (int)(*BIOS_VIDEO_PAGE_NUM);
  64.    }
  65.