Grevle Posted October 21, 2015 Share Posted October 21, 2015 Does the BCC and BCS commands work with the RTS ? so you give a bcc command, then it will branch when carry is clear, Can i then have a RTS in branch so that i returns to the BCC or must one use the JSR or similar command ? And also whats a smart and easy way to have a event counter, Lets say i want to control (in my case a Bat flying in a controlled flight path) within the vbi in assembler. i tried something like this but it doesnt seem to work: The MBU and MBR are for moving the bat up and to the right. 2044 LDX MULF2 ; Event counter2044 INX2044 CPX #52044 BCC MBU ; bat fly up as long as Mulf is less than 52044 CPX #102044 BCS MBR ; Comment here its supposed to move bat to right. but this doesnt work ( i messed up probably carry is already set ?)2044 RTS2044 MBU2044 DEC P0Y ; Equates for Player 0 Y pos2044 DEC P1Y ; Equates for Player 1 Y pos2044 DEC P0Y2044 DEC P1Y2044 RTS2044 MBR2044 INC PX ; Player X pos Counter2044 LDX PX2044 STX P0X ; Equates for player 0 X pos2044 STX P1X ; Equates for player 1 X pos2044 RTS Quote Link to comment Share on other sites More sharing options...
Rybags Posted October 21, 2015 Share Posted October 21, 2015 RTS is paired with JSR usually - JSR puts the return address onto the stack so that RTS will pull it and resume where the sub was called from. BCC or any other branch for that matter, as well as plain JMP - none of these put return info onto the stack. If you want to implement special conditions you just need to put more test/branches into your program. Generally the trick is to program your code such that the complexity of branches is minimized. Sometimes you can use tricky programming instead of branching. e.g. though this isn't exactly tricky. Incrementing a 16-bit integer you can either have. INC LOW BNE NO_INC1 INC HIGH NO_INC1 ; program continues... or LDA LOW CLC ADC #1 STA LOW LDA HIGH ADC #0 STA HIGH Probably not the best example, in this case the method of avoiding branches actually means more program code. Quote Link to comment Share on other sites More sharing options...
Grevle Posted October 21, 2015 Author Share Posted October 21, 2015 Ok. no wonder my programs behaves strangely sometimes then hehe. Thank you. I realy should know this by now, But you know, still learning about assembler. Quote Link to comment Share on other sites More sharing options...
Grevle Posted October 21, 2015 Author Share Posted October 21, 2015 Yes . Made it work now. Heres a screenshot .. the bat is flying... 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.