tschak909 Posted September 24, 2016 Share Posted September 24, 2016 As can be inevitable while developing a VCS game, I'm finding that some of my routines (particularly the joystick and collision routines) are becoming too big to loop. I've managed to mitigate this by breaking the routines up into functional subroutines, but each JSR/RTS pair takes 13 cycles each time...is there a more sane/better pattern to use? (for background, as I am working on Dodgeball, I am adding a very pivotal play case, the ability for an opponent to catch the other player's ball, so that they can potentially be carrying it, and their own ball...right now, this is involving lots of checking of the opposing ball flags for each player (I copy to a temp var and BIT check it, to try and save some space, oh how I wish BIT had an indexed address mode), and depending on how it's set, to flip my X register (which carries the current player being acted upon) to deal with the opposite player's missile, instead... this quickly creates a big ol' bowl of pasta...and blows up the size of the loop to quickly be too big to branch...) -Thom Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted September 24, 2016 Share Posted September 24, 2016 If you only use subroutines for cleaner code (and not for multiple calls), you can use macros instead. That saves you the 12 cycles of JSR/RTS. Quote Link to comment Share on other sites More sharing options...
Omegamatrix Posted September 24, 2016 Share Posted September 24, 2016 For the interim you can inline it all (macros or no macros) and then check a condition to break the loop with a jump behind it to re-loop. .loopChecking: ;....code here bne .exit jmp .loopChecking .exit: That's the simple way of handling code blocks which span over half a page. From there it is refactoring until you can use a branch instead of a jump which would save 3 bytes in this case ( you wouldn't need the "bne .exit" or "jmp .loopChecking", just "beq .loopChecking". You will find a lot of times during refactoring that it is possible to move code around so that the branches take less then a page. Something like this: .earlyBranch: ; more code bne .rejoinRoutine RoutineEntry: ; some code bcs .earlyBranch .rejoinRoutine: ; remaining code That works good when you are JSRing to the whole routine. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 24, 2016 Author Share Posted September 24, 2016 oh, nice... cool... Yeah, right now, I'm doing a near branch to jump, until I can get the routine working exactly as I want, then I'll start chopping and shuffling bits around... -Thom Quote Link to comment Share on other sites More sharing options...
tschak909 Posted September 24, 2016 Author Share Posted September 24, 2016 (btw) I am forever impressed at the simultaneous willingness to help others, and the quality of the help to other users on this forum. Most places really aren't like this. -Thom 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.