I am having trouble getting a number between 10-110. This is my code I have now:
Get_random_value jsr Random ; get value between and #127 ; 0-127 adc #10 ; add ten sta NextValueXPos ; save value cpx #110 ; check if value is above 110 bcs Lower_X_Pos ; if so, go to the lowering part of the code rts ; end this section Lower_X_Pos lda NextValueXPos ; load value sbc #57 ; decrease by 57 sta NextValueXPos ; save value rts ; end this section
Sometimes a value will turn the object up at the extreme right part of the code where it is unreachable, even though I had set it to decrease the value of the x position by a whole bunch. Or am I doing something wrong?
Random: lda Rand lsr ifconst Rand16 rol Rand16 endif bcc noeor eor #$B4 noeor sta Rand ifconst Rand16 eor Rand16 endif rts
EDIT: Argh! I am such a dummy! It should be this:
cmp #110 ; check if value is above 110 bcs Lower_X_Pos ; if so, go to the lowering part of the code
Since it's saved in a, not x.
EDIT #2: Hmm. This isn't working as I thought it would, either.
Edited by atari2600land, Sun Jan 28, 2018 9:01 PM.