new version
[Chiptunes.git] / foo.c
CommitLineData
61fab018 1#include <stdio.h>
da32ed67 2#include "fakeasm.h"
61fab018 3typedef unsigned char u8;
da32ed67 4
24abdcbb
TG
5u8 data[] = {
6 0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58,
7 0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58
8};
3b86ca43
TG
9u8 x;
10u8 t;
11u8 o;
12u8 g(int i) {
63363195 13 u8 tmp;
0f219114 14 ANDI (t, 0x07)
63363195
TG
15 tmp = i >> 16;
16 ANDI (tmp, 3)
09cf3949
TG
17 TST (tmp)
18 BREQ (skip)
19 SUBI (t, -8)
20 skip:
c616f0c2 21 t = data[t];
c616f0c2
TG
22 t = (i*t) >> o;
23 AND (t, x)
24 ANDI (t, 3)
25 return t;
61fab018
TG
26};
27
28int main(void) {
5dd8b8ff 29 int i = 0;
c65ddced
TG
30 unsigned short n;
31 unsigned short s;
ab6fe4c2 32 u8 acc;
5dd8b8ff 33 for (;;) {
ab6fe4c2 34 acc = 0;
fe9a76e4
TG
35 n = i >> 14;
36 s = i >> 17;
3b86ca43
TG
37
38 //voice 1:
39 LDI (x, 1)
40 MOV (t, n)
41 LDI (o, 12)
42 acc += g(i);
43
44 //voice 2:
45 MOV (x, s)
46 t = n ^ i >> 13;
47 LDI (o, 10)
48 acc += g(i);
49
50 //voice 3:
51 x = s / 3;
52 t = n + ((i >> 11) % 3);
53 LDI (o, 10)
54 acc += g(i);
55
56 //voice 4:
57 x = s / 5;
58 t = 8 + n - ((i >> 10) % 3);
59 LDI (o, 9)
60 acc += g(i);
bfce2f8c 61
5dd8b8ff 62 i++;
ab6fe4c2 63 putchar(acc<<4);
fe9a76e4 64 }
61fab018 65}
Imprint / Impressum