## "Plotpourri" graphics demos in Basic for Apple II

### "Plotpourri" graphics demos in Basic for Apple II

Maybe this hi res graphics demo program could be ported to BBC Basic?

Article with images:

http://studio.jmoyer.nodomain.net/hgr23dplots/

Full text:

https://archive.org/details/washingtona ... 9/page/n13

Article with images:

http://studio.jmoyer.nodomain.net/hgr23dplots/

Full text:

https://archive.org/details/washingtona ... 9/page/n13

### Re: "Plotpourri" graphics demos in Basic for Apple II

It's more of a demo of the Apple II's hard-to-use HGR screen mode. It could kinda-sorta display six colours at 280 × 192: not all colours could appear adjacent to one another. MODE 1 would do nicely to replace it.

Lines 200-330 of the code do the clever bit. There doesn't seem to be the program code of this easily available online, and the OCR from the Internet Archive scan is not usable. You might need some help on AppleSoft's graphics commands: https://www.calormen.com/jsbasic/refere ... s-Graphics

Lines 200-330 of the code do the clever bit. There doesn't seem to be the program code of this easily available online, and the OCR from the Internet Archive scan is not usable. You might need some help on AppleSoft's graphics commands: https://www.calormen.com/jsbasic/refere ... s-Graphics

### Re: "Plotpourri" graphics demos in Basic for Apple II

The OCR is pretty bad! But the program text is fairly readable to the human eye. I think this is a type-in challenge.

Edit to add photo

Edit to add photo

Last edited by BigEd on Sat Jun 22, 2019 4:04 pm, edited 1 time in total.

### Re: "Plotpourri" graphics demos in Basic for Apple II

Here's the business end of the code. OCR with manual correction, been passed through an Apple II emulator to see if it parses, but not run:
There may be typos. AppleSoft does weird things to spacing, so if you want to import this via AppleSoft's EXEC function it'll need work. Badly needs a renum, something AppleSoft BASIC lacks.

Code: Select all

```
120 X1 = -2:X2 = 3:Y1 = -3:Y2 = 5.7:ZS = 80:RZ = 1:PC = 6:BC = 0
125 DEF FN Z(X) = SIN(X *Y) * EXP( -(X *X +Y *Y)/9) +0.2
128 GOSUB 130
129 END : REM WAS GOTO 30
130 NY = RZ *87:NX = RZ *50
140 HGR2
150 DX = (X2 -X1)/NX:DY = (Y2 -Y1)/NY
160 H0 = 0
170 K1 = 58:K2 = Y2 -Y1:K3 = 90
172 K4 = 174:K5 = 191
200 FOR X = X1 TO X2 STEP DX
220 H0 = (X -X1)/(X2 -XI) *100:NH = -1
240 FOR Y = Y1 TO Y2 STEP DY
250 ZZ = FN Z(X)
260 U = -ZZ *ZS -(Y -Y1)/K2 *K1 +K3 +H0
270 NH = NH +1
280 H = H0 +NH *K4/NY
290 IF V <0 OR V >K5 GOTO 330
300 HCOLOR= PC: HPLOT H,V: HCOLOR= BC: HPLOT H,V +1 TO H,K5
330 NEXT : NEXT
340 FOR J = 0 TO 3: PRINT CHR$(7): NEXT
345 GET ST$: REM HIT A KEY TO CONTINUE
350 RETURN
```

Last edited by scruss on Sat Jun 22, 2019 5:58 pm, edited 1 time in total.

### Re: "Plotpourri" graphics demos in Basic for Apple II

Correcting for OCR typos and changing line 330 to use BBC BASIC commands gives this:

Code: Select all

