#include "vid.h"

#define  FALSE  0

#define  UL     0
#define  UR     1
#define  LL     2
#define  LR     3
#define  HOR    4
#define  VERT   5
#define  BLNK   6

VIDMEM vputn();

vputbox(row, col, width, height, attr, battr, retrace, frame)
int   row, col, width, height, attr, battr, retrace, *frame;
{
   register int    c;
   VIDMEM scr_ofs, vstart;
   int    iwid, iht, i;

   iwid = width -2;
   iht  = height -2;

   if (vidmode() == 7)
   {
      vstart = MGAMEM + (row * 80);
      retrace = FALSE;
   }
   else
      vstart = CGAMEM+(row * 80);

   scr_ofs = vstart + col;
   c = battr <<8 | frame[UL];
   vput(scr_ofs++, c, retrace);

   c = battr <<8 | frame[HOR];
   scr_ofs = vputn(scr_ofs, c, iwid, retrace);

   c = battr <<8 | frame[UR];
   vput(scr_ofs, c, retrace);

   i = iht;
   while (i)
   {
      vstart += 80;
      scr_ofs = vstart + col;

      c = battr <<8 | frame[VERT];
      vput(scr_ofs++, c, retrace);

      c = attr <<8 | frame[BLNK];
      scr_ofs = vputn(scr_ofs, c, iwid, retrace);

      c = battr <<8 | frame[VERT];
      vput(scr_ofs, c, retrace);
      i--;
   }
   vstart += 80;
   scr_ofs = vstart + col;
   c = battr <<8 | frame[LL];
   vput(scr_ofs++, c, retrace);

   c = battr <<8 | frame[HOR];
   scr_ofs = vputn(scr_ofs, c, iwid, retrace);

   c = battr <<8 | frame[LR];
   vput(scr_ofs, c, retrace);
}
