# "Demo Scene" programming

Page 1/3
| 2 | 3

When I was about 14 I was very interested into doing some cool demo stuff on the MSX. I didn't have enough knowledge back then on how to do all the math and how to create some effects. So I wanted to revisited them and see how to achieve them in basic.

We've all seen the raster bars/scrollers/starfields on the MSX.

But how are these effects achieved? And more importantly can we achieve them in basic although a bit slower)

I wanted to see if I could start with Moire patterns (Circles in this case)

```10 'Moire Circles
100 COLOR15,0,0:KEYOFF
101 'set Screen 5 and clear video memory on all pages
110 SCREEN5:FORI=0TO3:SET PAGE1,I:CLS:NEXTI:SETPAGE1,1
111 'set colors
120 COLOR=(2,7,7,7)
130 COLOR=(3,1,1,1)
131 'draw circles
140 FORI=0TO63
150 CIRCLE(64,64),I,((I/2)MOD2)+2
160 NEXTI
161 'let us do some page swapping magic to make the animation go `smoother`
170 A=2:B=3
180 FOR X=0 TO 32 STEP 1
190 SET PAGE B,A:CLS
200 COPY(0,0)-(127,127),1 TO (16,16),A
210 COPY(0,0)-(127,127),1 TO (X,X+8),A,OR
220 SWAP A,B
230 NEXT X
231 'all done
240 A\$=INPUT\$(1)```

The next effect is like horizontal Raster Bars. Due to screen swapping a sense of motion is created.

```100 'some sort of raster bars
110 COLOR15,0,0:KEYOFF
120 'set Screen 5 and clear video memory on all pages
130 SCREEN5:FORI=0TO3:SET PAGE1,I:CLS:NEXTI:SETPAGE1,1
131 COLOR=(2,1,1,1)
132 COLOR=(3,5,5,5)
140 'let us do some page swapping magic to make the animation go `smoother`
150 A=2:B=3
160 FOR I=0 TO 256 STEP .5
170 SET PAGE B,A
171 S=SIN(I/32)
180 LINE(128+S*I*.75,I/1.5)-(128+S*I*.75+4,192),15,BF
190 LINE(128+S*I*.75,I/1.5)-(128+S*I*.75,192),2,B
191 LINE(132+S*I*.75,I/1.5)-(132+S*I*.75,192),3,B
200 SWAP A,B
210 NEXT I
220 SET PAGE B,A:FOR I=0TO200:NEXT
230 SWAP A,B
240 IF INKEY\$<>CHR\$(32) GOTO 220
250 'all done```

That's cool. Have you tried running it in NestorBASIC, for instance?

I want to keep it as 'regular' basic as possible. I'm already using a turbo-R for this though.

The next effect isn't that spectacular due to missing vertical blank checks in basic. So I'll just called it "Broken VDP?"

```110 SCREEN5
120 FOR I=0 TO 7:COLOR=(2+I,7-I,I,7-I):NEXT I
130 FORI=0TO192:LINE(0,I)-(256,I),IMOD8+2:NEXTI
140 FOR I=0 TO 7:VDP(19)=I:VDP(24)=I:NEXT
150 GOTO 140```

keep em coming!

This time I try to play with Vampier rules

Here is very BASIC plasma animation:

```10 SCREEN 5
20 FOR Y=0 TO 211:FOR X=0 TO 255
30 PSET (X,Y),(SIN(X/22)+COS(Y/20)+SIN((X+Y)/19))*8AND15
40 NEXT X,Y
50 I=(I+1)AND15:COLOR=(I,0,0,0):COLOR=((I+1)AND15,7,7,7)
60 IF INKEY\$="" THEN 50
```

Takes a while, even when throttling, but this is very nostalgic.
The Dutch MSX Computer Magazine did have Kort en Kracht (short and powerful) in its haydays. This is just like that: A short listing which, if you give a look at for a split second and think not too much of it, but does something quite cool...

Such things are treasures for people who want to find out more tricks in Basic, so keep them coming...

Ah, my cuppa tea

You know, in Assembly you have the opportunity to do quick changes on every interrupt line. That fact is used to create raster and copper bars for example. In Basic you can't really do such thing.

Starfields are easy and in essence just moving pixels. Can be done in Basic. The same principle applies for good old text scrollers. Just moving pixels I suppose. It's those extra tricks like screenswapping that make such effects even bigger. Can be done in Basic as well. It's just, well.... slower.

Ok, this is only copy/paste from Copy-command Wiki page that I wrote earlier, but here is how you can make some Sierpinski triangles:

```10 ' Some Sierpinski-triangles
20 COLOR 15,0,0:SCREEN 5
30 FORI=RND(-5048) TO 6:PSET(RND(1)*255,RND(1)*211),RND(1)*13+2:NEXT I
40 FOR I=0 TO 211:H=IAND254:L=(IAND1)*2
50 COPY (1,H)-STEP(253,0) TO (L,H+2),,XOR
60 COPY (1,211-H)-STEP(253,0) TO (L,209-H),,XOR
70 NEXT I
80 A\$=INPUT\$(1)
```

I'm running the "Plasma animation" now. It has filled only about 20% of the screen so far. It looks a bit rough, not like 256X212 resolution in lots of other graphics screens. I wonder how long it takes to finish? It seems obvious to me that I won't be able to save this first screen, or perhaps there is a way someone could tell me about. Even then, I need to go on a shopping trip, so I may not want to leave my VG8235 running for several hours while I'm out.

Page 1/3
| 2 | 3