/* ghline.c (emx+gcc) -- Copyright (c) 1987-1993 by Eberhard Mattes */

#include <stdlib.h>
#include <memory.h>
#include <graph.h>
#define INCL_VIO
#include <os2emx.h>
#include "graph2.h"

void g_hline (int y, int x0, int x1, int color)
{
  int f, n;

  if (y >= _g_clipy0 && y <= _g_clipy1)
    {
      f = 1;
      if (x0 < _g_clipx0)
        {
          x0 = _g_clipx0; --f; 
        }
      if (x1 < _g_clipx0)
        {
          if (f == 0)
            return;
          x1 = _g_clipx0;
        }
      f = 1;
      if (x0 > _g_clipx1)
        {
          x0 = _g_clipx1; --f;
        }
      if (x1 > _g_clipx1)
        {
          if (f == 0)
            return;
          x1 = _g_clipx1;
        }
      if (x0 <= x1)
        n = x1 - x0 + 1;
      else
        {
          n = x0 - x1 + 1;
          x0 = x1;
        }
      GLOCK;
      memset (_g_mem + y * 320 + x0, color, n);
      GUNLOCK;
    }
}
