2

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!

Eight-Bit Guru
  • 9,756
  • 2
  • 48
  • 62
18AdrianoH
  • 101
  • 7
  • Something like Thread.sleep(x) in java. Thanks! – 18AdrianoH Apr 12 '17 at 15:15
  • 1
    Based on what @BillHileman wrote - take a look at: https://www.c64-wiki.com/wiki/TIME - there is a delay subroutine towards the bottom of the page. – Pawel Apr 12 '17 at 23:02
  • @18AdrianoH: You're getting great info here on SO, but in case you didn't know about it, there's also http://retrocomputing.stackexchange.com/. – Nick Westgate Apr 13 '17 at 02:03

2 Answers2

5

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
wizofwor
  • 917
  • 8
  • 25
0

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).

Bill Hileman
  • 2,798
  • 2
  • 17
  • 24