-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
121 lines (115 loc) · 3.72 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "karaoke.h"
unsigned int verbose = 0;
#include "lrc.c"
#include "ultrastar.c"
#include "ikmod.c"
#include "sid.c"
void usage(void)
{
printf(
"--verbose\n"
#ifdef TESTING
"--readlrc <file>\n"
"--writelrc <file>\n"
#endif
"--readusc <file>\n"
"--writeusc <file>\n"
"--readikmod <file>\n"
"--writeikmod <file>\n"
"--writeikasm <file>\n"
"--readsid <file>\n"
"--writesid <file>\n"
"--start-with-countdown use countdown at song start (default: no)\n"
"--volume-addr <addr> addr in player to patch for volume fade (default: use $d418)\n"
"--fade-speed <speed> speed of fade out when sid ends (default: $02)\n"
"--fade-delay <delay> number of frames to play music when lyrics are done (default: $0202)\n"
);
}
int main(int argc, char *argv[] )
{
int i;
if (argc < 2) {
usage();
exit(-1);
}
for(i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--verbose")) {
verbose++;
} else if (!strcmp(argv[i], "--start-with-countdown")) {
start_counter = 1;
} else if (!strcmp(argv[i], "--volume-addr")) {
i++;
volume_addr = strtoul(argv[i], NULL, 0);
} else if (!strcmp(argv[i], "--fade-speed")) {
i++;
fade_speed = strtoul(argv[i], NULL, 0);
} else if (!strcmp(argv[i], "--fade-delay")) {
i++;
fade_delay = strtoul(argv[i], NULL, 0);
#ifdef TESTING
} else if (!strcmp(argv[i], "--readlrc")) {
i++;
if(readlrc(argv[i]) != 0) {
fprintf(stderr, "error: could not read file '%s'\n", argv[i]);
exit(-1);
}
} else if (!strcmp(argv[i], "--writelrc")) {
i++;
if(writelrc(argv[i]) != 0) {
fprintf(stderr, "error: could not write file '%s'\n", argv[i]);
exit(-1);
}
#endif
} else if (!strcmp(argv[i], "--readusc")) {
i++;
if(readusc(argv[i]) != 0) {
fprintf(stderr, "error: could not read file '%s'\n", argv[i]);
exit(-1);
}
} else if (!strcmp(argv[i], "--writeusc")) {
i++;
if(writeusc(argv[i]) != 0) {
fprintf(stderr, "error: could not write file '%s'\n", argv[i]);
exit(-1);
}
} else if (!strcmp(argv[i], "--readikmod")) {
i++;
if(readikmod(argv[i]) != 0) {
fprintf(stderr, "error: could not read file '%s'\n", argv[i]);
exit(-1);
}
} else if (!strcmp(argv[i], "--writeikmod")) {
i++;
if(writeikmod(argv[i]) != 0) {
fprintf(stderr, "error: could not write file '%s'\n", argv[i]);
exit(-1);
}
} else if (!strcmp(argv[i], "--writeikasm")) {
i++;
if(writeikasm(argv[i]) != 0) {
fprintf(stderr, "error: could not write file '%s'\n", argv[i]);
exit(-1);
}
} else if (!strcmp(argv[i], "--readsid")) {
i++;
if(readsid(argv[i]) != 0) {
fprintf(stderr, "error: could not read file '%s'\n", argv[i]);
exit(-1);
}
} else if (!strcmp(argv[i], "--writesid")) {
i++;
if(writesid(argv[i]) != 0) {
fprintf(stderr, "error: could not write file '%s'\n", argv[i]);
exit(-1);
}
} else {
usage();
exit(-1);
}
}
return 0;
}