How can i DEC/INC 13 times without 13 lines? 4.1.5 (solved)

mouse spirit

Well-known member
Is there a better command?Or can i just say variable equals 13? Currently i....
Code:
INC variable
INC  variable
INC variable
INC  variable
ect....

Maybe something like this?
Code:
LDA #$13
STA variable
 

CutterCross

Active member
Adding:
Code:
LDA variable
CLC
ADC #$0D
STA variable

Subtracting:
Code:
LDA variable
SEC
SBC #$0D
STA variable
 

mouse spirit

Well-known member
Thanks cutter. A work around is for me to start the variable at 12.But not always.
Thanks alot for this. I remember seeing this now,just didnt know how exactly it worked. I
kinda understand now.

Edit: Certainly works great.
 

AllDarnDavey

Active member
Cutter beat me too it.

Your first one is add 13 (or add 1 thirteen times), you second one is set the variable to 13. They are not exactly the same thing.
Cutter's code for adding and subtracting 13 is how you would do it. But the question you need to ask yourself is how you're using it, do you want to add 13 to the variable or force the variable to be 13?
 

mouse spirit

Well-known member
Thank you both. I want variable to equal 13, then 12, then 11, then 14.
I have this which is working for now.I start my variable "whoAmI" at 0.

Code:
;;; assumes projectile type is unlockable weapon 00000010 

   
	
	;;; assumes projectile type is unlockable weapon 00000010 

    ;;changing characters?
    
    TXA
    STA tempx
    TYA 
    STA tempy

    ;;;;;;;;;;;;;;;;;;;
    LDX player1_object
    LDA Object_x_hi,x
    STA temp
    LDA Object_y_hi,x
    STA temp1

    DeactivateCurrentObject
	
    LDA screenType
	CMP #15
	BEQ ++
	CMP #25
	BEQ oneTo
	CMP #35
	BEQ oneTo
	CMP #45
	BEQ righgtEre
	JMP +
	++
	INC canIShoit
    LDA whoAmI
    CLC
    ADC #$0D
    STA whoAmI
	JMP++
	righgtEre:
	 LDA whoAmI
    CLC
    ADC #$04
    STA whoAmI
	JMP ++
	oneTo:
	DEC whoAmI
	++
	
    CreateObject temp, temp1, whoAmI, #$00, currentNametable
	;INC whoAmI
	
	+
	LDA screenType
	CMP #99
	BNE +
	CreateObject temp, temp1, #NOWPLAYER3, #$00, currentNametable
	
	
    ;;;;;;;;;;;;;;;;;;;
    ;;;StopSound
    ;;;PlaySound #$01, #$01
    ;LDA #$FF
    
    ;STA player1_object
    
    ;LDX tempx
   ; LDY tempy
	;INC which_weapon
	
    ;;ActivateCurrentObject

I am changing my player object to different objects with this variable.Also i spawn the correct player object
using this variable. It is for my armor upgrades.Works like a charm, thank you both again.
 
Top Bottom