Boing ball BASIC demo

new graphics/music demos - bitshifters, 0xc0de, The Master + others
User avatar
tricky
Posts: 4676
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Boing ball BASIC demo

Post by tricky » Mon Aug 03, 2020 5:06 pm

The aliens never move in my AstroBlaster game either ;)

https://youtu.be/-9X8fRGjmJ8 best watched in 720p on a 50Hz monitor.

User avatar
kieranhj
Posts: 921
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Boing ball BASIC demo

Post by kieranhj » Mon Aug 03, 2020 6:23 pm

It couldn’t be in BASIC but on a Master you could do this at 50Hz with single pixel horizontal & vertical movement in MODE 2 by using vertical rupture to scroll vertically one scanline at a time, plus SHADOW RAM to offset a second copy of the ball by one pixel.

For the background you could make a fixed checkerboard of reasonable resolution using stable raster to twiddle the ULA palette register (or flash bit) as many times as possible on every line. That’d leave 15 colours for the rotation animation to get it nice and smooth, perhaps a couple less if you want the shadow.

EDIT: PS. There’s something lovely about seeing it done in one screenful (or Tweet!) of BASIC though.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
SimonSideburns
Posts: 564
Joined: Mon Aug 26, 2013 9:09 pm
Location: Purbrook, Hampshire
Contact:

Re: Boing ball BASIC demo

Post by SimonSideburns » Mon Aug 03, 2020 7:16 pm

