-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGRAPH.PAS
More file actions
162 lines (130 loc) · 2.71 KB
/
Copy pathGRAPH.PAS
File metadata and controls
162 lines (130 loc) · 2.71 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
unit graph;
interface
uses dos,u_adv;
var greg:registers;
var graphresult:integer;
var thisgraphiccolor:byte;
var lastlinex,lastliney:integer;
const detect=0;
grok=0;
getmaxcolor=15;
procedure startupgraph;
procedure initgraph;
procedure closegraph;
procedure shutdowngraph;
function grapherrormsg(n:integer):string;
procedure setcolor(n:integer);
procedure line(x1,y1,x2,y2:word);
procedure lineto(x,y:integer);
procedure putpixel(cx,cy,c:integer);
procedure setvisualpage(n:byte);
procedure setactivepage(n:byte);
procedure detectgraph(var gd,gm:integer);
{procedure setrgbpalette(c,r,b,g:byte);}
implementation
procedure startupgraph;
begin
greg.ah:=0;
greg.al:=19;
intr($10,greg);
end;
procedure initgraph;
begin
greg.ah:=0;
greg.al:=19+128;
intr($10,greg);
graphresult:=0;
end;
procedure closegraph;
begin
greg.ah:=0;
greg.al:=2; {was +128}
intr($10,greg);
end;
procedure shutdowngraph;
begin
greg.ah:=0;
greg.al:=2;
intr($10,greg);
end;
function grapherrormsg(n:integer):string;
begin
grapherrormsg:='Blah, blah';
end;
procedure setcolor(n:integer);
begin
thisgraphiccolor:=n;
end;
procedure swap(var n1,n2:word);
var t:word;
begin
t:=n1;
n1:=n2;
n2:=t;
end;
procedure line(x1,y1,x2,y2:word);
var cx,cy:word;
ucx,ucy:word;
xd,yd:word;
factor:word;
xswapped,yswapped:boolean;
begin
{mult all by 64}
x1:=x1 SHL 6; y1:=y1 SHL 6;
x2:=x2 SHL 6; y2:=y2 SHL 6;
if ((mouseon) and (mouseactive)) then hidemouse;
if (x1>x2) then begin;swap(x1,x2);xswapped:=true;end else xswapped:=false;
if (y1>y2) then begin;swap(y1,y2);yswapped:=true;end else yswapped:=false;
xd:=abs(x2-x1);
yd:=abs(y2-y1);
if xd<yd then factor:=yd SHR 6 else factor:=xd SHR 6;
{ if factor<1 then factor:=1;}
if factor>255 then factor:=9 else
if factor>127 then factor:=8 else
if factor>63 then factor:=7 else factor:=6;
cx:=x1;cy:=y1;
repeat
ucx:=cx;
ucy:=cy;
if xswapped then ucx:=x2+(x1-ucx);
if yswapped then ucy:=y2+(y1-ucy);
ucx:=ucx SHR 6;
ucy:=ucy SHR 6;
mem[$a000:(ucy)*320 + (ucx)]:= thisgraphiccolor;
cy:=cy+(yd SHR factor);
cx:=cx+(xd SHR factor);
until ((cx>x2) OR (cy>y2));
{ until (abs(cx-x1)>abs(x2-x1)) OR (abs(cy-y1)>abs(y2-y1)); }
lastlinex:=x2;lastliney:=y2;
end;
procedure lineto(x,y:integer);
begin
line(lastlinex,lastliney,x,y);
end;
procedure putpixel(cx,cy,c:integer);
begin
mem[$a000:round(cy)*320 + round(cx)]:= c;
lastlinex:=cx; lastliney:=cy;
end;
procedure setvisualpage(n:byte);
begin
end;
procedure setactivepage(n:byte);
begin
end;
procedure detectgraph(var gd,gm:integer);
begin
gm:=0;
gd:=9;
end;
{procedure setrgbpalette(c,r,b,g:byte);
begin
greg.ax:=$1010;
greg.bx:=c;
greg.dh:=r;
greg.ch:=b;
greg.cl:=g;
intr($10,greg);
end;}
begin
end.