Re: [stella] optimization : sneaky fractional bit representation

Subject: Re: [stella] optimization : sneaky fractional bit representation
From: "Andrew Davie" <adavie@xxxxxxxxxxxxxxxxx>
Date: Mon, 18 May 1998 20:44:34 +1000
>Aaarrgh... did you use that in a program too?
>I think it would be very cycle-consuming to do this.


Nup.  How about

    ldx number
    lda mod12,x            ; this is the encoded number  (4 cycles)
    lda div12,x                ; this is the number / 12    (4 cycles)
    tax
    lda mod12,x            ; this is the 2nd encoded number.... etc

It's all relative.  Sure, you need two 256 byte tables for this (for each
"base" you use).
But, THE POINT IS.... sometimes you need a trick or two.  Rather than assume
that it would be expensive, or infeasible... thinking negatively and
throwing up objections to the ideas I'm throwing your way... add it to your
bag of tricks, to pull out when you really need it.

With the 2600, more than most other machines I've programmed, there are
definite pros and cons to just about every decision you make.  If you could
save a single bit with this method, meaning that your RAM requirements were
one byte less than otherwise, well maybe it would be worth the ROM space.
Maybe it would even be worth using division.  It's all a trade-off.  So,
who's interested in efficient division and multiplication?

I'm not telling you to use these ideas that I throw on the list.  I don't
even care if some of you think they're obvious and you have been using them
for years.  These things are in MY bag of tricks, and I sure would like to
see the contents of yours, too.  Come on, surprise me :)

And yes, in answer to the quesion... I DID need to use this technique on the
C64.  I distinctly remember the days when we had to use the screen space to
hold code, and change the colours so that it would not be seen on the TV.
Space was often really really really tight.

Enjoy
A


--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/stella.html

Current Thread