Jump to content
IGNORED

PEEK(632) vs. STICK(0)?


DEBRO

Recommended Posts

I'm guessing by misconception more than anything else.

 

PEEK(632) takes the same space as STICK(0) once the line is tokenized, 10 bytes. Atari BASIC doesn't put the function names in the program -- it stores a token byte for the function instead. You can save more space in the input line you type in with one over the other, but that only matters if you're cramming so much into a line you're up against the raw 3-line limit.

 

Speed-wise, the difference is negligible. I found at least one reference that says that PEEK(632) is faster -- http://www.atariarchives.org/pmgraphics/chapter5.php-- but the actual difference in the interpreter is tiny. PEEK() is faster by about a dozen machine cycles when executing a single BASIC statement takes thousands.

  • Like 2
Link to comment
Share on other sites

My thought was that STICK was quicker due to less complex FP numbers converting to 16-bit binary slightly faster. I suppose the advantage is lost given that Basic then has to add the result to 632 before doing the lookup.

 

One method that can be used to speed up Basic programs is using PTRIG to assist with horizontal movement. Since the paddle buttons are just stick left/right you can subtract one from the other to give the current direction delta - the result you end up with is -1, 0 or 1.

  • Like 1
Link to comment
Share on other sites

Variable access is slower than constants with Atari Basic at least. Not by a lot but enough to be an incentive to use constants in speed critical loops etc. The saving though is in memory, once a variable is referenced a few times the memory savings start to build up.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...