Search found 6 matches

by chitselb
Wed Jul 09, 2014 7:12 am
Forum: NESdev
Topic: Unsigned Integer Division Routines
Replies: 30
Views: 26574

Re: Unsigned Integer Division Routines

tepples wrote:Try rounding the multiplication by 1.024 up using ceil().
I played around with it in a spreadsheet and there are inaccuracies. It would probaby work if more bits were available for the fractions, but in Rad50 they just aren't there.
by chitselb
Tue Jul 08, 2014 7:30 pm
Forum: NESdev
Topic: Unsigned Integer Division Routines
Replies: 30
Views: 26574

Re: Unsigned Integer Division Routines

I found another fudge if you're allowed to change the encoder. Have the encoder multiply each 16-bit word by 65536/64000 = 128/125 = 1.024, so that the decoder works by multiplying by 40 (shift, shift, add, shift, shift) instead of dividing by 40. The principle is that of arithmetic coding. The enc...
by chitselb
Tue Jul 01, 2014 9:11 pm
Forum: NESdev
Topic: Unsigned Integer Division Routines
Replies: 30
Views: 26574

Re: Unsigned Integer Division Routines

Here's what I came up with. Probably not optimal, and at 179 bytes, way more code than I want. It's a Forth word in http://pettil.tumblr.com if you're wondering what is all that weird stuff on the fringe of the code ;-------------------------------------------------------------- #if 0 name=40/MOD st...
by chitselb
Tue Jul 01, 2014 4:42 am
Forum: NESdev
Topic: Unsigned Integer Division Routines
Replies: 30
Views: 26574

Re: Unsigned Integer Division Routines

I played around with it in a spreadsheet, and I noticed this. It's 32-bit math, but it doesn't have to be an obscene amount of 6502 code (x*13107+13100)/65536 = x/5 and 13107 = 3 + 48 + 192 + 12288 (triple it; add and shift 4; add and shift 4; add and shift 4; add (and shift 4)) Here it is in C #inc...
by chitselb
Tue Jul 01, 2014 2:08 am
Forum: NESdev
Topic: Unsigned Integer Division Routines
Replies: 30
Views: 26574

Re: Unsigned Integer Division Routines

The idea behind Rad50 http://en.wikipedia.org/wiki/RADIX-50 is that 40x40x40 = 64000, so if you limit your character set to 40 characters (26 letters + 10 digits + 4 whatevers) you can squeeze three bytes of text into a two byte unsigned, every time. 33% compression. In these routines, the divisor i...
by chitselb
Sat Jun 14, 2014 5:22 pm
Forum: NESdev
Topic: Unsigned Integer Division Routines
Replies: 30
Views: 26574

Re: Unsigned Integer Division Routines

These are great! I needed a divide by 40 and modulo 40 for a http://en.wikipedia.org/wiki/DEC_Radix-50 decoder in a game I'm writing for the Commodore PET 2001( http://pettil.tumblr.com ) and the divide by 10 here looks like a good start. Thank you!