Jump to content
IGNORED

Issues with sprite position on left side


shazz

Recommended Posts

Hi,

 

I have a strange bug I can't explain, I coded a fairly simple piece of code which display the 2 sprites (x3, all in a row separated by 8 pixels, so, close) and move them right then left then right...

And I've got 2 strange issues :

- when sprites should be drawn let say in the 10 first left pixels it glitches (even if I comment the movement code and draw them directly), I tried 2 different sprite positionning routine (using table or computing the coarse/fine displacement), same results.

- sprites go faster left to right than right to left....

 

If somebody can help.... glitches in the screenshot.

 

Thanks in advance...... I feel dumb !

post-27939-0-16499900-1376505555_thumb.png

source6b_en.bin

source6b_en.asm

post-27939-0-28307800-1376505611_thumb.png

Link to comment
Share on other sites

This is the routine I use:

 

PosObject:   ; A holds X value
       sec ; X holds object, 0=P0, 1=P1, 2=M0, 3=M1, 4=Ball
       sta WSYNC
DivideLoop
       sbc #15        ; 2
       bcs DivideLoop ; 2    4
       eor #7         ; 2    6
       asl            ; 2    8
       asl            ; 2   10
       asl            ; 2   12
       asl            ; 2   14
       sta.wx HMP0,X  ; 5   19
       sta RESP0,X    ; 4   23 <- set object position
       rts

 

There's another problem in your main loop - you're updating GPR1 too late.

ScanlineLoop
   TXA            ; 2 (7)
   CMP #(226-SPRITE_POSY)    ; 2 (9)    -> draw if at the v pos
   BCS .SkipDraw        ; 2 (11)

   TYA            ; 2 (13)
   BEQ .SkipDraw        ; 2 (15)
   LDA Sprite0-1,Y        ; 4 (19)
   STA GRP0        ; 3 (22)

   LDA Sprite1-1,Y        ; 4 (26)
   STA GRP1        ; 3 (29)

   DEY            ; 2 (31)

.SkipDraw
   STA WSYNC        ; 3 (34)

   ;*********************** scanline boundary

   DEX             ; 2 (2)
   BNE ScanlineLoop    ; 2+1 (5)

 

Look at the TV Timing Diagram. TIA starts drawing pixels at TIA Clock count 69. 3 TIA Clock Counts = 1 6507 Cycle. You're updating GRP1 at cycle 29 which is TIA Clock Count 87 (18 pixels too late).

 

Move the WSYNC to the start of the loop gives you more cycles during the time critical horizontal blank time.

ScanlineLoop:
   STA WSYNC
   CMP #(226-SPRITE_POSY)    ; 2  2
   BCS .SkipDraw              ; 2  4
   TYA                          ; 2  6
   BEQ .SkipDraw              ; 2  8
   LDA Sprite0-1,Y              ; 4 12
   STA GRP0                  ; 3 15
   LDA Sprite1-1,Y              ; 4 19
   STA GRP1                  ; 3 22
   DEY                          ; 2 24
   DEX                       ; 2 26
   TXA                       ; 2 28
   BNE ScanlineLoop          ; 3 31

 

Tip - always end you labels with : so that you can find them without having to wade thru all the the JSRs, JMPs and branches that target the label.

Link to comment
Share on other sites

Darrel, you're the man !

 

You spot the 2 issues... damn, the PosObject routine I was using is bugged on the left side... with yours it works perfectly...

And dooooh I took the time to comment the timing of my scanline loop and I did not check the timings with the GRPx registers.... so dumb..... shame on me.

And another CLC and TXA were missing too... I really need to take care of any ADC/SBC I can write...

 

And I added ":", you're right ;-)

 

in case of, if it can help anybody, the working source code.

 

thanks you saved my night !

source6b_en.asm

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