|
Post by evildragon on May 24, 2007 22:36:11 GMT -5
im writing a utility, and i need to end a loop after so many seconds.. for example, my loop just counts numbers as fast as it can, and it needs to stop itself.. at the moment, i just have the user stop it with "waitpadup", but that's no good for accurate results... (it's a simple benchmarking utility) here's my code so far.. 10 print " Sega MD/Genesis Benchmark" 20 print "" 30 print " Coded by 'evildragon'." 40 print "" 50 input " Press 'Start' when you are ready!" 60 counter=0 110 print "";counter;"" 120 counter=counter+1 125 waitpadup 130 goto 110 so when it's stuck in a loop like that, how can i stop it after 60 seconds? thanks! (im just learning, and i want this procedure to work exactly this way, cause im stubborn )
|
|
|
Post by evildragon on May 25, 2007 9:40:15 GMT -5
Actually, how about this, is it possible to see how many "VInts" have occured? Perhaps I can stop it after so many vints...
|
|
|
Post by Tom Maneiro on May 26, 2007 11:04:26 GMT -5
Why complex your life with a loop when you have the Sleep instruction?
'Sleep after 60 seconds sleep 60*60
...or if you still want the loop:
'loopy-de-loop way, using Sleep for i=1 to 60 do sleep 60 'do something? next
|
|
|
Post by evildragon on May 26, 2007 12:35:26 GMT -5
if i do it that way, with the loop, will the loop still be able to run as fast as it possibly can? it's a benchmark for the 68000, and it needs to count as fast as it can within 60 seconds...
|
|
|
Post by evildragon on May 26, 2007 12:41:46 GMT -5
ehh, should have tried first (and i may just register here so i can edit)...
the first one don't work, it just haults the whole benchmark and keeps it counting minutes instead of a CPU counter.. the second one just makes it count seconds...
for example, if i could somehow count vints, i wanted the loop to end after 60 vints, and therefore, give me a benchmark number..
for example, with the code i have right now, just a loop that can be stopped by a button, after 60 seconds, my genny counts 4868.. if it's in 50Hz mode, i score an even higher 7000--and something.. thing is, i dont want to have to hault it manually, because that's introducing human error..
|
|
|
Post by Tom Maneiro on May 26, 2007 13:06:31 GMT -5
If you check the BEX manual, you have two Sleep functions:
- Sleep: wait for VBlanks (60 VBlanks = 1 second) - Sleep2: wait for HBlanks
From v0.12 changelog:
|
|
|
Post by evildragon on May 26, 2007 13:20:03 GMT -5
If you check the BEX manual, you have two Sleep functions: - Sleep: wait for VBlanks (60 VBlanks = 1 second) - Sleep2: wait for HBlanks From v0.12 changelog: I did check the dev manual, but your forgetting something.. If I sleep the loop, so does the counting! thus the test is no longer valid, and all the CPU counter does, is count H Blanks or V Blanks, which is not what I wanted.
|
|
|
Post by evildragon on May 26, 2007 13:23:35 GMT -5
I don't think your understanding me..
I don't want to stop at VBlanks, I want to COUNT them, then END at a certain time..
for example, make the loop keep running, without interruption.. then, have another part of the program count how many verticals the TV goes through, and when it reaches a certain count, it then ends the loop...
If I just sleep it, that stops the loop, and all we have is a VBlank counter or an HBlank counter, which isn't what i want at all, that's not benchmarking..
|
|
|
Post by jlf65 on May 26, 2007 14:33:09 GMT -5
Try
10 print " Sega MD/Genesis Benchmark" 20 print "" 30 print " Coded by 'evildragon'." 40 print "" 50 on VBLANK gosub 1000 60 input " Press 'Start' when you are ready!" 70 counter=0 80 vblanks=0
100 counter=counter+1 110 if vblanks<120 goto 100 120 print "number of increments in 2 seconds is "; counter 130 end
1000 vblanks = vblanks +1 1010 return
I don't know if the on vblank needs restarting every vblank... that might need to be added to the routine at 1000. Basically, you want a vblank routine that increments a time value (called vblanks in this case). Then your code you are benching simply checks for a specific number of vblanks when looping.
|
|
|
Post by evildragon on May 26, 2007 15:14:38 GMT -5
Try 10 print " Sega MD/Genesis Benchmark" 20 print "" 30 print " Coded by 'evildragon'." 40 print "" 50 on VBLANK gosub 1000 60 input " Press 'Start' when you are ready!" 70 counter=0 80 vblanks=0
100 counter=counter+1 110 if vblanks<120 goto 100 120 print "number of increments in 2 seconds is "; counter 130 end
1000 vblanks = vblanks +1 1010 return I don't know if the on vblank needs restarting every vblank... that might need to be added to the routine at 1000. Basically, you want a vblank routine that increments a time value (called vblanks in this case). Then your code you are benching simply checks for a specific number of vblanks when looping. it didn't work, and i tried by restarting VBlank everytime, and still nothing... also fixed your if statement cause it didn't have a than, and the print statement was missing a ;"" at the end.. still didn't work.. i think im going to have to do this in assembly instead..
|
|