File: lineproc.mac

package info (click to toggle)
gnuplot 4.6.6-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 15,640 kB
  • ctags: 9,080
  • sloc: ansic: 85,383; cpp: 6,743; lisp: 3,999; makefile: 2,126; sh: 976; objc: 647; asm: 539; perl: 310; awk: 235; pascal: 194; csh: 179; tcl: 88; python: 46
file content (126 lines) | stat: -rw-r--r-- 1,980 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
; lineproc.mac
; MASM macro definition for Bresenham line-drawing routine
; Colin Kelley
; January 13, 1987


INCAX	equ 40h			; for Self-Modifying Code
INCBX	equ 43h
DECAX	equ 48h
DECBX	equ 4bh

; usage:
;   lineproc linename, pixelname
;
; where linemane is the name you want for the proc, and pixelname is the
;   name of the routine that linename is to call to set pixels
;

lineproc macro linename, pixelname
beginproc linename

	push bp
	mov bp,sp
	push si
	push di
	mov ax,[bp+X]		; x1
	mov bx,[bp+X+2]		; y1
	mov cx,[bp+X+4]		; x2
	mov si,[bp+X+6]		; y2

	cmp ax,cx		; x1,x2
	jne i19
	cmp bx,si		; y1,y2
	jne i19

	call pixelname

	jmp i28
i19:
	mov dx,ax		; dx,x1
	sub dx,cx		; x2
	jnc noabsx
	neg dx
noabsx:
	mov di,bx		; dy,y1
	sub di,si		; y2
	jnc noabsy
	neg di			; dy
noabsy:
	cmp dx,di		; dx,dy
	jb i21			; go iterate y's
;
; iterate x's
;
	cmp bx,si		; y1,y2
	jb forwardy
	mov byte ptr cs:yinc1,DECBX
	jmp short i22
forwardy:
	mov byte ptr cs:yinc1,INCBX
i22:
	cmp ax,cx		; x1,x2
	jae l20004
	mov byte ptr cs:xinc1,INCAX
	jmp short l20005
l20004:
	mov byte ptr cs:xinc1,DECAX
l20005:
	mov bp,dx		; sum,dx
	shr bp,1		; sum
d23:
	cmp ax,cx		; x1,x2
	je i28			; done
xinc1:	inc ax			; may become inc or dec
	add bp,di		; sum,dy
	cmp bp,dx
	jb i27
	sub bp,dx		; sum,dx
yinc1:	inc bx			; may become inc or dec
i27:
	call pixelname
	jmp short d23

;
; else iterate y's
;
i21:
	cmp ax,cx		; x1,x2
	jae l20006
	mov byte ptr cs:xinc2,INCAX
	jmp short l20007
l20006:
	mov byte ptr cs:xinc2,DECAX
l20007:
	cmp bx,si		; y1,y2
	jb forwardy2
	mov byte ptr cs:yinc2,DECBX
	jmp short i29
forwardy2:
	mov byte ptr cs:yinc2,INCBX
i29:
	mov bp,di		; sum,dy
	shr bp,1		; sum,1
d30:
	cmp bx,si		; y1,y2
	je i28
yinc2:	inc bx			; may become inc or dec
	add bp,dx		; sum,dx
	cmp bp,di		; sum,dy
	jb i34
	sub bp,di		; sum,dy
xinc2:	inc ax			; may become inc or dec
i34:
	call near ptr pixelname
	jmp short d30
;
; clean up and exit
;
i28:
	pop di
	pop si
	pop bp
	ret

linename endp
	endm