It is currently Thu Jul 19, 2018 8:18 pm

 All times are UTC - 7 hours

 Page 2 of 2 [ 21 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: 255 rubies in "The Legend of Zelda"?Posted: Thu Jun 16, 2016 2:42 pm

Joined: Thu Aug 28, 2008 1:17 am
Posts: 591
Sik wrote:
tomaitheous wrote:
I think having a 256 LUT, which outputs 0 to 99.

You only need 100 entries for that ;P

Well, you did mention speed...

Up the 256 to 512bytes..
Code:
ByteBin2Dec:
lda TableDec,x
ldy SwapLowNybble2BCD,x
ldx TableDec,y
rts

Input is byte in X. Returns BCD in two bytes via X:A.

Edit: I guess it doesn't make any sense to have a whole 'nother 256 LUT for high nybble shift and extraction, when it can just convert it directly. So just TableDec and TableDecUpper. I also thought you could simply cascade afterwards, for a larger binary conversion using this method, but I just realized that's not going to work. Meh...

_________________
__________________________
http://pcedev.wordpress.com

Top

 Post subject: Re: 255 rubies in "The Legend of Zelda"?Posted: Thu Jun 16, 2016 3:45 pm

Joined: Thu Aug 12, 2010 3:43 am
Posts: 1589
tomaitheous wrote:
Well, you did mention speed...

Checking for 100 or 200 is nothing compared to doing a division by 10 to split the tens from the units.

Top

 Post subject: Re: 255 rubies in "The Legend of Zelda"?Posted: Thu Jun 16, 2016 4:30 pm

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20273
Location: NE Indiana, USA (NTSC)
If you understand "checking for 200", then you can understand my routine as applying the same concept to 200, 100, 80, 40, 20, and 10.

Top

 Post subject: Re: 255 rubies in "The Legend of Zelda"?Posted: Fri Jun 17, 2016 9:09 pm

Joined: Tue Jun 10, 2014 8:15 pm
Posts: 35
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#p130363

And 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
; 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
; end with decTenThousand, decThousand, Y = 100's, A = 10's, decOnes
; requires 2 extra temp registers on top of decTenThousand, decThousand, decOnes

Top

 Post subject: Re: 255 rubies in "The Legend of Zelda"?Posted: Sat Jul 02, 2016 4:35 pm

Joined: Mon Jul 14, 2014 6:05 am
Posts: 90
Location: Lausanne, Switzerland
Sik wrote:
The problem isn't that, the problem is doing it quickly.

I actually wanted to do this once with 16-bit vars, and here is the code I came up with viewtopic.php?f=2&t=13816 if that's what you're asking for

Top

 Post subject: Re: 255 rubies in "The Legend of Zelda"?Posted: Sun Jul 03, 2016 8:55 pm

Joined: Mon Dec 29, 2014 1:46 pm
Posts: 774
Location: New York, NY
Off topic, but the original post reminded me of a question I had about Baskin-Robbins: Why 31 flavors instead of 32? But, it turns out to have nothing to do with base-2 math. Rather, it's a flavor for everyday of the month.

Edit: Also this.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 21 posts ] Go to page Previous  1, 2

 All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 4 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki