Cisano Posted November 29, 2021 Share Posted November 29, 2021 (edited) Hi, I have a problem. I created a macro for update GRP1 X coordinate. Not the positioning, but only the value. The code is executed during vertical blank time. Y is used inside the Macro. All works great. ldy #0 UpdateGRP1_Macro I tried to use the same code by a Subroutine. ldy #0 jsr UpdateGRP1 It doesn't work good. The sprite movement is not smooth. Is there something I don't know about these 2 way to use code? Thanks. Edited November 29, 2021 by Cisano Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 29, 2021 Share Posted November 29, 2021 Can you show some more code? What you describe should not happen. Quote Link to comment Share on other sites More sharing options...
Cisano Posted November 29, 2021 Author Share Posted November 29, 2021 lda FrqFrameGRPX and MaskOne,y bne .end lda XposGRP1,y cmp StartOne,y bne .other lda #1 sta CursorSpringOne,y jmp .opera .other ;lda XposGRP1,y cmp ArriveOne,y bne .opera lda #$ff sta CursorSpringOne,y .opera clc lda CursorSpringOne,y adc XposGRP1,y sta XposGRP1,y .end lda StartOne,y cmp ArriveOne,y bne exit sta XposGRP1,y exit rts The Macro has not the rts. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 29, 2021 Share Posted November 29, 2021 Looks fine. Since the code of a macro is included directly inside the code, this changes the following addresses. I suppose a page penalty is happening now. Quote Link to comment Share on other sites More sharing options...
Cisano Posted November 29, 2021 Author Share Posted November 29, 2021 Penalty? You mean extra cycles? Quote Link to comment Share on other sites More sharing options...
stepho Posted November 30, 2021 Share Posted November 30, 2021 Just some generic things to look for... 1. Jumping to the subroutine takes a few cycles. Returning also takes a few cycles. You said it is in the vertical blank code but is it time sensitive? 2. Storing the return address takes a few bytes of stack. Is the stack big enough? 3. Some bank switching schemes trigger off subroutine calls (ie when you write/read the return address in the first few elements of the stack). Quote Link to comment Share on other sites More sharing options...
Cisano Posted November 30, 2021 Author Share Posted November 30, 2021 (edited) 1. I set a timer and the vertical blank time is not all used. 2. yes it is 3. no bank switching for now I just moved the subroutine in another part of the cose, upper, and it works good. It is the normality or there are solutions? Thanks. Edited November 30, 2021 by Cisano Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 30, 2021 Share Posted November 30, 2021 (edited) 15 hours ago, Cisano said: Penalty? You mean extra cycles? Yup. Always when a branch or an indexed table access crosses a 256 bytes page the instruction takes one extra cycle. To check this during assembly I have written a simple macro: MAC CHECKPAGE IF >. != >{1} ECHO "" ECHO "ERROR: different pages! (", {1}, ",", ., ")" ECHO "" ERR ENDIF ENDM If your branch moves backward, put this behind the branch and provide the branch address. If it is a table, put it at the end of the table and provide the table address. Edited November 30, 2021 by Thomas Jentzsch 2 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.