/* gvline.c (emx+gcc) -- Copyright (c) 1987-1993 by Eberhard Mattes */

#include <stdlib.h>
#include <graph.h>
#define INCL_VIO
#include <os2emx.h>
#include "graph2.h"


void g_vline (int x, int y0, int y1,int color)
{
  int f, n;
  unsigned char *p;

  if (x >= _g_clipx0 && x <= _g_clipx1)
    {
      f = 1;
      if (y0 < _g_clipy0)
        {
          y0 = _g_clipy0; --f; 
        }
      if (y1 < _g_clipy0)
        {
          if (f == 0)
            return;
          y1 = _g_clipy0;
        }
      f = 1;
      if (y0 > _g_clipy1)
        {
          y0 = _g_clipy1; --f;
        }
      if (y1 > _g_clipy1)
        {
          if (f == 0)
            return;
          y1 = _g_clipy1;
        }
      if (y0 <= y1)
        n = y1 - y0 + 1;
      else
        {
          n = y0 - y1 + 1;
          y0 = y1;
        }
      GLOCK;
      p = _g_mem + x + 320 * y0;
      while (n > 0)
        {
          *p = (unsigned char)color;
          p += 320;
          --n;
        }
      GUNLOCK;
    }
}
