Every time I've tried to add a variable to a score, I feel like I've quickly gone wrong because I can't seem to figure out BCDs and the dec statement. Often my solution is a simple loop:

for x = 1 to level : score = score + 50 : next

That works well for small, repeatable instances. But I've got a game concept I'd like to implement where the score can be large, and with that amount (let's assume it's money), you can purchase things that have variable prices and are larger than 255.

So, for example, with a score of 25,000, I could purchase an item that costs 9,876.

The question is how to make this work. I understand the _sc1, _sc2, and _sc3 parts of the score. My idea would be to store prices in data arrays similarly named, with two digits per price. So, for something that costs 9,876, item1 would have an entry of $00 (first two digits), item2 would be $98 (second two digits), and item3 would have an entry of $76. I also understand how to store _sc1 et al. into other variables and replace them when necessary. But I can't figure out the math and the proper way to store things to have the calculations come out correctly. Ideally, I'd like the score to display the cost upon hovering over a graphic of the item to be bought (by using a missile as a mouse pointer, say), then you could press fire to buy the item, and then upon leaving the correct new score would display (old score - price of item). I'm trying to do this by comparing each pair of digits and subtracting where appropriate (and "carrying the one" when necessary).

I've fought with BCDs and dec statements and trying to parse how the score works and I can't seem to get anywhere. I'm running into some hex issues where if I store $10 into my data array and load it into _sc3, It's actually hex 10 = decimal 16. (And I think I've tried every combination of dec statements and dollar signs to combat this, to no avail.) So there's some definite hex / dec conversion issues I'm failing to navigate.

Anyway, I'd really appreciate any assistance in trying to make this work. I've looked at RT's page, sample programs, the forums, etc., and haven't found the right combination of operations yet. Thanks.

**Edited by bjbest60, Wed Nov 28, 2018 11:47 PM.**