Suggestion for unscramble_constant_data()
pullmoll at t-online.de
Fri Jun 15 07:30:29 PDT 2007
I remember how I was confused by unscramble_constant_data() before I
understood it was just bit-reversing the data :-) Here's a way simpler and
faster (which doesn't count, I know) method to reverse the 16 bits in d.
/* Reverse 16 bits in d */
static int unscramble_constant_data (int d)
d = (((d & 0xaaaa) >> 1) | ((d & 0x5555) << 1));
d = (((d & 0xcccc) >> 2) | ((d & 0x3333) << 2));
d = (((d & 0xf0f0) >> 4) | ((d & 0x0f0f) << 4));
d = (((d & 0xff00) >> 8) | ((d & 0x00ff) << 8));
I came back to this, because I also needed to bit reverse a PROM: the
displ.a38 MBEMPTY and STOPWAKE control PROM for the FIFO has its address
lines tied in reverse order to the in/out counters, and I swap its contents
once at init time.
BTW: Should I try explain how I got the video timing based entirely on the
PROMs, or are you happy with how you do the timing it in altogether?
More information about the Altogether-devel