shazz Posted August 14, 2013 Share Posted August 14, 2013 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 ! source6b_en.bin source6b_en.asm Quote Link to comment Share on other sites More sharing options...
Joe Musashi Posted August 14, 2013 Share Posted August 14, 2013 - sprites go faster left to right than right to left.... In isgoingRight you need to clear the carry flag (CLC) before ADD. Likewise in isgoingLeft you have to set the carry flag (SEC) before SUB. In your code the carry flag is always set, so it subtracts 1 but adds 2. Quote Link to comment Share on other sites More sharing options...
shazz Posted August 14, 2013 Author Share Posted August 14, 2013 ah !!! it fixes the speed issue ! thanks ! But it still glitches on the left side... source6b_en.asm source6b_en.bin Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted August 14, 2013 Share Posted August 14, 2013 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. Quote Link to comment Share on other sites More sharing options...
shazz Posted August 14, 2013 Author Share Posted August 14, 2013 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.