QL Tinkering

Helpful tips and guides, also new users can ask for help here.
User avatar
Andrew
Aurora
Posts: 889
Joined: Tue Jul 17, 2018 9:10 pm

Re: QL Tinkering

Post by Andrew »

qbits wrote: Sat Aug 17, 2024 9:21 pm Hi Steve,
The two options PAUSE and use of T_ON,T_START,T_COUNT,T_STOP,T_OFF both produce 20ms Delays across a wide range of platforms.
PAUSE is not a reliable method. PAUSE temporarily halts execution for the specified timeout number of frames (there are 50 frames per second in the UK and Europe, 60 frames per second in the US).
So PAUSE will produce 20ms delays in Europe and 16ms delays in US.
Also execution will continue at the end of the timeout OR if a key is pressed. This makes it totally unreliable for most of the games/programs that use the keyboard. That is exactly why I used the Timer in my games.


stevepoole
Aurora
Posts: 776
Joined: Mon Nov 24, 2014 2:03 pm

Re: QL Tinkering

Post by stevepoole »

Hi Folks,

Yes, Andrew, Using PAUSEs makes games or music programming very difficult when you begin.

Somebody recently mentioned that the User Manual states that KEYROW clears the keyboard queue. This is indeed not the case !

Just insert i$=INKEY$ in you innermost loop, before reading from KEYROW().... to clear the Queue satisfactorily. Regards, Steve.


qbits
Trump Card
Posts: 216
Joined: Sun Dec 11, 2016 3:32 pm

Re: QL Tinkering

Post by qbits »

Hi Stev and Andrew,
Where PAUSE and Simon Goodwin’s T_ON, T_START, T_COUNT, T_STOP , T_OFF maybe OK for Games (Andrew I see you use the later in your QStar and Pitman) whereas I think we all agree timing for Musical notes does require a different approach:

Andrew’s use of T_ON etc
515 DEFine PROCedure Delay(ms)
2520 LOCal t
2525 T_START 1
2530 REPeat l
2535 IF T_COUNT(1)>=ms THEN T_STOP 1: EXIT l
2540 END REPeat l
2545 END DEFine Delay

The DATE Timer method as I will refer to It, uses the QL Clock to determine a QL Platforms speed per second to Set a cycle count that can potentially be divided into milliseconds or a PAUSE lower than 20msec. Taking Stev’s suggestion and code we have a Function to return a QL Platforms cycle rate and a Procedure to execute a calculable Time Delay.

Steve Poole’s - QL Clock DATA Timer of fastStave6_bas
5310 DEFine FuNction ajust_timer
5320 LOCal forever,dd,get_set,ticks
5330 forever=1E15: dd=DATE
5340 REPeat get_set: IF dd<>DATE: dd=DATE: EXIT get_set
5350 FOR ticks=1 TO forever: IF dd<>DATE: EXIT ticks
5360 RETurn ticks:
5365 END DEFine

5380 DEFine PROCedure wait(hold)
5390 LOCal dd,delay: IF hold<1: hold=1
5400 dd=DATE: FOR delay=1 TO hold: IF dd<>DATE: END IF
5410 END DEFine

This executes as: BEEP 0,p1,p2,gx,gy:wait dr:BEEP ...where dr (hold) is a product of ticks*required msec Delay.

Thank you both Steve and Andrew this has been a rewarding development in going forward with QLSounds.
I guess the next challenge will be to develop a common QLSound DATA file format.

QBITS
Last edited by qbits on Mon Aug 19, 2024 8:45 am, edited 1 time in total.


stevepoole
Aurora
Posts: 776
Joined: Mon Nov 24, 2014 2:03 pm

Re: QL Tinkering

Post by stevepoole »

Hi Qbits, Andrew and All,

Yes, using the Date timer method, the adjust_timer and wait routines are not only fine for music, but also allow games to be made compatible on ANY platform, as they automatically adjust to processor speed and multitasking overheads.

After developing the method a few years ago, (and posting it on the Forum), much less tearing-out of hair when prototyping programs !

Please feel free to use it as you please. And thanks for posting your codes, Qbits, very promising indeed.... Regards, Steve.

______________________


qbits
Trump Card
Posts: 216
Joined: Sun Dec 11, 2016 3:32 pm

Re: QL Tinkering

Post by qbits »

Hi steve
I’m working the updates to QLSound so thanks for your code.
Checking out keywords and note HOLD seems to be one on my system.

QBITS


Post Reply