new version
[Chiptunes.git] / foo.c
1 #include <stdio.h>
2 #include "fakeasm.h"
3 typedef unsigned char u8;
4
5 u8 data[] = {
6 0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58,
7 0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58
8 };
9 u8 g(int i, u8 x, u8 t, u8 o) {
10 u8 tmp;
11 ANDI (t, 0x07)
12 tmp = i >> 16;
13 ANDI (tmp, 3)
14 TST (tmp)
15 BREQ (skip)
16 SUBI (t, -8)
17 skip:
18 t = data[t];
19 t = (i*t) >> o;
20 AND (t, x)
21 ANDI (t, 3)
22 return t;
23 };
24
25 int main(void) {
26 int i;
27 int n;
28 int s;
29 u8 acc;
30 for (i = 0;; i++) {
31 acc = 0;
32 n = i >> 14;
33 s = i >> 17;
34 acc += g(i, 1, n, 12);
35 acc += g(i, s, n ^ i >> 13, 10);
36 acc += g(i, s / 3, n + ((i >> 11) % 3), 10);
37 acc += g(i, s / 5, 8 + n - ((i >> 10) % 3), 9);
38 putchar(acc<<4);
39 }
40 }
Imprint / Impressum