From decwrl!elroy.jpl.nasa.gov!usc!cs.utexas.edu!uunet!allbery Sun Mar 25 18:43:34 PST 1990
Article 1452 of comp.sources.misc:
Path: decwrl!elroy.jpl.nasa.gov!usc!cs.utexas.edu!uunet!allbery
From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
Newsgroups: comp.sources.misc
Subject: v11i077: Gnuplot 2.0 - 12 of 14
Message-ID: <82372@uunet.UU.NET>
Date: 26 Mar 90 00:13:19 GMT
Sender: allbery@uunet.UU.NET
Organization: Pixar -- Marin County, California
Lines: 1195
Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)

Posting-number: Volume 11, Issue 77
Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
Archive-name: gnuplot2/part12

This is gnuplot.sh12

--- CUT HERE ---
#! /bin/sh
echo x - corgraph.asm
sed 's/^X//' >corgraph.asm <<'*-*-END-of-corgraph.asm-*-*'
XTITLE	Corona graphics module
X;	Colin Kelley
X;	January 1987
X
Xinclude header.mac
X
Xif1
Xinclude lineproc.mac
Xendif
X
X
X_text	segment
X
Xpublic	_GrInit,_GrReset,_GrOnly,_TxOnly,_GrandTx,_Cor_line,_Cor_mask
X
Xcorpixel proc near
X	ror word ptr linemask,1
X	jc cont
X	ret
Xcont:	push bp
X	mov bp,sp
X	push ax
X	push bx
X	push cx
X	mov es,ScSeg
X	shl bx,1			; y
X	mov bx,word ptr LookUp[bx] ; bx has y mem address
X	mov cl,al			; x
X	and cl,7
X	shr ax,1
X	shr ax,1
X	shr ax,1			; ax /= 8
X	add bx,ax
X	mov al,1
X	shl al,cl			; al contains bit mask
X	or byte ptr es:[bx],al
X	pop cx
X	pop bx
X	pop ax
X	pop bp
X	ret
X
Xlineproc _Cor_line, corpixel
X
Xbeginproc _GrInit
X	push bp
X	mov bp,sp
X	push di
X	mov ax, [bp+X]			; screen number (0 - 7)
X	mov cl,11
X	shl ax,cl			; multiply by 2048 to get segment
X	mov ScSeg,ax			; save segment for later
X	push ax
X	mov es, ax
X	xor ax,ax
X	mov di,ax
X	mov cx, 4000h
X	cld
X	rep stosw
X	pop cx
X	call near ptr GrAddr
X	mov ax,es
X	pop di
X	pop bp
X	ret
X_GrInit	endp
X
Xbeginproc _GrReset
X	mov cx, 0
X	call near ptr GrAddr
X	ret
X_GrReset endp
X
XGrAddr	proc near
X	mov dx,3b4h			; address of 6845
X	mov al,0ch			; register 12
X	out dx,al
X	inc dx
X	mov al,ch			; Graphics Segment High
X	out dx,al
X	dec dx
X	mov al,0dh			; register 13
X	out dx,al
X	mov al,cl			; Graphics Segment Low
X	inc dx
X	out dx,al
X	ret
XGrAddr	endp
X
Xbeginproc _GrOnly
X	mov dx,3b8h
X	mov al,0a0h
X	out dx,al
X	ret
X_GrOnly	endp
X
Xbeginproc _TxOnly
X	mov dx,3b8h
X	mov al,28h
X	out dx,al
X	ret
X_TxOnly	endp
X
Xbeginproc _GrandTx
X	mov dx,3b8h
X	mov al,0a8h
X	out dx,al
X	ret
X_GrandTx endp
X
Xbeginproc _Cor_mask
X	push bp
X	mov bp,sp
X	mov ax,[bp+x]			; mask
X	mov linemask,ax
X	pop bp
X	ret
X_Cor_mask endp
X
Xcorpixel endp
X
X_text	ends
X 
X
X_data	segment
Xlinemask dw -1
XScSeg	dw 0
X_data	ends
X
Xconst	segment
X
XK	equ 1024
X
Xmem_mac	MACRO x
X	dw x,2*K+x,4*K+x,6*K+x,8*K+x,10*K+x,12*K+x,14*K+x,16*K+x
X	dw 18*K+x,20*K+x,22*K+x,24*K+x
X	ENDM
XLookUp	equ $
X	mem_mac 0
X	mem_mac 80
X	mem_mac (80*2)
X	mem_mac (80*3)
X	mem_mac (80*4)
X	mem_mac (80*5)
X	mem_mac (80*6)
X	mem_mac (80*7)
X	mem_mac (80*8)
X	mem_mac (80*9)
X	mem_mac (80*10)
X	mem_mac (80*11)
X	mem_mac (80*12)
X	mem_mac (80*13)
X	mem_mac (80*14)
X	mem_mac (80*15)
X	mem_mac (80*16)
X	mem_mac (80*17)
X	mem_mac (80*18)
X	mem_mac (80*19)
X	mem_mac (80*20)
X	mem_mac (80*21)
X	mem_mac (80*22)
X	mem_mac (80*23)
X	mem_mac (80*24)
X
Xconst	ends
X
X	end
*-*-END-of-corgraph.asm-*-*
echo x - corplot.c
sed 's/^X//' >corplot.c <<'*-*-END-of-corplot.c-*-*'
X#include <stdio.h>
X#include <process.h>
X#include <dos.h>
X
X#define BOUNDARY 32768
X#define segment(addr) (FP_SEG(m) + ((FP_OFF(m)+15) >> 4));
X#define round(value,boundary) (((value) + (boundary) - 1) & ~((boundary) - 1))
X
Xchar *malloc(),*realloc();
X
Xchar prog[] = "gnuplot";
Xchar corscreen[] = "CORSCREEN=0";
X
Xmain()
X{
Xregister unsigned int segm,start;
Xchar *m;
X	if (!(m = malloc(BOUNDARY))) {
X		printf("malloc() failed\n");
X		exit(1);
X	}
X	segm = segment(m);
X	start = round(segm,BOUNDARY/16);
X
X	if (realloc(m,BOUNDARY+(start-segm)*16) != m) {
X		printf("can't realloc() memory\n");
X		exit(2);
X	}
X
X	if ((segm = start >> 11) >= 8) {
X		printf("not enough room in first 256K\n");
X		exit(3);
X	}
X
X	corscreen[sizeof(corscreen)-2] = '0' + segm;
X	if (putenv(corscreen))
X		perror("putenv");
X
X	if (spawnlp(P_WAIT,prog,prog,NULL))
X		perror("spawnlp");
X}
*-*-END-of-corplot.c-*-*
echo x - header.mac
sed 's/^X//' >header.mac <<'*-*-END-of-header.mac-*-*'
Xif1
XLARGE	equ 1			; define your memory model here
X
Xifdef	SMALL
X	; default, so do nothing
X	else
X
Xifdef	MEDIUM
X	LARGE_CODE equ 1
X	else
X
Xifdef	COMPACT
X	LARGE_DATA equ 1
X	else
X
Xifdef	LARGE
X	LARGE_DATA equ 1
X	LARGE_CODE equ 1
X
Xelse
X	%out No memory model defined--assuming SMALL
X
Xendif	; LARGE
Xendif	; COMPACT
Xendif	; MEDIUM
Xendif	; SMALL
X
X
Xbeginproc macro procname
X
Xifdef	LARGE_CODE
X	procname proc far
Xelse
X	procname proc near
Xendif	; LARGE_CODE
X
X	endm	; beginproc
X
X
Xendif	; if1
X
X
X_TEXT	SEGMENT	BYTE PUBLIC 'CODE'
X_TEXT	ENDS
X_DATA	SEGMENT WORD PUBLIC 'DATA'
X_DATA	ENDS
XCONST	SEGMENT WORD PUBLIC 'CONST'
XCONST	ENDS
X_BSS	SEGMENT WORD PUBLIC 'BSS'
X_BSS	ENDS
X
XDGROUP	GROUP	CONST, _BSS, _DATA
X	assume cs:_text, ds:dgroup, ss:dgroup, es:dgroup
X
X; define X as the offset of first argument on stack frame
X
Xifdef LARGE_CODE
X	X	equ 6			; return offset and segment + old BP
Xelse
X	X	equ 4			; return offset + old BP
Xendif	; LARGE_CODE
*-*-END-of-header.mac-*-*
echo x - hrcgraph.asm
sed 's/^X//' >hrcgraph.asm <<'*-*-END-of-hrcgraph.asm-*-*'
XTITLE	Hercules graphics module
X
X;	Michael Gordon - 8-Dec-86
X;
X; Certain routines were taken from the Hercules BIOS of	Dave Tutelman - 8/86
X; Others came from pcgraph.asm included in GNUPLOT by Colin Kelley
X;
X; modified slightly by Colin Kelley - 22-Dec-86
X;	added header.mac, parameterized declarations
X; added dgroup: in HVmodem to reach HCh_Parms and HGr_Parms - 30-Jan-87
X; modified by Russell Lang 3 Jun 1988
X;	added H_init
X
Xinclude header.mac
X
Xif1
Xinclude lineproc.mac
Xendif
X
X
XGPg1_Base equ 0B800h	; Graphics page 1 base address
X
X_text	segment
X
X	public _H_line, _H_color, _H_mask, _HVmode, _H_puts
X	public _H_init
X
XHCfg_Switch equ	03BFH	; Configuration Switch - software switch 
X			; to select graphics card memory map
X
Xbeginproc _H_init
X	mov al, 03H	; allow graphics in b8000:bffff
X	mov dx, HCfg_Switch
X	out dx, al
X	ret
X_H_init endp
X
Xhpixel	proc near
X	ror word ptr bmask,1
X	jc cont
X	ret
Xcont:
X	push ax
X	push bx
X	push cx
X	push dx
X	push si
X	mov cx,ax		; x
X	mov dx,bx		; y
X;
X; [couldn't this be done faster with a lookup table? -cdk]
X;
X	; first compute the address of byte to be modified
X	; = 90*[row/4] + [col/8] + 2^D*[row/4] + 2^F*page
X	mov	bh,cl		; col (low order) in BH
X	mov	bl,dl		; row (low order) in BL
X	and	bx,0703H	; mask the col & row remainders
XIFDEF iAPX286
X	shr	cx,3		; col / 8
X	shr	dx,2		; row / 4
X	mov	al,90
X	mul	dx		; AX = 90*[ row/4 ]
X	add	ax,cx		;  ... + col/8
X	shl	bl,5		; align row remainder
XELSE			; same as above, obscure but fast for 8086
X	shr	cx,1		; divide col by 8
X	shr	cx,1
X	shr	cx,1
X	shr	dx,1		; divide row by 4
X	shr	dx,1
X	shl	dx,1		; begin fast multiply by 90 (1011010 B)
X	mov	ax,dx
X	shl	dx,1
X	shl	dx,1
X	add	ax,dx
X	shl	dx,1
X	add	ax,dx
X	shl	dx,1
X	shl	dx,1
X	add	ax,dx		; end fast multiply by 90
X	add	ax,cx		; add on the col/8
X	shl	bl,1		; align row remainder
X	shl	bl,1
X	shl	bl,1
X	shl	bl,1
X	shl	bl,1
XENDIF
X	add	ah,bl		; use aligned row remainder
Xend_adr_calc:			; address of byte is now in AX
X	mov	dx,GPg1_Base	; base of pixel display to DX
X	mov	es,dx		; ...and thence to segment reg
X	mov	si,ax		; address of byte w/ pixel to index reg
X	mov	cl,bh		; bit addr in byte
X	mov	al,80H		; '1000 0000' in AL 
X	shr	al,cl		; shift mask to line up with bit to read/write
Xset_pix:			; set the pixel
X	or	es:[si],al	; or the mask with the right byte
X	pop si
X	pop dx
X	pop cx
X	pop bx
X	pop ax
X	ret
Xhpixel endp
X
Xlineproc _H_line, hpixel
X
X;
X; clear - clear page 1 of the screen buffer to zero (effectively, blank
X;	the screen)
X;
Xclear   proc near
X	push es
X	push ax
X	push cx
X	push di
X	mov ax, GPg1_Base
X	mov es, ax
X	xor di, di
X	mov cx, 4000h
X	xor ax, ax
X	cld
X	rep stosw			; zero out screen page
X	pop di
X	pop cx
X	pop ax
X	pop es
X	ret
Xclear	endp
X
Xbeginproc _H_color
X	push bp
X	mov bp,sp
X	mov al,[bp+X]			; color
X	mov byte ptr color,al
X	pop bp
X	ret
X_H_color endp
X
Xbeginproc _H_mask
X	push bp
X	mov bp,sp
X	mov ax,[bp+X]			; mask
X	mov word ptr bmask,ax
X	pop bp
X	ret
X_H_mask endp
X
XHCtrl_Port	equ	03B8H	; Hercules 6845 control port IO addr
XHIndx_Port	equ	03B4H	; Hercules 6845 index port IO addr
XHScrn_Enable	equ	008h	; Control port bit to enable video
XHCh_Mode	equ	020h	; Character output mode
XHGr_Mode	equ	082h	; Graphics output mode page 1
X
Xparm_count equ 12
X
Xbeginproc _HVmode
X	push bp
X	mov bp, sp
X	push si
X	mov ax, [bp+X]
X	or ah, al
X	mov al, HCh_Mode		; Assume character mode is wanted
X	mov si, offset dgroup:HCh_Parms
X	cmp ah, 0			; nonzero means switch to graphics
X	jz vmode_ok
X	call near ptr clear		; clear the graphics page
X	mov al, HGr_Mode
X	mov si, offset dgroup:HGr_Parms
Xvmode_ok:
X	mov dx, HCtrl_Port
X	out dx, al			; Set Hercules board to proper mode
X	call near ptr setParms		; Set the 6845 parameters
X	or al, HScrn_Enable		; Enable the video output
X	out dx, al
X	pop si
X	pop bp
X	ret
X_HVmode	endp
X
XsetParms proc near		; Send 6845 parms to Hercules board
X	push ax
X	push dx
X	push si			
X	mov dx, HIndx_Port	; Index port addr -> DX
X	mov ah, 0		; 0 -> parameter counter
Xsp_loop:
X	mov al, ah
X	out dx, al		; output to 6845 addr register
X	inc dx			; next output to data register
X	mov al, [si]		; next control byte -> al
X	inc si
X	out dx, al		; output control byte
X	dec dx			; 6845 index addr -> dx
X	inc ah			; bump addr
X	cmp ah, parm_count
X	jnz sp_loop
X	pop si
X	pop dx
X	pop ax
X	ret
XsetParms endp
X
X; H_puts - print text in graphics mode
X;
X;	cx = row
X;	bx = column
X;	si = address of string (null terminated) to print
X
Xbeginproc _H_puts
X	push bp
X	mov bp, sp
X	push si
X	push ds
X	mov si, [bp+X]			; string offset
X
Xifdef LARGE_DATA
X	mov ds, [bp+X+2]		; string segment
X	mov cx, [bp+X+4]		; row
X	mov bx, [bp+X+6]		; col
Xelse
X	mov cx, [bp+X+2]		; row
X	mov bx, [bp+X+4]		; col
Xendif
X
Xploop:	lodsb				; get next char
X	or	al, al			; end of display?
X	je	pdone
X	call near ptr display
X	inc	bx			; bump to next column
X	jmp	ploop
Xpdone:	pop ds
X	pop si
X	pop bp
X	ret
X_H_puts	endp
X
X;
X; display - output an 8x8 character from the IBM ROM to the Herc board
X;
X; AX = char, BX = column (0-89), CX = row(0-42)  ** all preserved **
X;
XCON8	db	8
XCON180	db	180
XIBMROM	equ	0F000h
XCHARTAB	equ	0FA6Eh
X
Xdisplay	proc near
X	push	ds			; save the lot
X	push	es
X	push	ax
X	push	bx
X	push	cx
X	push	dx
X	push	si
X	push	di
X
X; setup ds -> IBM ROM, and si -> index into IBM ROM character table located
X;	at 0fa6eh in the ROM
X
X	and	ax, 07fh
X	mul	cs:CON8			; mult by 8 bytes of table per char
X	mov	si, ax
X	mov	ax, IBMROM
X	mov	ds, ax
X	assume	ds:nothing
X	add	si, CHARTAB		; add offset of character table
X
X; compute index into Hercules screen memory for scan line 0.  The remaining
X;	seven scan lines are all at fixed offsets from the first.
X;
X;	Since graphics mode treats the screen as sets of 16x4 "characters",
X;	we need to map an 8x8 real character onto the front or back of
X;	a pair of graphics "characters".  The first four scan lines of our
X;	8x8 character will map to the top graphics "character", and the second
X;	four scan lines map to the graphics character on the "line" (4 scan
X;	lines high) below it.
X;
X;	For some exotic hardware reason (probably speed), all scan line 0
X;	bits (i.e. every fourth scan line) are stored in memory locations
X;	0-2000h in the screen buffer.  All scan line 1 bits are stored
X;	2000h-4000h.  Within these banks, they are stored by rows.  The first
X;	scan line on the screen (scan line 0 of graphics character row 0)
X;	is the first 45 words of memory in the screen buffer.  The next 45
X;	words are the first scan line graphics row 1, and since graphics
X;	"characters" are 4 bits high, this second scan line is physically
X;	the fifth scan line displayed on the screen.
X;
X;	SO, to display an 8x8 character, the 1st and 5th rows of dots are
X;	both scan line 0 of the graphics "character", the 2nd and 6th are
X;	scan line 1, and so on.
X;
X;	The column (0-89) tells which byte in a scan line we need to load.
X;	Since it takes two rows of graphics characters to hold one row of
X;	our characters, column+90 is a index to scan line 4 rows of pixels
X;	higher (n+4).  Thus 180 bytes of screen memory in any bank (0h, 2000h,
X;	4000h, 6000h) represent a row of 8x8 characters.
X;	
X;	The starting location in screen memory for the first scan line of
X;	a character to be displayed will be:  	(row*180)+column
X;	The 5th scan line will be at:		(row*180)+column+90
X;
X;	The second and 6th scan lines will be at the above offsets plus
X;	the bank offset of 2000h.  The third and 7th, add 4000h and finally
X;	the 4th and 8th, add 6000h.
X;
X	mov	ax, GPg1_Base
X	mov	es, ax			; es = hercules page 0
X	mov	ax, cx			; get row
X	mul	cs:CON180		; mult by 180(10)
X	mov	di, ax			; di = index reg
X	cld				; insure right direction
X
X;output 8 segments of character to video ram
X
X	lodsb				; line 0
X	mov	es:[di+bx], al
X	lodsb
X	mov	es:[di+bx+2000h], al	; line 1
X	lodsb
X	mov	es:[di+bx+4000h], al	; line 2
X	lodsb
X	mov	es:[di+bx+6000h], al	; line 3
X	lodsb
X	mov	es:[di+bx+90], al	; line 4
X	lodsb
X	mov	es:[di+bx+2000h+90], al	; line 5
X	lodsb
X	mov	es:[di+bx+4000h+90], al	; line 6
X	lodsb
X	mov	es:[di+bx+6000h+90], al	; line 7
X
X	pop	di
X	pop	si
X	pop	dx
X	pop	cx
X	pop	bx
X	pop	ax
X	pop	es
X	pop	ds
X	ret
Xdisplay	endp
X
X_text	ends
X
X_data	segment
Xbmask	dw -1
Xcolor	db 1
X_data	ends
X
Xconst	segment
XHCh_Parms db 	61H, 50H, 52H, 0FH, 19H, 06H, 19H, 19H, 02H, 0DH, 0BH, 0CH
XHGr_Parms db	35H, 2DH, 2EH, 07H, 5BH, 02H, 57H, 57H, 02H, 03H, 00H, 00H
Xconst	ends
X
X	end
X
X
*-*-END-of-hrcgraph.asm-*-*
echo x - lineproc.mac
sed 's/^X//' >lineproc.mac <<'*-*-END-of-lineproc.mac-*-*'
X; lineproc.mac
X; MASM macro definition for Bresenham line-drawing routine
X; Colin Kelley
X; January 13, 1987
X
X
XINCAX	equ 40h			; for Self-Modifying Code
XINCBX	equ 43h
XDECAX	equ 48h
XDECBX	equ 4bh
X
X; usage:
X;   lineproc linename, pixelname
X;
X; where linemane is the name you want for the proc, and pixelname is the
X;   name of the routine that linename is to call to set pixels
X;
X
Xlineproc macro linename, pixelname
Xbeginproc linename
X
X	push bp
X	mov bp,sp
X	push si
X	push di
X	mov ax,[bp+X]		; x1
X	mov bx,[bp+X+2]		; y1
X	mov cx,[bp+X+4]		; x2
X	mov si,[bp+X+6]		; y2
X
X	cmp ax,cx		; x1,x2
X	jne i19
X	cmp bx,si		; y1,y2
X	jne i19
X
X	call pixelname
X
X	jmp i28
Xi19:
X	mov dx,ax		; dx,x1
X	sub dx,cx		; x2
X	jnc noabsx
X	neg dx
Xnoabsx:
X	mov di,bx		; dy,y1
X	sub di,si		; y2
X	jnc noabsy
X	neg di			; dy
Xnoabsy:
X	cmp dx,di		; dx,dy
X	jb i21			; go iterate y's
X;
X; iterate x's
X;
X	cmp bx,si		; y1,y2
X	jb forwardy
X	mov byte ptr cs:yinc1,DECBX
X	jmp short i22
Xforwardy:
X	mov byte ptr cs:yinc1,INCBX
Xi22:
X	cmp ax,cx		; x1,x2
X	jae l20004
X	mov byte ptr cs:xinc1,INCAX
X	jmp short l20005
Xl20004:
X	mov byte ptr cs:xinc1,DECAX
Xl20005:
X	mov bp,dx		; sum,dx
X	shr bp,1		; sum
Xd23:
X	cmp ax,cx		; x1,x2
X	je i28			; done
Xxinc1:	inc ax			; may become inc or dec
X	add bp,di		; sum,dy
X	cmp bp,dx
X	jb i27
X	sub bp,dx		; sum,dx
Xyinc1:	inc bx			; may become inc or dec
Xi27:
X	call pixelname
X	jmp short d23
X
X;
X; else iterate y's
X;
Xi21:
X	cmp ax,cx		; x1,x2
X	jae l20006
X	mov byte ptr cs:xinc2,INCAX
X	jmp short l20007
Xl20006:
X	mov byte ptr cs:xinc2,DECAX
Xl20007:
X	cmp bx,si		; y1,y2
X	jb forwardy2
X	mov byte ptr cs:yinc2,DECBX
X	jmp short i29
Xforwardy2:
X	mov byte ptr cs:yinc2,INCBX
Xi29:
X	mov bp,di		; sum,dy
X	shr bp,1		; sum,1
Xd30:
X	cmp bx,si		; y1,y2
X	je i28
Xyinc2:	inc bx			; may become inc or dec
X	add bp,dx		; sum,dx
X	cmp bp,di		; sum,dy
X	jb i34
X	sub bp,di		; sum,dy
Xxinc2:	inc ax			; may become inc or dec
Xi34:
X	call near ptr pixelname
X	jmp short d30
X;
X; clean up and exit
X;
Xi28:
X	pop di
X	pop si
X	pop bp
X	ret
X
Xlinename endp
X	endm
*-*-END-of-lineproc.mac-*-*
echo x - linkopt.msc
sed 's/^X//' >linkopt.msc <<'*-*-END-of-linkopt.msc-*-*'
Xpcgraph+hrcgraph+corgraph+term+graphics+
Xplot+setshow+command+help+internal+misc+
Xparse+eval+scanner+standard+util+version
Xgnuplot
Xnul;
*-*-END-of-linkopt.msc-*-*
echo x - linkopt.tc
sed 's/^X//' >linkopt.tc <<'*-*-END-of-linkopt.tc-*-*'
X\tc\lib\C0l command eval graphics help internal misc parse plot scanner setshow standard term util version cga egavga herc ,gnuplot,gnuplot, \tc\lib\emu \tc\lib\mathl \tc\lib\cl \tc\lib\graphics
X        
*-*-END-of-linkopt.tc-*-*
echo x - makefile.msc
sed 's/^X//' >makefile.msc <<'*-*-END-of-makefile.msc-*-*'
X# Make file for use with Microsoft C  Version 5.10
X# and Microsoft Program Maintenance Utility  Version 4.07
X# 
X
X# where to place gnuplot.gih helpfile
XHELPFILE = gnuplot.gih
X
X# /c  means don't link
X# /AL means large memory model (large code, large data)
X# /DPC means define symbol PC
XCFLAGS = /c /AL /DPC #/DMSDOS #/Zi #/Od
X
XTERMFLAGS = /DHERCULES /DCORONA /DATT6300 /DEPSON /DPOSTSCRIPT /DHP75 /DHPGL /DDXY800A  /DNEC
X
X# /NOE means NO EXTernal Dictionary
X# /EX  means pack EXE file
X# /ST:8000 means stack size 8000 bytes
XLINKFLAGS = /NOE /EX /ST:8000 #/codeview 
X
XOBJS = 	command.obj eval.obj graphics.obj help.obj internal.obj \
X	misc.obj parse.obj plot.obj scanner.obj setshow.obj standard.obj \
X	term.obj util.obj version.obj pcgraph.obj hrcgraph.obj corgraph.obj
X
XCSOURCE5 = term\aed.trm term\dxy.trm term\epson.trm term\font5x7.trm \
X	term\hp26.trm term\hp2648.trm term\hpgl.trm \
X	term\hpljet.trm term\iris4d.trm term\latex.trm 
XCSOURCE6 = term\post.trm term\pc.trm term\qms.trm term\regis.trm \
X	term\tek.trm term\unixpc.trm term\unixplot.trm term\v384.trm \
X	term\imPcodes.h term\imagen.trm term\object.h term\fig.trm
X
X
X# default rules
X.c.obj:
X	cl $(CFLAGS) $*.c
X
X.asm.obj:
X	masm $*;
X
Xpcgraph.obj: pcgraph.asm header.mac lineproc.mac
X
Xcorgraph.obj: corgraph.asm header.mac lineproc.mac
X
Xhrcgraph.obj: hrcgraph.asm header.mac lineproc.mac
X
Xcommand.obj: command.c plot.h setshow.h help.h
X	cl $(CFLAGS) /DHELPFILE=\"$(HELPFILE)\" command.c
X
Xeval.obj: eval.c plot.h
X
Xgraphics.obj: graphics.c plot.h setshow.h
X
Xhelp.obj: help.c plot.h help.h
X
Xinternal.obj: internal.c plot.h
X
Xmisc.obj: misc.c plot.h setshow.h
X
Xparse.obj: parse.c plot.h
X
Xplot.obj: plot.c plot.h setshow.h
X
Xscanner.obj: scanner.c plot.h
X
Xsetshow.obj: setshow.c plot.h setshow.h
X
Xstandard.obj: standard.c plot.h
X
Xterm.obj: term.c plot.h $(CSOURCE5) $(CSOURCE6)
X	cl $(CFLAGS) $(TERMFLAGS) term.c
X
Xutil.obj: util.c plot.h
X
Xversion.obj: version.c
X
X# convert gnuplot.doc to gnuplot.gih
Xdoc2gih.exe: docs\doc2gih.c
X	cl docs\doc2gih.c
X
X$(HELPFILE): doc2gih.exe docs\gnuplot.doc
X	doc2gih docs\gnuplot.doc $(HELPFILE)
X
X# Object files in link command line are ordered to avoid far jumps.
X# use linkopt.msc to avoid command-line overflow
X
Xgnuplot.exe: $(OBJS)
X link $(LINKFLAGS) @linkopt.msc
*-*-END-of-makefile.msc-*-*
echo x - makefile.tc
sed 's/^X//' >makefile.tc <<'*-*-END-of-makefile.tc-*-*'
X# make file for Turbo C
X# Modified from MSC make by John Campbell and Bill Wilson
X# The compile and link includes debug flags.  Take them out if you
X# do not want them included  (-y -v -M, /m /s /v /l)
X
X# where to place gnuplot.gih helpfile
XHELPFILE = gnuplot.gih
X# location of Turbo C compiler
X# if this is changed then linkopt.tc will need to be edited.
XTC = \tc
X# location of BGI files
XBGI = $(TC)
X# -c means don't link, -f means emulate 8087 if not present
X# -ml means use large model (large code, large data)
X# -M means produce link map
X# -y means include line numbers for debugger
X# -v means include debug info
XCFLAGS = -c -f -ml -M -y -v -I$(TC)\include -DMSDOS -DPC
XTERMFLAGS = -DPOSTSCRIPT -DHPGL -DHP75 -DDXY800A -DEPSON -DNEC
X
XOBJS = 	command.obj eval.obj graphics.obj help.obj internal.obj \
X	misc.obj parse.obj plot.obj scanner.obj setshow.obj standard.obj \
X	term.obj util.obj version.obj cga.obj egavga.obj herc.obj
X
XCSOURCE5 = term\aed.trm term\dxy.trm term\epson.trm term\font5x7.trm \
X	term\hp26.trm term\hp2648.trm term\hpgl.trm \
X	term\hpljet.trm term\iris4d.trm term\latex.trm 
XCSOURCE6 = term\post.trm term\pc.trm term\qms.trm term\regis.trm \
X	term\tek.trm term\unixpc.trm term\unixplot.trm term\v384.trm \
X	term\imPcodes.h term\imagen.trm term\object.h term\fig.trm
X
X
Xall: gnuplot.exe $(HELPFILE)
X
X# use linkopt.tc to avoid command-line overflow
X
Xgnuplot.exe: $(OBJS) 
X	tlink /m /s /v /l @linkopt.tc
X
X# default rules
X
X.c.obj:  
X	tcc $(CFLAGS) $<
X
Xcommand.obj: command.c plot.h setshow.h help.h
X	tcc $(CFLAGS) -DHELPFILE="$(HELPFILE)" command.c
X
Xeval.obj: eval.c plot.h
X
Xgraphics.obj: graphics.c plot.h setshow.h
X
Xhelp.obj: help.c plot.h help.h
X
Xinternal.obj: internal.c plot.h
X
Xmisc.obj: misc.c plot.h setshow.h help.h
X
Xparse.obj: parse.c plot.h
X
Xplot.obj: plot.c plot.h setshow.h
X
Xscanner.obj: scanner.c plot.h
X
Xsetshow.obj: setshow.c plot.h setshow.h
X
Xstandard.obj: standard.c plot.h
X
Xterm.obj: term.c plot.h $(CSOURCE5) $(CSOURCE6)
X	tcc $(CFLAGS) $(TERMFLAGS) term.c
X	
Xutil.obj: util.c plot.h
X
Xversion.obj: version.c
X
X# convert gnuplot.doc to gnuplot.gih
X$(HELPFILE): doc2gih.exe docs\gnuplot.doc
X	doc2gih docs\gnuplot.doc $(HELPFILE)
X
Xdoc2gih.exe: docs\doc2gih.c
X	tcc -I$(TC)\include -L$(TC)\lib docs\doc2gih.c
X
X# convert Borland Graphics Interface files to object for linking
Xcga.obj: $(BGI)\cga.bgi
X	bgiobj $(BGI)\cga
X
Xegavga.obj: $(BGI)\egavga.bgi
X	bgiobj $(BGI)\egavga
X
Xherc.obj: $(BGI)\herc.bgi
X	bgiobj $(BGI)\herc
*-*-END-of-makefile.tc-*-*
echo x - pcgraph.asm
sed 's/^X//' >pcgraph.asm <<'*-*-END-of-pcgraph.asm-*-*'
XTITLE	PC graphics module
X;	uses LINEPROC.MAC
X
X;	Michael Gordon - 8-Dec-86
X;
X; Certain routines were taken from the Hercules BIOS of	Dave Tutelman - 8/86
X; Others came from pcgraph.asm included in GNUPLOT by Colin Kelley
X;
X; modified slightly by Colin Kelley - 22-Dec-86
X;	added header.mac, parameterized declarations
X; added dgroup: in HVmodem to reach HCh_Parms and HGr_Parms - 30-Jan-87
X;
X; modified and added to for use in plot(3) routines back end.
X; Gil Webster.
X;
X; Assemble with masm ver. 4.  
X
Xinclude header.mac
X
Xif1
Xinclude lineproc.mac
Xendif
X
XGPg1_Base equ 0B800h	; Graphics page 1 base address
X
X_text	segment
X
X	public _PC_line, _PC_color, _PC_mask, _PC_curloc, _PC_puts, _Vmode
X	public _erase, _save_stack, _ss_interrupt
X	extrn _inter:near
X
Xpcpixel proc near
X	ror word ptr linemask,1
X	jc cont
X	ret
Xcont:
X	push ax
X	push bx
X	push cx
X	push dx
X	push bp
X	mov cx,ax		; x
X	mov dx,bx		; y
X	mov ah,0ch		; ah = write pixel
X	mov al,byte ptr color
X
X	mov bh, 0		; page 0
X	int 10h
X	pop bp
X	pop dx
X	pop cx
X	pop bx
X	pop ax
X	ret
Xpcpixel endp
X
Xlineproc _PC_line, pcpixel
X
X;
X; erase - clear page 1 of the screen buffer to zero (effectively, blank
X;	the screen)
X;
Xbeginproc _erase
X	push es
X	push ax
X	push cx
X	push di
X	mov ax, GPg1_Base
X	mov es, ax
X	xor di, di
X	mov cx, 4000h
X	xor ax, ax
X	cld
X	rep stosw			; zero out screen page
X	pop di
X	pop cx
X	pop ax
X	pop es
X	ret
X_erase endp
X
Xbeginproc _PC_color
X	push bp
X	mov bp,sp
X	mov al,[bp+X]			; color
X	mov byte ptr color,al
X	pop bp
X	ret
X_PC_color endp
X
Xbeginproc _PC_mask
X	push bp
X	mov bp,sp
X	mov ax,[bp+X]			; mask
X	mov word ptr linemask,ax
X	pop bp
X	ret
X_PC_mask endp
X
Xbeginproc _Vmode
X	push bp
X	mov bp,sp
X	push si
X	push di
X	mov ax,[bp+X]
X	int 10h
X	pop di
X	pop si
X	pop bp
X	ret
X_Vmode	endp
X
Xbeginproc _PC_curloc
X	push bp
X	mov bp,sp
X	mov dh, byte ptr [bp+X] ; row number
X	mov dl, byte ptr [bp+X+2] ; col number
X	mov bh, 0
X	mov ah, 2
X	int 10h
X	pop bp
X	ret
X_PC_curloc endp
X
X;
X; thanks to watale!broehl for finding a bug here--I wasn't pushing BP
X;   and reloading AH before INT 10H, which is necessary on genuine IBM
X;   boards...
X;
Xbeginproc _PC_puts
X	push bp
X	mov bp,sp
X	push si
X	mov bl,byte ptr color
X	mov si,[bp+X]		; offset
X
Xifdef LARGE_DATA
X	mov es,[bp+X+2]		; segment if large or compact data model
Xendif
X
Xputs2:
X
Xifdef LARGE_DATA
X	mov al,es:[si]
Xelse
X	mov al,[si]
Xendif
X	or al,al
X	jz puts3
X	mov ah,0eh		; write TTY char
X	int 10h
X	inc si
X	jmp short puts2
Xputs3:	pop si
X	pop bp
X	ret
X_PC_puts endp
X
X
X; int kbhit();
X;   for those without MSC 4.0
X; Use BIOS interrupt 16h to determine if a key is waiting in the buffer.
X; Return nonzero if so.
X;
X
Xbeginproc _kbhit
X	mov ah, 1		; function code 1 is keyboard test
X	int 16h			; keyboard functions
X	jnz kbfin		; Exit if char available
X	xor ax, ax		; No char:  return zero.
Xkbfin:	ret
X_kbhit	endp
X
X
X; _save_stack and _ss_interrupt are needed due to a bug in the MSC 4.0
X; code when run under MS-DOS 3.x.  Starting with 3.0, MS-DOS automatically
X; switches to an internal stack during system calls.  This leaves SS:SP
X; pointing at MS-DOS's stack when the ^C interrupt (INT 23H) is triggered.
X; MSC should restore its own stack before calling the user signal() routine,
X; but it doesn't.
X;
X; Presumably this code will be unnecessary in later releases of the compiler.
X;
X
X; _save_stack saves the current SS:SP to be loaded later by _ss_interrupt.
X;
X
Xbeginproc _save_stack
X	mov ax,ss
X	mov cs:save_ss,ax
X	mov ax,sp
X	mov cs:save_sp,ax
X	ret
X_save_stack endp
X
X
X; _ss_interrupt is called on ^C (INT 23H).  It restores SS:SP as saved in
X; _save_stack and then jumps to the C routine interrupt().
X;
Xbeginproc _ss_interrupt
X	cli			; no interrupts while the stack is changed!
X	mov ax,-1		; self-modifying code again
Xsave_ss	equ this word - 2
X	mov ss,ax
X	mov sp,-1		; here too
Xsave_sp equ this word - 2
X	sti
X	jmp _inter; now it's safe to call the real routine
X_ss_interrupt endp
X
X
X_text	ends
X
X
Xconst	segment
Xlinemask dw -1
Xcolor	 db 1
Xconst	ends
X
X	end
*-*-END-of-pcgraph.asm-*-*
exit