```
MODE 2
120 X1 = -2:X2 = 3:Y1 = -3:Y2 = 5.7:ZS = 80:RZ = 1:PC = 6:BC = 0
125 DEF FNZ(X) = SIN(X *Y) * EXP( -(X *X +Y *Y)/9) +0.2
128 GOSUB 130
129 END : REM WAS GOTO 30
130 NY = RZ *87:NX = RZ *50
140 REM HGR2
150 DX = (X2 -X1)/NX:DY = (Y2 -Y1)/NY
160 H0 = 0
170 K1 = 58:K2 = Y2 -Y1:K3 = 90
172 K4 = 174:K5 = 191
200 FOR X = X1 TO X2 STEP DX
220 H0 = (X -X1)/(X2 -X1) *100:NH = -1
240 FOR Y = Y1 TO Y2 STEP DY
250 ZZ = FNZ(X)
260 V = -ZZ *ZS -(Y -Y1)/K2 *K1 +K3 +H0
270 NH = NH +1
280 H = H0 +NH *K4/NY
290 IF V <0 OR V >K5 GOTO 330
300 GCOL 0,PC: PLOT 69,H,V: GCOL 0,BC: PLOT 69,H,V +1:DRAW H,K5
330 NEXT : NEXT
340 FOR J = 0 TO 3: PRINT CHR$(7): NEXT
345 A%=GET: REM PRESS A KEY TO CONTINUE
350 RETURN
```

Code: Select all

```
$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_
```

### Re: "Plotpourri" graphics demos in Basic for Apple II

Doesn't exactly produce the most edifying output (at least in MODE 1 on Brandy):

### Re: "Plotpourri" graphics demos in Basic for Apple II

Try scaling it up a bit:

300 GCOL 0,PC: PLOT 69,4*H,4*V: GCOL 0,BC: PLOT 69,4*H,4*V +1:DRAW 4*H,4*K5

300 GCOL 0,PC: PLOT 69,4*H,4*V: GCOL 0,BC: PLOT 69,4*H,4*V +1:DRAW 4*H,4*K5

Code: Select all

```
$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_
```

### Re: "Plotpourri" graphics demos in Basic for Apple II

Code: Select all

```
1 REM ******************
2 REM * *
3 REM * PLOTPOURRI *
4 REM * S COTTRELL *
5 REM * SEPT 1979 *
6 REM * *
7 REM ******************
8 REM
9 REM
10 TEXT
20 HOME : INPUT "WHICH PLOT FIRST (1-10)?";PN
25 ON PN GOTO 30,40,50,60,70,80,90,100,110,120
30 X1 = -4:X2 = 4:Y1 = -4:Y2 = 4:ZS = 45:RZ = 1:PC = 3:BC = 0
35 DEF FN Z(X) = ( COS(X *X +Y *Y) +1) * EXP( -(X *X +Y *Y)/6)
39 GOSUB 130
40 X1 = -4:X2 = 4:Y1 = -4:Y2 = 4:ZS = 12.5:RZ = 1:PC = 6:BC = 0
45 DEF FN Z(X) = 1 + COS(X *Y)
49 GOSUB 130
50 X1 = -6:X2 = 2:Y1 = -5:Y2 = 1:ZS = 25:RZ = 2:PC = 0:BC = 3
55 DEF FN Z(X) = ( - COS(X *X +Y *Y) -1) * EXP( -(X *X +Y *Y)/16) +1
59 GOSUB 130
60 X1 = -200:X2 = 200:Y1 = -100:Y2 = 200:ZS = 12.5:RZ = 2:PC = 0:BC = 7
65 DEF FN Z(X) = 1 + COS((X +Y)/( LOG(X *X +Y ^4)))
69 GOSUB 130
70 X1 = -20:X2 = 20:Y1 = -20:Y2 = 20:ZS = 40:RZ = 2:PC = 0:BC = 3
75 DEF FN Z(X) = ( COS(X *Y/ SQR(X *X +Y *Y)) -1) * EXP( -(X *X +Y *Y)/120)
79 GOSUB 130
80 X1 = -5:X2 = 5:Y1 = -5:Y2 = 5:ZS = 12.5:RZ = 2:PC = 0:BC = 7
85 DEF FN Z(X) = 1 + COS((X +Y)/( LOG( ABS(X *Y +0.5))))
89 GOSUB 130
90 X1 = -7:X2 = 7:Y1 = -17.4:Y2 = 17.4:ZS = 50:RZ = 2:PC = 0:BC = 3
95 DEF FN Z(X) = Y *X *X/(Y *Y +X *X *X *X) +0.4
99 GOSUB 130
100 X1 = -3:X2 = 3:Y1 = -3:Y2 = 3:ZS = 10:RZ = 1:PC = 2:BC = 0
105 DEF FN Z(X) = Y *X *(X *X -Y *Y)/(X *X +Y *Y) +2
109 GOSUB 130
110 X1 = -4:X2 = 6:Y1 = -3:Y2 = 5.7:ZS = 32:RZ = 2:PC = 3:BC = 0
115 DEF FN Z(X) = 3 * EXP( -( SQR(X *X +Y *Y))) +0.1 * COS(X *Y)
119 GOSUB 130
120 X1 = -2:X2 = 3:Y1 = -3:Y2 = 5.7:ZS = 80:RZ = 1:PC = 6:BC = 0
125 DEF FN Z(X) = SIN(X *Y) * EXP( -(X *X +Y *Y)/9) +.2
128 GOSUB 130
129 GOTO 30
130 NY = RZ *87:NX = RZ *50
140 HGR2
150 DX = (X2 -X1)/NX:DY = (Y2 -Y1)/NY
160 H0 = 0
170 K1 = 58:K2 = Y2 -Y1:K3 = 90
172 K4 = 174:K5 = 191
200 FOR X = X1 TO X2 STEP DX
220 H0 = (X -X1)/(X2 -X1) *100:NH = -1
240 FOR Y = Y1 TO Y2 STEP DY
250 ZZ = FN Z(X)
260 V = -ZZ *ZS -(Y -Y1)/K2 *K1 +K3 +H0
270 NH = NH +1
280 H = H0 +NH *K4/NY
290 IF V <0 OR V >K5 GOTO 330
300 HCOLOR= PC: HPLOT H,V: HCOLOR= BC: HPLOT H,V +1 TO H,K5
330 NEXT : NEXT
340 FOR J = 0 TO 3: PRINT CHR$(7): NEXT
345 GET ST$: REM HIT A KEY TO CONTINUE
350 RETURN
```

