lerugray Posted February 18, 2021 Share Posted February 18, 2021 (edited) Hello all, I'm currently teaching myself how to program the 2600 using the 8bit workshop tutorials. Currently, I am wondering how to slow down player movement. Here is the code I am currently using for player movement. ; Read joystick movement and apply to object 0 MoveJoystick ; Move vertically ; (up and down are actually reversed since ypos starts at bottom) ldx YPos lda #%00100000 ;Up? bit SWCHA bne SkipMoveUp cpx #2 bcc SkipMoveUp dex SkipMoveUp lda #%00010000 ;Down? bit SWCHA bne SkipMoveDown cpx #183 bcs SkipMoveDown inx SkipMoveDown stx YPos ; Move horizontally ldx XPos lda #%01000000 ;Left? bit SWCHA bne SkipMoveLeft cpx #16 bcc SkipMoveLeft dex SkipMoveLeft lda #%10000000 ;Right? bit SWCHA bne SkipMoveRight cpx #153 bcs SkipMoveRight inx SkipMoveRight stx XPos rts Normally, I am used to coding for the NES and I would be able to just DEX and NOP until the player slowed down, wondering what I would do here in this instance. Thank you! And here is a link to my current test project, took me all day yesterday how to figure out the 'ground' bit of playfield 2600 Test Edited February 18, 2021 by lerugray Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted February 18, 2021 Share Posted February 18, 2021 There are at least two methods: In case you have a frame counter, execute MoveJoystick only every 2nd frame. Use fractional numbers. For that you need a sum variable and a constant added to it each frame. Only call MoveJoystick when the sum variable wraps around. The latter is more flexible as you can fine tune the speed very gradually. Quote Link to comment Share on other sites More sharing options...
lerugray Posted February 18, 2021 Author Share Posted February 18, 2021 10 minutes ago, Thomas Jentzsch said: There are at least two methods: In case you have a frame counter, execute MoveJoystick only every 2nd frame. Use fractional numbers. For that you need a sum variable and a constant added to it each frame. Only call MoveJoystick when the sum variable wraps around. The latter is more flexible as you can fine tune the speed very gradually. Thank you Thomas! I think I can visualize your first example, but would you mind providing a short example of your second please? Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted February 18, 2021 Share Posted February 18, 2021 Sure. lda moveSum clc adc #SPEED ; e.g. 128 for 50% or 192 for 75% speed sta moveSum bcc .skipMove jsr MoveJoystick .skipMove 1 Quote Link to comment Share on other sites More sharing options...
lerugray Posted February 21, 2021 Author Share Posted February 21, 2021 On 2/18/2021 at 8:55 AM, Thomas Jentzsch said: Sure. lda moveSum clc adc #SPEED ; e.g. 128 for 50% or 192 for 75% speed sta moveSum bcc .skipMove jsr MoveJoystick .skipMove Not sure if I am doing this incorrectly but I can't seem to get it to work on my end MoveSpeed lda MoveSum clc adc #128 sta MoveSum bcc MoveSpeed jsr MoveJoystick Adversary(1).a Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted February 21, 2021 Share Posted February 21, 2021 You are branching to "MoveSpeed", but you should branch after "jsr MoveJoystick" 1 1 Quote Link to comment Share on other sites More sharing options...
lerugray Posted February 21, 2021 Author Share Posted February 21, 2021 2 minutes ago, Thomas Jentzsch said: You are branching to "MoveSpeed", but you should branch after "jsr MoveJoystick" Thank you for your patience with me, I think I'm still getting confused though as to what you mean. where should I be branching to after jsr MoveJoystick if not MoveSpeed to use it as a counter? MoveSpeed lda MoveSum clc adc #128 sta MoveSum jsr MoveJoystick bcc MoveSpeed Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted February 21, 2021 Share Posted February 21, 2021 bcc .skipMove jsr MoveJoystick .skipMove This is the correct code in question again. Hope it helps. 1 Quote Link to comment Share on other sites More sharing options...
lerugray Posted February 21, 2021 Author Share Posted February 21, 2021 5 minutes ago, Thomas Jentzsch said: bcc .skipMove jsr MoveJoystick .skipMove This is the correct code in question again. Hope it helps. This worked! Dont know what I was thinking, thanks! Quote Link to comment Share on other sites More sharing options...
DEBRO Posted February 21, 2021 Share Posted February 21, 2021 Hi there, On 2/18/2021 at 8:04 AM, lerugray said: Hello all, I'm currently teaching myself how to program the 2600 using the 8bit workshop tutorials. Currently, I am wondering how to slow down player movement. If the true intent is to control the player movement then you should move this code into the joystick routine where you are moving the player. In its current position you are controlling when to poll for the joystick input instead. 1 Quote Link to comment Share on other sites More sharing options...
lerugray Posted February 22, 2021 Author Share Posted February 22, 2021 On 2/21/2021 at 3:35 PM, DEBRO said: Hi there, If the true intent is to control the player movement then you should move this code into the joystick routine where you are moving the player. In its current position you are controlling when to poll for the joystick input instead. Doesn't it get caught in an endless loop though given it jumps right back to the Joystick routine? Thanks for your help 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.