Quote:
If for some reason you don't want to make the fractions powers of two, at least make them all fractions of a power of 2
Huh, was this supposed to make any sense ?
Quote:
Although the 6502 lacks multiplication and division, multiplications are easier to code.
No the NES don't lack multiplication and division, you just have to code them all by yourself. And again it's not easier to avoid multiplication or division, doing them is NOT HARD AT ALL.
Just take a sheet of paper, do the division manually, and then code an algorithm that does the same on a computer... the fact there is only '0' and '1' to deal with makes it much simpler than doing it with all digits '0' to '9'.
You'd want to use power of 2 if you care about speed or size of the code, but else I don't see an issue. Since you typically compute damage once in a while, and don't do it like 20 times per frame, I don't see any need for more speed in the calculations.
As for random number generator, as far I know there is 3 techniques arround :
- Use a value captured from a counter that increments much faster than the rate you capture it (for example it increments every frame but you only read it ocasionally). Not applicable if you need random numbers at high rate
- The shift register with feedback technique, which tepples described and which is used for the noise channel. This will give you a predictable random sequence with a fixed lenght before it repeats.
- The multiply, add and tuncate to lower n bits technique. Different multipliers and adders gives you a different amount of random numbers before they repeat, the larger the better.
These techniques will typically give you a random number between 0 and 255. It's not too hard to make it act like a random number of another range using AND operations, or divisions.