I put a supposedly auto-run disk image up on the Internet Archive: Plotpourri for Apple II. As the more famous brother of a prominent NW Glasgow seller of floor coverings once sang: “

*Dig the slowness*…”

Last edited by scruss on Tue Jun 25, 2019 9:37 pm, edited 1 time in total.

### Re: "Plotpourri" graphics demos in Basic for Apple II

Thanks for sharing the images - that gives us in beeb-land something to aim for...

### Re: "Plotpourri" graphics demos in Basic for Apple II

(Nice job with the runnable image on the Internet Archive - thanks for that too.)

### Re: "Plotpourri" graphics demos in Basic for Apple II

No probs: with IA's Apple II support, it's as easy to make an auto-run image as anything else. I'm sure it wouldn't take much prodding to get them to add Beeb-in-a-browser support.

I did all this with an emulator (dabonetn/linapple-pie) and the AppleCommander disk image tool. AppleCommander has recently added BASIC import/tokenizing.

Who knew that AppleSoft BASIC didn't do any syntax checking on entry, but only at run time? Also, if an Apple II is in HGR2 mode and hits a syntax error, you can't see the error message until you type

There's video too on the IA page now.

I did all this with an emulator (dabonetn/linapple-pie) and the AppleCommander disk image tool. AppleCommander has recently added BASIC import/tokenizing.

Who knew that AppleSoft BASIC didn't do any syntax checking on entry, but only at run time? Also, if an Apple II is in HGR2 mode and hits a syntax error, you can't see the error message until you type

*TEXT*.There's video too on the IA page now.

Last edited by scruss on Wed Jun 26, 2019 1:50 pm, edited 1 time in total.

### Re: "Plotpourri" graphics demos in Basic for Apple II

If anyone wishes to port it, the Apple II's 280 × 192 screen has the origin at the

*top left*of the screen.The way the programme does hidden pixel removal is quite simple:- plot a point at
*(X, Y)*in colour PC - draw a vertical line from (X, Y-1) down to (X, 0) in colour BC

