home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programming
/
powerprogramming1994.iso
/
progtool
/
microcrn
/
issue_41.arc
/
CHAOS.ARC
/
CHAOS.PRO
< prev
next >
Wrap
Text File
|
1988-03-18
|
8KB
|
283 lines
nowarnings
include "tdoms.pro"
include "tpreds.pro"
include "linemenu.pro"
Database - graphics
Determ driver(Integer,Integer,String)
Determ maxcolors(Integer)
Determ maxX(Integer)
Determ maxY(Integer)
Determ aspectCorr(Real)
Determ graphCoord(Integer,Integer)
Determ lineStyleDBA(Integer,Integer,Integer)
Determ textHeightDBA(Integer)
Determ params(Real,Real,Real,Real,Real,Real,Real,Real,Real)
/* Initialize video and Global flags */
PREDICATES
GetDriverName(Integer,String)
Initialize
nondeterm KeepColor(Integer,Integer,Integer)
ToGrapHic
ToText
CLAUSES
Initialize:-
ToGraphic,
GetMaxColor(MaxColors), assert(maxcolors(MaxColors)),
GetMaxX(MaxX), assert(maxX(MaxX)),
GetMaxY(MaxY), assert(maxY(MaxY)),
GetAspectRatio(Xasp,Yasp),
AspectRatio = Xasp/Yasp, assert(aspectCorr(AspectRatio)).
ToGrapHic:-
/* Detect graphic equipment */
DetectGraph(G_Driver, G_Mode1),
KeepColor(G_Driver,G_Mode1,G_Mode),
GetDriverName(G_Driver,G_Name),
assert(driver(G_Driver,G_Mode,G_Name)),
InitGraph(G_Driver,G_Mode, _, _, bgi_Path),!.
ToText:-
closegraph().
KeepColor(1,_,0).
KeepColor(_,Mode,Mode).
GetDriverName(0,"Detect"). GetDriverName(1,"CGA").
GetDriverName(2,"MCGA"). GetDriverName(3,"EGA").
GetDriverName(4,"EGA64"). GetDriverName(5,"EGAMono").
GetDriverName(6,"Reserved"). GetDriverName(7,"HercMono").
GetDriverName(8,"ATT400"). GetDriverName(9,"VGA").
GetDriverName(10,"PC3270").
/* Main */
PREDICATES
Function(Real,Real,Real,Real,Real,Real,Real,Real,Real)
Iterate(Real,Real,Real,Real,Real,Real,Real,Real,Real,Real)
Iterate_Trace(Real,Real,Real,Real,Real,Real,Real,Real,Real,Real)
Main
Main_menu
NextProcess(Integer)
Process(Integer)
Testwindow(Integer)
CLAUSES
Iterate(X,L,Count,I,XScale,YScale,Height,Width,YStart,XStart):-
Y = X * (1-X),
Y1 = Y * L,
Row = Height - (((Y1 - YStart)/ YScale) * Height),
Col = (((Count - XStart)/ XScale)) * Width,
putpixel(Col,Row,7),
Newcount = Count + I,
XEnd = XScale + XStart,
Newcount <= XEnd,
!,
Y > 0.1E-275,
Iterate(Y1,L,Newcount,I,XScale,YScale,Height,Width,YStart,XStart).
Iterate(_,_,_,_,_,_,_,_,_,_).
Iterate_Trace(X,L,Count,I,XScale,YScale,Height,Width,YStart,XStart):-
Y = X * (1-X),
Y1 = Y * L,
Row = Height - (((Y1 - YStart)/ YScale) * Height),
Col = (((Count - XStart)/ XScale)) * Width,
shiftwindow(3),
write("YStart: ",YStart),
write("X : ",Count," "),
write("Y : ",Y1," "),
write("Col : ",Col," "),
write("Row : ",Row," "),nl,
putpixel(Col,Row,7),
Newcount = Count + I,
XEnd = XScale + XStart,
Newcount <= XEnd,
!,
Y > 0.1E-275,
Iterate_Trace(Y1,L,Newcount,I,XScale,YScale,Height,Width,YStart,XStart).
Iterate_Trace(_,_,_,_,_,_,_,_,_,_).
Function(I,X,Height,Width,XScale,YScale,L,XStart,YStart):-
Y = L * X * (1 - X),
Row = Height - (((Y - YStart)/ YScale) * Height),
Col = (((X - XStart)/ XScale)) * Width,
NextXRel = X + I,
XEnd = XScale + XStart,
NextXRel <= XEnd,
putpixel(Col,Row,2),
!,function(I,NextXRel,Height,Width,XScale,YScale,L,XStart,YStart).
function(_,_,_,_,_,_,_,_,_).
Main:-
makewindow(1,7,0,"",0,0,25,80),
makewindow(2,7,0,"",2,0,12,80),
makewindow(3,7,0,"",22,0,3,80),
makewindow(99,18,7,"",8,22,10,36), nl,
write(" CHAOS"),nl,
write(" (a Quick Code Project)"),nl,nl,
write(" copyright (c) 1988 by"),nl,
write(" acquired intelligence"),nl,
write(" po box 2091; davis, ca 95617"),
Main_menu.
Main_menu:-
linemenu(0,18,0,["Parameters","Function","Iterate","Trace","Quit"],C),
testwindow(99),
Process(C), ToText, Testwindow(81), Main_menu.
Testwindow(N):-
existwindow(N),
!,shiftwindow(N),
removewindow.
Testwindow(N).
Process(1):-
linemenu(1,103,0,["Show","Lambda","Step","XStart",
"XEnd","YStart","YEnd"],C),
!,NextProcess(C), testwindow(81).
Process(1).
Process(2):-
Initialize,
ClearDevice,
SetColor(1), % Set current color to white
SetBkColor(0), % Set background to black
maxX(MaxX),
maxY(MaxY), R = MaxY - 50,
SetViewPort(0,0,MaxX,R,1), % Open port to upper screen
GetViewSettings(Left,Top,Right,Bottom,_),
Rectangle(Left,Top,Right,Bottom), % Draw Border
Height = Bottom-Top,
Width = Right - Left,
params(XStart,_,XScale,YStart,_,YScale,Seed,Lambda,Inc),
function(Inc,Seed,Height,Width,XScale,YScale,Lambda,XStart,YStart),
!,readchar(_).
Process(2).
Process(3):-
Initialize,
SetColor(1), % Set current color to white
SetBkColor(0), % Set background to black
maxX(MaxX),
maxY(MaxY), R = MaxY - 50,
SetViewPort(0,0,MaxX,R,1), % Open port to upper screen
GetViewSettings(Left,Top,Right,Bottom,_),
Rectangle(Left,Top,Right,Bottom), % Draw Border
Height = Bottom-Top,
Width = Right - Left,
params(XStart,XEnd,XScale,YStart,_,YScale,Seed,Lambda,I),
iterate(Seed,Lambda,Seed,I,XScale,YScale,Height,Width,YStart,XStart),
!,readchar(_).
Process(3).
Process(4):-
Initialize,
SetColor(1), % Set current color to white
SetBkColor(0), % Set background to black
maxX(MaxX),
maxY(MaxY), R = MaxY - 50,
SetViewPort(0,0,MaxX,R,1), % Open port to upper screen
GetViewSettings(Left,Top,Right,Bottom,_),
Rectangle(Left,Top,Right,Bottom), % Draw Border
Height = Bottom-Top,
Width = Right - Left,
params(XStart,XEnd,XScale,YStart,_,YScale,Seed,Lambda,I),
Iterate_Trace(Seed,Lambda,Seed,I,XScale,YScale,Height,Width,YStart,XStart),
!,readchar(_).
Process(4).
Process(5):-
testwindow(81),
exit(1).
NextProcess(1):-
shiftwindow(2),
params(A,B,C,D,E,F,G,H,I),nl,
!,write("XStart : ",A),nl,
write("XEnd : ",B),nl,
write("XScale : ",C),nl,
write("YStart : ",D),nl,
write("YEnd : ",E),nl,
write("YScale : ",F),nl,
write("Seed : ",G),nl,
write("Lambda : ",H),nl,
write("Step : ",I),nl.
NextProcess(1).
NextProcess(2):-
shiftwindow(2),
write("Lambda : "), readreal(Lam),
Lam <> 0,
params(A,B,C,D,E,F,G,H,I),
!,retract(params(A,B,C,D,E,F,G,H,I)),
asserta(params(A,B,C,D,E,F,G,Lam,I)).
NextProcess(2):-
shiftwindow(2),
write("Invalid Lambda = 0").
NextProcess(3):-
shiftwindow(2),
write("Step : "), readreal(Inc),
Inc <> 0,
params(A,B,C,D,E,F,G,H,I),
!,retract(params(A,B,C,D,E,F,G,H,I)),
asserta(params(A,B,C,D,E,F,G,H,Inc)).
NextProcess(3):-
shiftwindow(2),
write("Invalid Step = 0").
NextProcess(4):-
shiftwindow(2),
write("XStart : "), readreal(XS),
params(A,B,C,D,E,F,G,H,I),
!,XScale = B - XS,
XScale <> 0,
retract(params(A,B,C,D,E,F,G,H,I)),
asserta(params(XS,B,XScale,D,E,F,G,H,I)).
NextProcess(4):-
shiftwindow(2),
write("Invalid X Scale = 0").
NextProcess(5):-
shiftwindow(2),
write("XEnd : "), readreal(XE),
params(A,B,C,D,E,F,G,H,I),
!,XScale = XE - A,
XScale <> 0,
retract(params(A,B,C,D,E,F,G,H,I)),
asserta(params(A,XE,XScale,D,E,F,G,H,I)).
NextProcess(5):-
shiftwindow(2),
write("Invalid X Scale = 0").
NextProcess(6):-
shiftwindow(2),
write("YStart : "), readreal(YS),
params(A,B,C,D,E,F,G,H,I),
!,YScale = E - YS,
YScale <> 0,
retract(params(A,B,C,D,E,F,G,H,I)),
asserta(params(A,B,C,YS,E,YScale,G,H,I)).
NextProcess(6):-
shiftwindow(2),
write("Invalid Y Scale = 0").
NextProcess(7):-
shiftwindow(2),
write("YEnd : "), readreal(YE),
params(A,B,C,D,E,F,G,H,I),
!,YScale = YE - D,
YScale <> 0,
retract(params(A,B,C,D,E,F,G,H,I)),
asserta(params(A,B,C,D,YE,YScale,G,H,I)).
NextProcess(7):-
shiftwindow(2),
write("Invalid Y Scale = 0").
GOAL
assert(params(0,1,1,0,1,1,0.04,3.0,0.003)),
Main.