Jump to content
IGNORED

Sprite timing question


Recommended Posts

Hi everyone!

 

I have been trying my hand at writing a little bit of code after reading through most of the "2600 programming for Newbies" but I ran in to a problem with the positioning for my sprites. In trying to test my knowledge I wanted to simply draw box (P0) on a predefined position on the screen. But my timing seemed off. I wrote some code to experiment with timing and RESP0 but it seems to contradict what I read. Can some one help me?

 

After the vertical sync I wrote this to set the player position

sta WSYNC
        REPEAT 15
        nop
        REPEND
        sta RESP0

Now from what I read this should take 15*2*3 = 90 colour cycles. Which should position the player at 90-68 = 22.But what gets drawn is this:

 

470380035_Atari2600test.thumb.png.e7c29cc86e1e721ab140f49270fb1ca4.png

(The white lines are the most left and right pixel of the player. The rest is just playfield for help counting pixels)

 

So I'm off by what seems like 5 cpu cycles. Can anyone explain what goes wrong in my calculations?

Thanks in advance!

Link to comment
Share on other sites

You left out the 3 cycles for sta RESP0 - (15*2 + 3) * 3 =  99.

As for the rest of the difference I believe it's caused by a propagation delay within TIA, but don't know specifics.

 

I do know the results are slightly different for the ball and missiles, I cover that in Step 11 - add the ball object of my tutorial:

Quote

I then modified RandomLocation to set all objects to the same location for comparision:


RandomLocation:
...
    ; for alignment test, set to (100, 100)
        lda #100
        sta ObjectX,x
        sta ObjectY,x
        rts
 

 

This revealed a minor quirk with TIA - namely that when objects are set to the same X position, missiles and the ball end up 1 pixel to the left of where a player ends up (player1 is the green square and it's directly on top of the red ball).

blogentry-3056-0-47300800-1405117472_thumb.png

 

This is a known issue and the solution is to increase the X value by 1 to compensate.

 

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