'TENiS', 3D ball game, modified for BB4W/BBCSDL

Discussions related to graphics (2D and 3D), animation and games programming
p_m21987
Posts: 177
Joined: Mon 02 Apr 2018, 21:51

'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by p_m21987 »

Hello,

Last night I adapted a game I wrote for ARM BBC BASIC for use with BBCSDL. I posted it on the old forum, just before it got taken down.
I thought I'd post it again here. Edit: But, regrettably, the file for this program has been lost.

While I'm at it, I'd like to ask about sound. I had sound effects in this game, but I disabled them because there seemed to be a long delay from asking for the sound, and hearing the sound actually get played. Is there a way to make sure the sounds get played instantly?

Regards,
- PM
Last edited by p_m21987 on Wed 26 Dec 2018, 16:27, edited 1 time in total.
guest

Re: 'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by guest »

Patrick M wrote: Mon 02 Apr 2018, 21:55 Is there a way to make sure the sounds get played instantly?
Instantly? No. Sounds have to be buffered into 'packets' before they can be sent to the OS, so the absolute minimum delay will be one packet, and in practice it will be more. If you use BBC BASIC's SOUND statement the packet duration depends on the *TEMPO setting; at the default value (*TEMPO 5) it is approximately 1/20 second and at the fastest setting (*TEMPO 1) approximately 1/100 second (220 samples at 22050 Hz in BB4W, 441 samples at 44100 Hz in BBCSDL, or when the HQSOUND library is used in BB4W).

So, when you are using the SOUND statement at least, the best that you can do is to set *TEMPO 1 which will reduce the latency to a minimum. However a word of caution; whilst in my experience this is always safe in BBCSDL, and it's often OK in BB4W too when running on a modern fast PC, setting the tempo this fast risks producing stuttery sound (or worse) on an older PC or a PC with slow audio hardware.

Also bear in mind that all this assumes that the SOUND queue is initially empty. If there are some notes/sounds queued or already playing on that channel, the delay between executing the SOUND statement and the actual sound being heard may of course be much greater (but that at least is under your control).

Richard.
guest

Re: 'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by guest »

admin wrote: Mon 02 Apr 2018, 22:17the best that you can do is to set *TEMPO 1
Here's a trivial program (compatible with BB4W and BBCSDL) that will indicate what the delay is on your particular machine and version of BBC BASIC:

Code: Select all

      *TEMPO 1
      GCOL 4,0
      x% = @vdu%!208
      y% = @vdu%!212
      SOUND 1,0,0,0
      REPEAT
        WAIT 200
        RECTANGLE FILL x%,y%,40,40
        SOUND 1,-15,200,2
        WAIT 4
        RECTANGLE FILL x%,y%,40,40
      UNTIL FALSE
Richard.
roy
Posts: 31
Joined: Mon 02 Apr 2018, 15:48

Re: 'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by roy »

Hi
I'v noticed that some programmers uses basic key words as variables and it must work for them. When I run TENiS I get Syntax error at 5990. Which is understandable as 'by' is a basic key word, but I'm just wondering how some programmers get away with it. :?

Regards Roy

Code: Select all

 5970 
 5980 rem: Ball starting position
 5990 bx=W/2: by=H/2: bz=1000
 6000 

guest

Re: 'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by guest »

roy wrote: Fri 06 Apr 2018, 17:41I'm just wondering how some programmers get away with it. :?
Traditionally BBC BASIC keywords must be in capital letters, so whereas BY is a keyword, by isn't. It is possible to override that default in BB4W/BBCSDL but it's highly non-standard and I strongly recommend that you don't. At the wiki it is explicitly stated that any code listed there must use CAPITAL keywords, and if this forum had rules that would be one of them too!

Richard.
roy
Posts: 31
Joined: Mon 02 Apr 2018, 15:48

Re: 'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by roy »

That's that mystery sorted :)

Thanks Richard
p_m21987
Posts: 177
Joined: Mon 02 Apr 2018, 21:51

Re: 'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by p_m21987 »

Sorry Roy. I wasn't aware that "BY" was actually a BASIC keyword - I'm used to Acorn/Sophie Wilson's BBC BASIC which probably doesn't have it. (or maybe it does have it, and I didn't know about it - I don't claim to be an expert who knows about every single feature of BBC BASIC)
In this context, I wrote 'by' meaning 'ball_y_coordinate'.

Still, the program worked for me while I was adapting it for BBCSDL, so I'm not sure why it's having problems for you.

Regards,
Patrick
guest

Re: 'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by guest »

Patrick M wrote: Sat 07 Apr 2018, 21:51I'm used to Acorn/Sophie Wilson's BBC BASIC which probably doesn't have it.
It does, but probably only for the last 30 years so it's a relative newcomer! ;) It's definitely in BASIC 5, not sure about BASIC 4; you can find the relevant entry in the manual for Acorn/Sophie's BASIC under Relative coordinates and BY here.

Richard.
roy
Posts: 31
Joined: Mon 02 Apr 2018, 15:48

Re: 'TENiS', 3D ball game, modified for BB4W/BBCSDL

Post by roy »

Hi Patrick

It's me because I like to use all lower case. As Richard said 'Traditionally BBC BASIC keywords must be in capital letters'

Regards Roy