-/* ; FILE IDENTIFICATION
-;
-; Name: CRT_LINE.ASM
-; Purpose: Draw lines on screen using Bresenham's integer algorithm
-; Programmer: Kevin Rosenberg
-; Date Started: 1 Jun 84
-; Last Modification: 15 Jul 85, Version 1.0
-;
-; CORRESPONDENCE
-; Kevin Rosenberg
-; 2515 E. 16th St.
-; Newport Beach, CA 92663
-; (714) 642-0119 (voice)
-; (714) 842-6348 (E-Mail on Consultant's Exchange RBBS)
-; Compuserve 73775,1232
-;
-; LANGAUGE
-; IBM macro v1.000000000
-;
-; LANGAUGE INTERFACE
-; Public routines callable from Lattice C v2.0+
-; Works with S & L memory models. Can easily add support for the
-; other models by changing the STK structure below.
-;
-; NEEDED FILES
-; egadrive.inc Definitions, macros, & procedures for driving EGA
-; hidden.inc Defines OPTIONAL public procedure, crt_hdn_line().
-; dos.mac Lattice's file containing memory model macros
-; See inclusion statement for more documentation
-;
-; GRAPHIC MODES SUPPORTED
-; - Standard CGA modes -- BIOS codes 4, 5, & 6 -- are support through
-; the ROM BIOS pixel setting routine. Things could be speeded up
-; by a factor of 7-15 by writing to the video buffer directly.
-; - You may remove support for the CGA completely by changing the
-; EQU of STD_GRF to 0, a slight speed increase in EGA operations
-; is the gain.
-; - All EGA graphic modes are supported with optimized direct pixel
-; accessing. Note: mode 13 (320x200) is bugged, see LOG date 6-20-85
-;
-; LANGUAGE INTERFACE
-; Lattice C v2.0+
-;
-; HISTORY LOG
-; 7-15-85
-; Released in PD as version 1.0
-; 6-27-85
-; Put EGA routines in INCLUDE file EGADRIVE.INC
-; Put Hidden line routines in OPTIONAL INCLUDE file HIDDEN.INC
-; 6-20-85
-; Tested with video modes 13 (320x200) & 14 (640x200). Mode 14 worked
-; ok, mode 13 was missing every other vertical line: I'm probably
-; not setting one of the myriad of registers correctly. Since I'll
-; never use mode 13, I won't investigate it further.
-; 6-05-85
-; Added & updated documentation
-; 2-28-85
-; Added hidden line routines
-; PUBLIC crt_hdn_line plus internal routines
-; (see function summary for more info)
-; 1-20-85
-; Added global variable STD_GRF
-; Will support standard graphic modes if it is set to non-zero value;
-; however, the slow ROM BIOS is used as well as a slight overhead
-; for the EG code. IT IS MUCH FASTER TO USE THE EGA ENHANCED
-; (350 line) GRAPHIC MODES.
-; 1-09-85
-; Convert to support IBM's Enhanced graphics adapter.
-; Remove all optimized code for color graphics adapter (CGA)
-; 7-16-84
-; Changed calls to ROM that set pixels to speedy routines which use
-; incremental address calculation and direct writing the to graphics
-; buffer.
-; 1-12-84
-; File creation:
-; Converted C function, bresline.c, to assembly langauge.
-; Retained C source of Bresenham's integer rastering algorithm
-; as comments.
-;
-; FUNCTION SUMMARY
-;
-; crt_line_page (page)
-; Set graphics page to plot lines on [default = 0]
-;
-; crt_line_style (style)
-; Set line style [Default = solid line]
-;
-; crt_line (x1, y1, x2, y1, color)
-; Plots a line on the screen using Bresenham's integer algorithm
-;
-; crt_hdn_line (x1, y1, x2, y1, color, col_min, col_max)
-; OPTIONAL routine to plots lines using hidden areas
-; INCLUDE file HIDDEN.INC if you wish to use this routine
-;
-; crt_init_hdn (col_min, col_max)
-; Initializes vectors for use with crt_hdn_line()
-;
-;
-; int x1, y1 - starting point
-; int x2, y2 - end point
-; int color - color to draw line, as defined by IBM bios setting
-; int linestyle - 16 bit wide dot setting pattern
-; int col_min[640] Minimum values for each X column (initialize to 349)
-; int col_max[640] Maximum values for each X column (initialize to 0)
-; (Do not display any points between the min & max,
-; and update these values for each new min & max)
-; If a vector == NULL, then do not clip against that
-; boundary.
-;
-; REFERENCES FOR BRESENHAM'S ALGORITHM
-; Newman & Sproll, "Principals of Interactive Computer Graphics",
-; page 25.
-; Foley & van Dam, "Fundementals of Interactive Computer Graphics",
-; page 433
-*/
-
-;------ Bresenham variables
-
- deltx dw ?
- delty dw ?
- absdx dw ?
- absdy dw ?
- min_inc dw ? ; (-1, 1) indicates direction of minor axis
- dinc1 dw ? ; d increment if (d >= 0)
- dinc2 dw ? ; d increment if (d < 0)
-
-
-
-
-;------------------------------------------------------------------------------
-; PROCEDURE
-; crt_line [PUBLIC] Plot a line on the screen using Bresenham's alg
-;
-; SYNOPSIS
-; crt_line (x1, y1, x2, y2, color)
-
-void bresenham (int x1, int y1, int x2, int y2)
+/*****************************************************************************
+** This is part of the CTSim program
+** Copyright (c) 1983-2009 Kevin Rosenberg
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License (version 2) as
+** published by the Free Software Foundation.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+******************************************************************************/
+
+// REFERENCES FOR BRESENHAM'S ALGORITHM
+// Newman & Sproll, "Principals of Interactive Computer Graphics", page 25.
+// Foley & van Dam, "Fundementals of Interactive Computer Graphics", page 433
+
+
+static void
+bresx (int x, int y, int major_inc, int minor_inc, int count, int d,
+ int dinc1, int dinc2, void(*fn)(const int, const int))