Up until now, I never used a 16 bit variable in my games as a variable that is buffered to the screen (at least not to its full potential, since the coins in Brony Blaster are a 16 bit variable but it can only go up to 9999 in the game). The first thing that came to my mind when buffering such variables is to take 5 variables in the RAM, load the high byte to X and then add decimal 256 to those variables, while having a loop where X decrements. When all this is done, I convert the lower byte to decimal and put it in the designated variables (Which works as it should). Here's some pseudocode to show you what I mean
The problem is that converting the high byte to decimal takes more CPU time each time the high byte is incremented, up to a certain point where the game slows down and becomes unplayable. I had another solution in mind but that would take a lot of ROM space which I don't want to waste either.
Does there exist any solution to buffer 16-bit variables conveniently? I know a few commercial games managed to do so (For example, the money in Uncharted Waters is a 16 bit variable, but then that game is rather slow paced so it can get away with CPU time use)
tl;dr Is there any convenient way to buffer decimal 16 bit variables to sprites or to the background?
Code:
LDX highbyte
.loop
CPX #$00
BEQ .done
;Fairly enough code that adds the decimal values to the designated RAM spot
DEX
JMP .loop
.done
;Rest of code
.loop
CPX #$00
BEQ .done
;Fairly enough code that adds the decimal values to the designated RAM spot
DEX
JMP .loop
.done
;Rest of code
The problem is that converting the high byte to decimal takes more CPU time each time the high byte is incremented, up to a certain point where the game slows down and becomes unplayable. I had another solution in mind but that would take a lot of ROM space which I don't want to waste either.
Does there exist any solution to buffer 16-bit variables conveniently? I know a few commercial games managed to do so (For example, the money in Uncharted Waters is a 16 bit variable, but then that game is rather slow paced so it can get away with CPU time use)
tl;dr Is there any convenient way to buffer decimal 16 bit variables to sprites or to the background?