tomaitheous wrote:

Sik wrote:

The problem isn't that, the problem is doing it quickly.

What's the fast method for doing this on the NES?

I think having a 256 LUT, which outputs 0 to 99. And for the last digit in the 100s place, simply check of the original byte is greater than 200 (populate a 2) or greater than 100 (populate a 1). Since NES doesn't have decimal mode like other 65x, you can't easily cascade two more bytes in this process unfortunately.

Here are some quick Hex to Decimal methods I have wrote.

viewtopic.php?p=130363#p130363And a quick summary of the routines byte usage and cycles. The cycles include the JSR/RTS.:

**Code:**

;slow routine - 174 bytes, 183 bytes with HexToDec255 and HexToDec999

;HexToDec99 ; 37 cycles

;HexToDec255 ; 52-57 cycles

;HexToDec999 ; 72-77 cycles

;HexToDec65535 ; 178-186 cycles

;Fast routine - 234 bytes, 243 bytes with HexToDec255 and HexToDec999

;HexToDec99 ; 37 cycles

;HexToDec255 ; 52-57 cycles

;HexToDec999 ; 72-77 cycles

;HexToDec65535 ; 157-162 cycles

;-------------------------------------------------------------------------------

;HexToDec99

; start in A

; end with A = 10's, decOnes

;HexToDec255

; start in A

; end with Y = 100's, A = 10's, decOnes

;HexToDec999

; start with A = high byte, X = low byte

; end with Y = 100's, A = 10's, decOnes

; requires 1 extra temp register on top of decOnes, could combine

; these two if HexToDec65535 was eliminiated...

;HexToDec65535

; start with A = high byte, X = low byte

; end with decTenThousand, decThousand, Y = 100's, A = 10's, decOnes

; requires 2 extra temp registers on top of decTenThousand, decThousand, decOnes