3 ms·
Often, on this chip you want to come up with a very specific dedicated purpose multiply that's fast and that gives you enough precision to do the work. The oth
by ddingus 4y ago
Often, on this chip you want to come up with a very specific dedicated purpose multiply that's fast and that gives you enough precision to do the work.
The other tricks are all worth learning, cordic, shifts, look up tables and the other tricks we use when add shifts and rotates and bit opps are the only thing the CPU can do.
- kbelder 4y agoRight. I remember on the C64 using, for instance, y * 40 + x for screen positioning, since it had a 40 column screen. Since y * 40 is (y * 8) + (y * 32), you'd take x, left-shift three times, save the result, shift left two more times, and add the two together. Pretty fast. You'd do stuff like this everywhere you knew the coefficients in advance.
- ddingus 4y agoBingo! I did the same on an Atari. Also, a lookup table for the Y address, plus a fixed X address can get bitmaps blitted to the screen quickly. For special case graphics, just code in the addresses, unroll the loop and use index X or Y to handle screen positioning. LDX XPOS LDA IMAGE0 STA SCREEN0, X LDA IMAGE1 STA SCREEN1, X LDA IMAGE2 STA SCREEN2, X . . . No multiply needed. Y addresses either coded at fixed position, or generated at runtime based on some event and or when there is time to compute it all off screen. Trade RAM for speed!
- commandlinefan 4y agoSigh... I remember doing a lot of this stuff as a teenager, looking forward to the day when I'd be getting paid to do it. But by the time I got paid to do stuff, there was no market for this kind of low-level optimization any more. Shame.
- ddingus 4y agoI hear ya! Today, I mostly do it for fun on my old Apple machine. It is enjoyable to see what can be done. 1Mhz is actually quite a lot when one looks at the resolution and overall task to complete. And where to put it? Things like having the game run at 30Hz or 15Hz so more can be computed in game, in real time. Then, when it comes to drawing everything, often a simple screen clear, or page flip then draw does not make sense. Two screens takes too much RAM, etc... Single buffer, draw fast, only draw deltas, using XOR, all add up! Getting paid? I have done some assembly for money on Propeller chips, PIC, AVR, and the like. There are times in embedded land where doing these fun things pays off and makes sense. For what it is worth, a little fun can be had for income, but not much.