### Re: "Plotpourri" graphics demos in Basic for Apple II

Code: Select all

```
1000 REM ******************
1010 REM * *
1020 REM * PLOTPOURRI *
1030 REM * S COTTRELL *
1040 REM * SEPT 1979 *
1050 REM * *
1060 REM ******************
1070 REM Washington Apple Pi Journal October 1979
1080 REM bbc basic / matrix brandy port - scruss, 2019-07
1090 MODE 1
1100 INPUT "WHICH PLOT FIRST (1-10)?";PN
1110 ON PN GOTO 1120,1240,1350,1470,1590,1710,1830,1950,2070,2190
1120 X1=-4
1130 X2=4
1140 Y1=-4
1150 Y2=4
1160 ZS=45
1170 RZ=1
1180 PN=1
1190 ZN=0:ZM=1.9992
1200 PC=5:REM magenta
1210 BC=0:REM black
1220 F$="(COS(X*X+Y*Y)+1)*EXP(-(X*X+Y*Y)/6)"
1230 GOSUB 2330
1240 X1=-4
1250 X2=4
1260 Y1=-4
1270 Y2=4
1280 ZS=12.5
1290 RZ=1
1300 PN=2
1310 ZN=0:ZM=2
1320 PC=2:REM blue, now green
1330 BC=0:REM black
1340 F$="1+COS(X*Y)"
1350 GOSUB 2330
1360 X1=-6
1370 X2=2
1380 Y1=-5
1390 Y2=1
1400 ZS=25
1410 RZ=2
1420 PN=3
1430 ZN=-1:ZM=0.9999
1440 PC=0:REM black
1450 BC=7:REM white?
1460 F$="(-COS(X*X+Y*Y)-1)*EXP(-(X*X+Y*Y)/16)+1"
1470 GOSUB 2330
1480 X1=-200
1490 X2=200
1500 Y1=-100
1510 Y2=200
1520 ZS=12.5
1530 RZ=2
1540 PN=4
1550 ZN=0:ZM=2
1560 PC=0:REM black
1570 BC=7:REM white?
1580 F$="1+COS((X+Y)/(LOG(X*X+Y^4)))"
1590 GOSUB 2330
1600 X1=-20
1610 X2=20
1620 Y1=-20
1630 Y2=20
1640 ZS=40
1650 RZ=2
1660 PN=5
1670 ZN=-1.4955:ZM=-0.0001
1680 PC=0:REM black
1690 BC=7:REM white?
1700 F$="(COS(X*Y/SQR(X*X+Y*Y))-1)*EXP(-(X*X+Y*Y)/120)"
1710 GOSUB 2330
1720 X1=-5
1730 X2=5
1740 Y1=-5
1750 Y2=5
1760 ZS=12.5
1770 RZ=2
1780 PN=6
1790 ZN=0:ZM=1.9999
1800 PC=0:REM black
1810 BC=7:REM white?
1820 F$="1+COS((X+Y)/(LOG(ABS(X*Y+0.5))))"
1830 GOSUB 2330
1840 X1=-7
1850 X2=7
1860 Y1=-17.4
1870 Y2=17.4
1880 ZS=50
1890 RZ=2
1900 PN=7
1910 ZN=-0.1:ZM=0.8999
1920 PC=0:REM black
1930 BC=7:REM white?
1940 F$="Y*X*X/(Y*Y+X*X*X*X)+0.4"
1950 GOSUB 2330
1960 X1=-3
1970 X2=3
1980 Y1=-3
1990 Y2=3
2000 ZS=10
2010 RZ=1
2020 PN=8
2030 ZN=-0.7022:ZM=4.7021
2040 PC=6:REM magenta
2050 BC=0:REM black
2060 F$="Y*X*(X*X-Y*Y)/(X*X+Y*Y)+2"
2070 GOSUB 2330
2080 X1=-4
2090 X2=6
2100 Y1=-3
2110 Y2=5.7
2120 ZS=32
2130 RZ=2
2140 PN=9
2150 ZN=-0.0985:ZM=3.0999
2160 PC=7:REM white?
2170 BC=0:REM black
2180 F$="3*EXP(-(SQR(X*X+Y*Y)))+0.1*COS(X*Y)"
2190 GOSUB 2330
2200 X1=-2
2210 X2=3
2220 Y1=-3
2230 Y2=5.7
2240 ZS=80
2250 RZ=1
2260 PN=10
2270 ZN=-0.5217:ZM=0.9216
2280 PC=6:REM blue
2290 BC=0:REM black
2300 F$="SIN(X*Y)*EXP(-(X*X+Y*Y)/9)+0.2"
2310 GOSUB 2330
2320 GOTO 1120
2330 NY=RZ*87
2340 NX=RZ*50
2350 MODE 1
2360 VDU 19,3,PC,0,0,0
2370 VDU 19,2,BC,0,0,0
2380 DX=(X2-X1)/NX
2390 DY=(Y2-Y1)/NY
2400 H0=0
2410 K1=58
2420 K2=Y2-Y1
2430 K3=90
2440 K4=174
2450 K5=191
2460 K6=X2-X1
2470 FOR X=X1 TO X2 STEP DX
2480 H0=100*(X-X1)/K6
2490 NH=-1
2500 FOR Y=Y1 TO Y2 STEP DY
2510 ZZ=EVAL(F$)
2520 V=-ZZ*ZS-(Y-Y1)/K2*K1+K3+H0
2530 NH=NH+1
2540 H=H0+NH*K4/NY
2550 IF V<0 OR V>K5 THEN GOTO 2610
2560 GCOL 0,3:REM HCOLOR=PC
2570 PLOT 69,4*H,1024-4*V
2580 PLOT 0,0,-4
2590 GCOL 0,2:REM HCOLOR=BC
2600 PLOT 5,4*H,0
2610 NEXT Y
2620 NEXT X
2630 G=GET
2640 RETURN
```