steve3000 wrote:
Sun Jul 26, 2020 11:46 pm
It reminds me of a much simpler but larger (I think?) spinning ball demo, possibly a type-in from Micro User BITD (wasn't the Beebug one above). It took a very long time to render, so I remember 'optimising' it during computer club at school, by dumping the final rendered screen to the econet for instant-load and then went round loading it up on a whole room of Beebs...
That program was indeed called SPINNER. It is from The Micro User. Specifically Volume 7, Issue 10, December 1989.

If you have a Master or an Archimedes, or the GXR ROM installed you can edit the listing and remove the REM commands from certain lines of the listing in order to speed it up. It draws pretty quickly in those cases. Otherwise it's about five minutes or so of waiting for the various semi-circles to draw, even though you can't see half of them due to the way the palette is set up.

After that it's pretty much palette switching.

Here's the code:

Code: Select all

   10REM > Spinner
   20REM by Jim Burdus
   30REM (c) The Micro User
   40MODE2
   50REM >> Archimedes series >>
   60REM MODE12
   70VDU23,1,0;0;0;0;0;
   80VDU19,0,4;0;19,1,0;0;19,2,7;0;
   90VDU19,3,0;0;19,4,1;0;19,5,1;0;
  100VDU19,6,1;0;19,7,1;0;19,8,7;0;
  110VDU19,9,7;0;19,10,7;0;19,11,7;0;
  120VDU19,12,3;0;
  130PROCbackground:PROCstars
  140y%=253:GCOL0,1
  150PROCell(640,200,y%,162):K%=-11
  160VDU29,0;0;24,640;0;1279;1023;
  170FOR x%=285 TO 0 STEP-SQR(285-x%)-1
  180J%=7-SQR(285-x%)MOD8+4:GCOL 0,J%
  190IF J%<>K% IF ABSx%>32 PROCell(640,512,x%-32,y%)
  200K%=J%:NEXT
  210VDU29,0;0;24,0;0;640;1023;:K%=-1
  220FOR x%=285 TO 0 STEP-SQR(285-x%)-1
  230J%=SQR(285-x%)MOD8+4:GCOL 0,J%
  240IF J%<>K% IF ABSx%>32 PROCell(640,512,x%-32,y%)
  250K%=J%:NEXT
  260L%=0:B%=4:dir=1:spd%=5
  270REPEAT:*FX19
  280FOR C%=0 TO 7
  290IF C%<4 VDU19,(C%+L%)MOD8+B%,1 ELSE VDU19,(C%+L%)MOD8+B%,7
  300NEXT
  310T%=TIME+spd%
  320REPEAT UNTIL TIME>T%
  330IF INKEY-122 dir=1
  340IF INKEY-26 dir=-1
  350IF INKEY-82 dir=0
  360IF INKEY-58 IF spd%>0 spd%=spd%-1
  370IF INKEY-42 IF spd%<40 spd%=spd%+1
  380L%=(L%+dir)MOD8:IF L%=-1 L%=7
  390UNTIL FALSE
  400:
  410DEFPROCbackground
  420VDU 29,640;512;:GCOL0,2
  430FOR X=-10000 TO 10000 STEP 400
  440MOVE 0,100:MOVEX-100,-512
  450PLOT 85,X+100,-512:NEXT:GCOL0,2
  460PROCfill(-640,0,1280,512)
  470Y=-8:YM=1.2:F=0:GCOL 3,2
  480REPEAT F=NOTF
  490IF F PROCfill(-640,Y,1280,Y*YM-Y)
  500Y=Y*YM:UNTIL Y<-600:GCOL 0,1
  510PROCfill(-640,-30,1280,512)
  520VDU29,0;0;:ENDPROC
  530:
  540DEF PROCfill(X%,Y%,x%,y%)
  550REM >> Master series >>
  560REM MOVE X%,Y%:PLOT101,x%,y%:ENDPROC
  570REM >> Archimedes series >>
  580REM RECT.FILL X%,Y%,x%-X%,y%-Y%:ENDPROC
  590IF Y%>y% t%=y%:y%=Y%:Y%=t%
  600FOR Q%=Y% TO y% STEP 4
  610MOVE X%,Q%:DRAW x%,Q%:NEXT
  620ENDPROC
  630:
  640DEF PROCstars:LOCAL L%
  650GCOL 0,12:FOR L%=1 TO 250
  660PLOT69,RND(1280)-1,RND(524)+500
  670NEXT:VDU26,29,0;0;:ENDPROC
  680:
  690DEF PROCell(X%,Y%,M%,N%)
  700REM >> Master series >>
  710REM MOVE X%,Y%:MOVE X%+M%,Y%
  720REM PLOT 205,X%,Y%+N%:ENDPROC
  730REM >> Archimedes series >>
  740REM ELLIPSE FILL X%,Y%,M%,N%:ENDPROC
  750LOCAL CA,SA,Ct,St,Ca,Sa,Cp,Sp
  760LOCAL A%,x%,y%,S%,T%:S%=60
  770Ct=COSRADT%:St=SINRADT%
  780Ca=COSRAD(360/S%):Cp=1
  790Sa=SINRAD(360/S%):Sp=0
  800MOVE M%*Ct+X%,M%*St+Y%
  810FOR A%=1 TO S%
  820CA=Cp*Ca-Sp*Sa:SA=Sp*Ca+Cp*Sa
  830x%=M%*Ct*CA-N%*St*SA+X%
  840y%=M%*St*CA+N%*Ct*SA+Y%
  850MOVE X%,Y%:PLOT 85,x%,y%
  860Cp=CA:Sp=SA:NEXT:ENDPROC
Just remember kids, Beeb spelled backwards is Beeb!

cmorley
Posts: 1319
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Boing ball BASIC demo

Post by cmorley » Mon Aug 03, 2020 7:39 pm

SimonSideburns wrote:
Mon Aug 03, 2020 7:16 pm
After that it's pretty much palette switching.
As was the original Amiga boing ball. I think it is ace to see a boing ball pretty much as good as the Amiga's original CES one on a model B :)

http://amiga.lychesis.net/special/Color ... Boing.html

Kweepa
Posts: 28
Joined: Mon Dec 16, 2013 11:45 pm
Contact:

Re: Boing ball BASIC demo

Post by Kweepa » Tue Aug 04, 2020 2:58 pm

I like the keyboard control in SPINNER. That's a nice touch.
The screen tearing as the palette changes could be removed with just a little rearrangement of the code...

drfloyd
Posts: 380
Joined: Tue Jun 09, 2020 3:36 pm
Contact:

Re: Boing ball BASIC demo

Post by drfloyd » Wed Aug 05, 2020 11:45 am

Kweepa wrote:
Mon Aug 03, 2020 3:06 pm
Yeah, the ball is made up of 8 different colours, so the ball rotation is in four steps.
Then, the vertical lines of the background grid are two different colours.
So in total there are 13 used colours (8 for the ball, 1 cyan background, 1 blue shadow, 2 vertical grid lines, 1 horizontal grid line).
And as Big Ed says, the screen base address is updated to move the ball around.
Line 4 calculates the new screen start address A% (actually it's the address divided by 8 ). &600 is the original base address (&600 x 8 = &3000). X% is calculated on line 5 - this just bounces back and forth so it moves the screen horizontally. 80*INT(U%*2.5-U%*U%*.1) moves the screen in a parabola vertically (a parabola has the form Ax^2 + Bx + C).
Then line 5's VDU 23,0,12,A%/256...23,0,13,A%... sets the screen base address.

Yep, 100% BASIC.
So incredible... best basic demo in 5 lines EVER

Never seen that on C64, ATARI XL, CPC or Spectrum in pure basic !

Kweepa
Posts: 28
Joined: Mon Dec 16, 2013 11:45 pm
Contact:

Re: Boing ball BASIC demo

Post by Kweepa » Wed Aug 05, 2020 3:24 pm

tricky wrote:
Mon Aug 03, 2020 5:06 pm
The aliens never move in my AstroBlaster game either ;)
Lovely!

drfloyd
Posts: 380
Joined: Tue Jun 09, 2020 3:36 pm
Contact:

Re: Boing ball BASIC demo

Post by drfloyd » Sat Aug 08, 2020 6:46 pm

so it should be easy to shoot them :mrgreen:

User avatar
oss003
Posts: 3365
Joined: Tue Jul 14, 2009 12:57 pm
Location: Netherlands
Contact:

Re: Boing ball BASIC demo

Post by oss003 » Sun Aug 23, 2020 4:20 pm

Looks like the Boing ball also runs in Atom Basic .....

boing.png

I did have problems with the ball draw code because in the BBC demo it uses the rectangle fill routines and these are very difficult to convert to Atom Basic so that's why I use a screenshot.

This is CLEAR4 monochrome with a 1/60 sec delay: https://www.youtube.com/watch?v=UwUJEG-0MUw
This is CLEAR4 colour with a 1/60 sec delay: https://www.youtube.com/watch?v=-MYNS9XCFvQ
This is CLEAR4 colour without delay: https://www.youtube.com/watch?v=VznaMx9dihI

It only runs on an Atom with a GODIL display ....

Greetings
Kees

Post Reply

Return to “new projects and releases: demoscene”