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 and the only other option I can think of is a For...Next loop.
Thanks!
Options for slowing down compiled basic
Re: Options for slowing down compiled basic
Yes, use FOR x=1 TO 1000:NEXT x Won't get interrupted by keypress, unlike PAUSE
Re: Options for slowing down compiled basic
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
Thanks Ralf, I think I'll use this to get it where I want it for testing at least.
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
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
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.
Cosmium
https://cosmium.itch.io/
https://cosmium.itch.io/