vsync bugfix + refactoring
[picodrive.git] / tools / mkt1.c
CommitLineData
c5b61ac2 1#include <stdio.h>
2#include <string.h>
3
4static FILE *fo = NULL;
5
6static void out(int r, int is_last)
7{
8 if (!is_last)
9 {
10 fprintf(fo, " or $t%i, $t%i, $a2\n", r, r);
11 fprintf(fo, " sb $t%i, %i($a0)\n", r, r);
12 }
13 else
14 {
15 fprintf(fo, " or $t%i, $t%i, $a2\n", r, r);
16 fprintf(fo, " jr $ra\n");
17 fprintf(fo, " sb $t%i, %i($a0)\n", r, r);
18 }
19}
20
21unsigned char pattern_db[0x100];
22
8ef001cc 23static int check_label(unsigned char i)
c5b61ac2 24{
25 if (!pattern_db[i]) {
26 fprintf(fo, "tile%i%i%i%i%i%i%i%i:\n", (i&0x80)?1:0, (i&0x40)?1:0, (i&0x20)?1:0, (i&0x10)?1:0,
27 (i&0x08)?1:0, (i&0x04)?1:0, (i&0x02)?1:0, (i&0x01)?1:0);
28 pattern_db[i] = 1;
29 return 0;
30 }
31
32 return 1;
33}
34
35
36int main()
37{
38 int i;
39
40 fo = fopen("out.s", "w");
41 if (!fo) return 1;
42
43 memset(pattern_db, 0, sizeof(pattern_db));
44
45 for (i = 0xff; i > 0; i--)
46 {
8ef001cc 47 if (check_label(i)) continue;
c5b61ac2 48
8ef001cc 49 if (i & 0x01) out(0, !(i&0xfe));
50 check_label(i&0xfe);
51 if (i & 0x02) out(1, !(i&0xfc));
52 check_label(i&0xfc);
53 if (i & 0x04) out(2, !(i&0xf8));
54 check_label(i&0xf8);
55 if (i & 0x08) out(3, !(i&0xf0));
56 check_label(i&0xf0);
57 if (i & 0x10) out(4, !(i&0xe0));
58 check_label(i&0xe0);
59 if (i & 0x20) out(5, !(i&0xc0));
60 check_label(i&0xc0);
61 if (i & 0x40) out(6, !(i&0x80));
62 check_label(i&0x80);
c5b61ac2 63 if (i & 0x80) out(7, 1);
64 }
65
66 fclose(fo);
67
68 return 0;
69}
70