After I saw the suggestion to add the forty-two melody as an easter egg somewhere in Action 53 volume 3, I got to thinking whether more substantial bytebeat compositions such as "Crowd" by Kragen might be doable. Is it possible to compute each sample of "Crowd" in exactly 224 cycles on the MOS 6502? Or are all the 32-bit shifts and bitwise ops too complex?
Or is this a moot point because of undefined behavior involving t>>(4-(1^7&(t>>19)))?
Code:
#include <stdint.h>
static inline void putchar(int c) {
*(uint8_t *)0x4011 = c >> 1;
}
int main(void) {
for (uint32_t t = 0; ; ++t) {
uint8_t out =
((t<<1)^((t<<1)+(t>>7)&t>>12))
| t>>(4-(1^7&(t>>19)))
| t>>7;
putchar(out);
}
}
static inline void putchar(int c) {
*(uint8_t *)0x4011 = c >> 1;
}
int main(void) {
for (uint32_t t = 0; ; ++t) {
uint8_t out =
((t<<1)^((t<<1)+(t>>7)&t>>12))
| t>>(4-(1^7&(t>>19)))
| t>>7;
putchar(out);
}
}
Or is this a moot point because of undefined behavior involving t>>(4-(1^7&(t>>19)))?