Link wrote:
That's exactly what I want to do. Using the multiplication routine and multiplicating the number by the recipricol which makes me get the divided answer. I just want to see if I can get this working, right now speed isn't a problem (it will be later), I just want to see if I can use the same routine for multiplying and dividing (recipricol multiplication). I sort of get how I'd do it, but not too well. Is there somewhere I could read about it? How much precission could I get out of it?
The thing is that a standard multiplication loop isn't all that much slower than a general purpose division function. So in order to gain anything from it all you'll need to use some fast multiplication algorithm to begin with (probably table or hardware based). Another problem with reciprocal multiplication is that to avoid any loss of precision you need about as much fixed point precision as the numerator's size.
However in a controlled special case (i.e. demo) 8-bit precision 'should' be enough. The C-Hacking multiplication combined with a reciprocal table could be optimized down to about 40 cycles.
Lets go through previous example again with concrete numbers. We'll divide 172 by 10 three times to extract each digit, in 8-bit precision.
The reciprocal of 10 as an 8-bit fixed point number is (1/10)*256 = ~26.
Multiplying 172 by 26 gives 4472, since we only want the integer part of the resulting fixed pointer number we this by 256 to obtain 17.
Repeating the procedure once more we get 17*26 = 442, 442 / 256 = 1.
In your case you probably want to prepare a table of the first 256 reciprocal divisors to feed the multiplication function. But that shouldn't be much of a sacrifice in a NES rom.
Link wrote:
Well, I want to try a little 3D demo for the NES, but otherwise I wanted to know if it was even possible in 6502 practically.
It's both possible and practical. With some optimizations you should be able to keep 64 (one per sprite) vertices flying around in 3d space without too much trouble. Unless you want to do vectors, like Elite does, but then you've got worse problems than vertex transformations to deal with.
Link wrote:
Would then it be much more useful (and faster) to use a lookup table? What's One-Der?
You should probably be using a lookup table for multiplication anyway, check the other 3d thread here on NesDev for a link.
One-Der is a 64 kB C64 intro which (among other amazing effects) features a part with 256 vector plots in full framerate.
One more thing, while the C64 might excell compared to the NES in most areas 'we' still have a a few advantages, most importantly there's enough ROM space available for some gigantic tables. Another thing is that updating raw 8-bit sprite coordinates is a whole lot easier (and faster) than having to do the plotting manually, especially if you need to clear it afterwards. You could even utilize the MMC5 to get hardware multiplication.
Btw, why did you quote me as code? Seemed awfully official that way.. ;)