now it plays properly, will fix up some leftovers later
[bootcard] / tools / gentune.c
1 #include <stdio.h>
2 #include <stdint.h>
3
4 uint32_t music[] = {
5         0x0a2f8f00, 0xa11123a1, 0x23a11423, 0x28000023, 0xbe322f8f, 0x25c0391f,
6         0x4b23a13c, 0x8f500000, 0x23a15a2f, 0x641ab161, 0x476e1ab1, 0x1fbe751c,
7         0x8223a178, 0xa18925c0, 0x1fbe8c23, 0xaa0000a0, 0
8 };
9
10 struct {
11         unsigned int cnt;
12         const char *name;
13 } notes[] = {
14         {0, "0"},
15         {6833, "F3"},
16         {7239, "E3"},
17         {8126, "D3"},
18         {9121, "C3"},
19         {9664, "B2"},
20         {12175, "G2"},
21         {0, 0}
22 };
23
24 const char *pre =
25         "G2     equ 12175\n"
26         "C3     equ 9121\n"
27         "D3     equ 8126\n"
28         "B2     equ 9664\n"
29         "F3     equ 6833\n"
30         "E3     equ 7239\n"
31         "\n"
32         "%macro EV 2\n"
33         "       db %1 >> 4\n"
34         "       dw %2\n"
35         "%endmacro\n\n";
36
37
38 int main(void)
39 {
40         int i, j;
41         unsigned char *mptr = (unsigned char*)music;
42
43         printf("%s", pre);
44
45         printf("music:");
46         for(i=0; i<22; i++) {
47                 const char *nn = "?";
48                 unsigned int tm = (unsigned int)*mptr++ << 4;
49                 unsigned int cnt = *(uint16_t*)mptr;
50                 mptr += 2;
51
52                 for(j=0; notes[j].name; j++) {
53                         if(notes[j].cnt == cnt) {
54                                 nn = notes[j].name;
55                                 break;
56                         }
57                 }
58
59                 printf("\tEV  %4u,  %s\n", tm, nn);
60         }
61         return 0;
62 }