Jump to content

Photo

cycle count & batari Basic


8 replies to this topic

#1 jeffry OFFLINE  

jeffry

    Space Invader

  • 15 posts

Posted Tue Jun 12, 2018 9:57 PM

Can Batari Basic read the cycle counts?

 

What I would like is to run 2 subroutines then display a 1 or 2 depending on which one is faster and also display the differnce in the score.

 

Then I could paste code into the 2 subroutines and compare them.

 

So is something like this possible?  and if so how do I read the cycles? 

 



#2 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • 754 posts
  • Location:Orlando, FL US

Posted Wed Jun 13, 2018 8:05 PM

You don't need to write any code for this. Just use the stella debugger. Set a break point before and after the section of code you want to profile and take note of the "F. Cycle" value at each breakpoint.

 

Of course, this will only tell you how many cycles a routine takes for whichever code path is executed. It may not necessarily reflect the worst case scenario or the average. You'd really need to analyze the generated assembly listing to determine that.



#3 jeffry OFFLINE  

jeffry

    Space Invader

  • Topic Starter
  • 15 posts

Posted Thu Jun 14, 2018 7:25 PM

Thanks ! 

 

Now, how do I go about setting the breakpoint? 



#4 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • 754 posts
  • Location:Orlando, FL US

Posted Thu Jun 14, 2018 10:22 PM

Now, how do I go about setting the breakpoint? 

 

This post should help.



#5 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 9,209 posts

Posted Mon Jul 23, 2018 12:35 PM

Actually, it would be nice to be able to count cycles within batari BASIC.

 

I have tried various uneducated ways to measure the difference between PAL and NTSC performance so I can automatically switch between PAL and NTSC colors upon starting my games.

 

Needless to say I've failed so far.



#6 Karl G OFFLINE  

Karl G

    Dragonstomper

  • 561 posts

Posted Tue Jul 24, 2018 7:35 AM

I don't follow how counting cycles would be able to detect the difference between NTSC and PAL consoles?  If you are thinking frames/second, then that is a function of how the frames are generated by the programmer, not by the hardware itself.  If you mean the very slight difference in clock speed, you would need a point of reference to be able to compare speeds.

 

I believe some games on Melody boards use a timing chip to achieve the latter, but I don't know the details of how it works.



#7 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 9,209 posts

Posted Tue Jul 24, 2018 11:32 AM

I don't follow how counting cycles would be able to detect the difference between NTSC and PAL consoles?  If you are thinking frames/second, then that is a function of how the frames are generated by the programmer, not by the hardware itself.  If you mean the very slight difference in clock speed, you would need a point of reference to be able to compare speeds.

 

I believe some games on Melody boards use a timing chip to achieve the latter, but I don't know the details of how it works.

 

I always figured I could increment a counter per frame and end up with a different amount when running in PAL or NTSC mode.  I've tried putting this counter in the main loop and also tried when the vblank is triggered.

 

Maybe that's my fatal logical flaw :)

 

UPDATE:  I just read up on set debug cyclescore.  Thought it might be useful for counting cycles.  For my purposes the cycle count DOES change when you "set tv ntsc" or "set tv pal".  I guess this also brings up the fact that any code is gonna fail with PAL60 as the timings are NTSC.

 

http://www.randomter...ands.html#debug



#8 Karl G OFFLINE  

Karl G

    Dragonstomper

  • 561 posts

Posted Tue Jul 24, 2018 12:41 PM

Well, you can determine if bB is running in NTSC or PAL50 mode, I suppose - but you already know that because you set it yourself.

More generally, on the assembly side, the number of cycle per frame depends on the number of scanlines, and that is determined solely by how many you, the programmer generate, not by the underlay console type.

#9 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 9,209 posts

Posted Tue Jul 24, 2018 12:55 PM

I guess I should post my code that I used since it seems to directly address the original posters question :P  The for next loop is just and example piece of code.  You'd of course want to replace that with the routine you want to test for cycles used.

 

 

 set debug cyclescore
 set romsize 4k
 
main
 
 rem //** RUN YOUR CODE TO TEST HERE **//
 for a = 0 to 64
 next
 
 drawscreen
 goto main





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users