From ca7c02da9576604ab539df99ca77fef0709b18e0 Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Wed, 5 Feb 2020 20:52:27 +0100 Subject: [PATCH] Mandelbrot on TV and 340 display. --- build/misc.tcl | 4 + src/lars/tvbrot.208 | 277 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 281 insertions(+) create mode 100644 src/lars/tvbrot.208 diff --git a/build/misc.tcl b/build/misc.tcl index 8eeb6d4d..8d017b5f 100644 --- a/build/misc.tcl +++ b/build/misc.tcl @@ -619,6 +619,10 @@ respond "*" ":midas dsk0: lars; ts lorenz_lorenz\r" expect ":KILL" respond "*" ":link dsk0: .; @ lorenz, lars; ts lorenz\r" +# Mandelbrot. +respond "*" ":midas lars; ts tvbrot_tvbrot\r" +expect ":KILL" + # PI respond "*" ":midas sys3;ts pi_rwg; ran\r" expect ":KILL" diff --git a/src/lars/tvbrot.208 b/src/lars/tvbrot.208 new file mode 100644 index 00000000..a7db8f72 --- /dev/null +++ b/src/lars/tvbrot.208 @@ -0,0 +1,277 @@ + title tvbrot - Draw Mandelbrot set on TV or 340 + +a=1 +b=2 +t=3 +r=4 +i=5 +x=7 +y=10 +pixel=11 +ptr=12 +q=16 +p=17 + +tyi==1 ;TTY channel. +pdp6==2 ;PDP6 channel. + +%tntv==5 ;Knight TV terminal type. +maxiter==100. + +define dins x + idpb x,dptr + aos dlen +termin + + +go: move p,[-10,,pdl] + + .open tyi,[.uai,,'tty] ;Is this a TV display? + .lose + .call [ setz + sixbit/cnsget/ + movei tyi + movem a + movem a + setzm a ] ;Third outout is terminal type. + .lose + caie a,%tntv + jrst notv ;Not a TV display. + + movei a,1100 ;TV display. + movem a,width ;It's 576x454 pixels. + movei a,454. + movem a,height + + move a,[-11,,tvpag] ;Map in frame buffer. + movei b,0 + .call [ setz + 'corblk + movei %cbwrt + movei %jself + move a + movei %jstvb + setz b ] + jrst notv + + move a,tvcreg ;Set TV ALU to IOR mode. + movei b,16 + dpb b,[341000,,a] + .suset [.stvcreg,,a] + jrst six + +notv: .dstart [-10000,,dlist-1] ;No TV, open 340. + jrst no340 + + movei a,1024. ;It's 1024x1024. + movem a,width + movei a,1024. + movem a,height + + movei q,start + move a,[jsp q,(q)] + movem a,blank + move a,[jsp q,1(q)] + movem a,dot + movei a,nl340 + movem a,newlin + + movei a,021047 ;Insert in display list, + dins a ;parameter mode. + + jrst six + +no340: .value [asciz /:No TV and no 340!/] + .logout 1, + +six: .open pdp6,[sixbit /usr/ ? 0 ? sixbit /pdp6/] + jrst nosix + + ;PDP-6 code not finished. + + +nosix: + move a,[3.0] ;Draw from -2.0 to +1.0. + move b,width + fsc b,233 + fdvr a,b ;Divide by number of pixels. + movem a,step' + + move a,height ;Start half a display height up. + lsh a,-1 + fsc a,233 + fmpr a,step + movem a,ystart' + + move y,height + movem y,ypix' + move y,ystart + hrli pixel,400000 + movei ptr,tvbuf + setom dots' + +yloop: + + setzm xpix' + move x,[-2.0] ;Draw from -2.0. + + pushj p,@newlin ;Start a new line. + setzm dots ;No dots on this line so far. + +xloop: + move r,x + move i,y + movei t,maxiter + +iter: move a,i + fmpr a,a + fmpr i,r + fsc i,1 + fmpr r,r + move b,r + fsbr r,a + fadr b,a + fsbri b,(4.0) + jumpge b,out + fadr r,x + fadr i,y + sojg t,iter + + xct dot ;Draw a dot. + setom dots ;At least one dot on this line. + jrst next + +out: xct blank ;Draw a blank. + +next: fadr x,step + + aos a,xpix + came a,width ;End of line? + jrst xloop + + fsbr y,step + + sos ypix + skipe ypix ;End of screen? + jrst yloop + + movei a,3000 ;Stop instruction. + dins a + .value + .logout 1, + +dot: jrst tvdot +blank: jrst tvblnk +newlin: [popj p,] + +tvdot: movem pixel,(ptr) +tvblnk: rot pixel,-1 + cain pixel,10 + jrst [ hrlzi pixel,400000 ? addi ptr,1 ? jrst .+1 ] + jrst next + + +;param 3000 is stop +; 020000 is point mode +; 100000 is vector mode +; 160000 is mode + +;point 200000 is vertical +; 002000 is intensify +; 160000 is mode + +;vect 400000 is escape +; 200000 is intensify +; 000177 is x magnitude +; 000200 is x sign +; 077400 is y magnitude +; 100000 is y sign + +nl340: movei a,220000 ;vertical point, stay in point mode + move b,ypix + dpb b,[001200,,a] + + skipe dots ;Any dots on this line? + jrst [ idpb a,dptr ? aos dlen ? jrst .+2 ] + jrst [ dpb a,dptr ? jrst .+1 ] + + ldb a,dptr ;Place a stop instruction at the + exch a,stop ;end of the display list. + dpb a,sptr + move a,dptr + movem a,sptr ;Remember where to restore later. + popj p, + +;The following is a state machine for making a 340 display list. +;It's implemented as a coroutine with two entry points. Call with +;JSP Q,0(Q) to draw a blank. Call with JSP Q,1(Q) to draw a dot. +; +;There are three states: blank, point, and vector. Each state has +;two transitions: draw a blank, or draw a point. +; +;JSP Q,(Q) is the coroutine return instruction. + +bl: jsp q,(q) ;blank mode +start: jrst bl + move a,xpix + movem a,xstart' + jrst point + +point: jsp q,(q) ;in point mode + jrst p1 + movei a,100000 ;go to vector mode + move b,xstart + dpb b,[001200,,a] + dins a + movei a,2 + movem a,length' + jrst vector +p1: movei a,022000 ;point mode, intensify + move b,xstart + dpb b,[001200,,a] + dins a + jrst bl + +vector: jsp q,(q) ;in vector mode + jrst v1 + aos length + move a,length + cail a,176 + jrst v2 + jrst vector + +v2: movei a,200000 ;intensify + move b,length + dpb b,[000700,,a] + dins a + movei a,1 + movem length + jrst vector + +v1: movei a,600000 ;escape, intensify + move b,length + dpb b,[000700,,a] + dins a + movei a,020000 ;point mode + dins a + jrst bl + + +pdl: block 10 +width: 0 +height: 0 + +dptr: 222200,,dlist +dlen: 1 +dlist: 3000,, + block 10000 +sptr: 222200,,dlist +stop: 0 + +;pdp6=<.+1777>/2000 + +tvpag=<.+1777>/2000 +tvbuf=tvpag_10. +tvcreg=tvbuf+10*2000 + +end go