Reputation: 101
How do I wait x amount of time in basic 6502? I am on VICE xpet, and I would like to print a character, wait a little, then delete it, and repeat for a while, as a sort of status indicator. The only problem is that it deletes to fast so the indicator never shows up. I've tried looking for such a command on the reference, but there is nothing for just flat out waiting a little bit. I know that if I make a huge for loop I may be able to slow the machine down enough to do it by brute force, but I'd rather avoid such if possible. Is there not a better way? Thanks!
Upvotes: 2
Views: 2557
Reputation: 937
You can refer to the system variable TI for timing purposes. Value of the variable incremented automatically in 1/60 seconds. It will not be perfect but it works.
Below example will print current value of TI for each second:
10 PRINT "START " TI
20 T0=T1
30 IF TI-T0>=60 THEN PRINT TI;TI-T0 : GOTO 20
40 GOTO 30
Upvotes: 5
Reputation: 2836
It's been decades since I've programmed on a 6502 (C-64/VIC-20) but I'm pretty sure even their version of BASIC had the keyword TIMER. If memory serves, it counts milliseconds, but I could be wrong. You might have to play with it. Set a variable equal to TIMER, do a for/next loop to take up some time, then check its value again. Once you figure out how many ticks occur in a second, you'll be able to make that a constant and then loop until variable = timer start plus constant ticks per second (first setting variable to timer before loop, of course).
Upvotes: 0