Page 1 of 1

Options for slowing down compiled basic

Posted: Tue Jan 22, 2019 9:37 am
by Jodo
Having completed writing about 80% of an arcade game I've compiled it in Hisoft Basic and now need to slow it down. I can do this with a Pause statement in the main loop and get it to the speed I require but is this good practice when Pause is interruptable?

Are there any other better options? My basic skills are, well, basic :D and the only other option I can think of is a For...Next loop.

Thanks!

Re: Options for slowing down compiled basic

Posted: Tue Jan 22, 2019 9:58 am
by Ralf
Yes, use FOR x=1 TO 1000:NEXT x ;) Won't get interrupted by keypress, unlike PAUSE

Re: Options for slowing down compiled basic

Posted: Tue Jan 22, 2019 9:58 am
by R-Tape
Have you considered a bit of in game BEEPer music? That can't be interrupted, and you could tailor it to the speed& mood you want.

Re: Options for slowing down compiled basic

Posted: Tue Jan 22, 2019 11:31 am
by Jodo
Ralf wrote: Tue Jan 22, 2019 9:58 am Yes, use FOR x=1 TO 1000:NEXT x ;) Won't get interrupted by keypress, unlike PAUSE
Thanks Ralf, I think I'll use this to get it where I want it for testing at least.
R-Tape wrote: Tue Jan 22, 2019 9:58 am Have you considered a bit of in game BEEPer music? That can't be interrupted, and you could tailor it to the speed& mood you want.
Thanks R-Tape for the reminder. I'd forgotten reading people use the sound to slow code down. Would it just be a case of calling a subroutine holding the music every lap of the main loop, and maybe use a counter in a computed goto to play the next note in the sequence? Or is there much more to it?

Re: Options for slowing down compiled basic

Posted: Wed Jan 23, 2019 4:43 pm
by Kweepa
If interrupts are still running, you could wait for the interrupt counter at 23672 to change, which it does every 1/50 seconds.

Re: Options for slowing down compiled basic

Posted: Fri Jan 25, 2019 8:10 pm
by Jodo
Kweepa wrote: Wed Jan 23, 2019 4:43 pm If interrupts are still running, you could wait for the interrupt counter at 23672 to change, which it does every 1/50 seconds.
Thanks Kweepa, I'll look into it. Not sure I'll be capable of implementing that though!

Re: Options for slowing down compiled basic

Posted: Fri Jan 25, 2019 10:15 pm
by Cosmium
Jodo wrote: Fri Jan 25, 2019 8:10 pm
Kweepa wrote: Wed Jan 23, 2019 4:43 pm If interrupts are still running, you could wait for the interrupt counter at 23672 to change, which it does every 1/50 seconds.
Thanks Kweepa, I'll look into it. Not sure I'll be capable of implementing that though!
If the interrupts are running, something like this should work (though I haven't written any BASIC for 30+ years, so pls forgive any syntax errors!):

10 LET LAST_FR = 0: REM clear last frame variable

main loop:
...
100 IF LAST_FR = PEEK 23672 THEN GO TO 100 : REM keep looping (ie. wait) if frame counter hasn't changed, ie. we're still on the same frame
110 LET LAST_FR = PEEK 23672 : REM store new frame for next time
...

This BASIC should delay the game by a max of one frame in the main loop.