Jump to content
IGNORED

adding score0 and score1 together


Recommended Posts

Hi all,

 

I've run into a problem where I'm trying to add two scores together but do not seem able to get the code to work.

 

I have an action that triggers "score0 = score0 + 1" and displays it. - all good

 

I have a second action that triggers "score1 = score1 + 1" and displays it. - all good

 

I want a third score to be the sum of score 0 and 1. 

 

My thinking was I could define "score2" per the documentation, like "dim score2 = var1 (noting it will use var 1, var2 and var3).

 

I then tried to update it with "score2 = score 2 + score0 : score2 = score2 + score1"

 

but all I get is zero even though score0 is ticking up on each event as expected.

 

I also tried just adding score0 to score1 and still got nothing.

 

is it not allowed to add score variables together?

Link to comment
Share on other sites

Yeah, the score code only handles very specific operations. Adding scores together isn't one of them, and honestly I don't want to bog the language down with more 24 bit math.

 

If you really need to do that, you can resort to some assembly...

 

 asm
 ; score2 = score 2 + score0
 sed ; set decimal mode
 clc

 ; lowest 2 digits...
 lda score0+2
 adc score2+2
 sta score2+2

 ; middle 2 digits...
 lda score0+1
 adc score2+1
 sta score2+1

 ; highest 2 digits...
 lda score0
 adc score2
 sta score2

 cld ; clear decimal mode
end

 

 

  • Like 2
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...