### Re: "Plotpourri" graphics demos in Basic for Apple II

Excellent - thanks!

### Re: "Plotpourri" graphics demos in Basic for Apple II

No problem. It was good learning BBC BASIC again — though those VDU commands must've made sense to someone at the time! Matrix Brandy BASIC has really good compatibility with the original, and is much faster for me to develop on. The code pasted into b-em and ran first time.

The only real change I had to make to the structure of the programme was using

The only real change I had to make to the structure of the programme was using

*EVAL()*rather than redefining*FN X*for each plot. BBC BASIC doesn't allow you to redefine functions, unlike most other dialects.### Re: "Plotpourri" graphics demos in Basic for Apple II

I happened to notice a slight error while porting scruss' version to the TRS-80 Model 3+4 with their optional hi-res board:

The last 6 entries of the ON GOTO are short by 10. Line should read:

The last 6 entries of the ON GOTO are short by 10. Line should read:

Code: Select all

`1110 ON PN GOTO 1120,1240,1360,1480,1600,1720,1840,1960,2080,2200`

### Re: "Plotpourri" graphics demos in Basic for Apple II

Thank you - that's most bizarre!

### Re: "Plotpourri" graphics demos in Basic for Apple II

Just stumbled upon this thread, and I'm going to throw in a small suggestion.

Add the line:
Won't make much of a difference on the Beeb (may look tidier as the text cursor isn't showing) but it makes an appreciable speed-up in Matrix Brandy.

Add the line:

Code: Select all

`2355 VDU23,1,0,0;0;0;0;`

Matrix Brandy BASIC VI with SDL, Teletext and Networking for Linux (work in progress)

### Re: "Plotpourri" graphics demos in Basic for Apple II

Thanks! That did make it a lot faster.

Here's a JSBeeb version:

https://bbc.godbolt.org/?autorun&loadBa ... BRANDY.bas

or if you just want the source:

https://gist.github.com/scruss/a0802027 ... d3cff66ae0

Here's a JSBeeb version:

https://bbc.godbolt.org/?autorun&loadBa ... BRANDY.bas

or if you just want the source:

https://gist.github.com/scruss/a0802027 ... d3cff66ae0