-
Notifications
You must be signed in to change notification settings - Fork 1
/
initopts.c
120 lines (112 loc) · 3.48 KB
/
initopts.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
/*
* dis [-p predefineds] file
*
* The -p option may be repeated.
*/
#include <stdlib.h>
#include "dis.h"
char *predef[NPREDEF];
int npredef = 0;
char *global_file;
char *progname = "dis";
int bopt = UNKNOWN;
int global_base_address = 0;
int global_vector_address = 0x10000;
int asmout = 0;
static void usage(void)
{
fprintf(
stderr,
"Usage: %s <format> <options> <object-file>\n"
" format: -r <address> raw binary file\n"
" -b Atari boot format\n"
" -l Atari load format\n"
" -c Commodore 64\n"
" options: -a assembly output\n"
" -p <file> predefines\n"
" -v <address> alternate vector address\n"
" -7 mask character data to 7-bit\n"
" output: -O Original format (default)\n"
" -L Lancaster format (similar to ADE)\n"
" -B BeebAsm format\n",
progname
);
exit(EXIT_FAILURE);
}
void initopts(int argc, char *argv[])
{
int ai;
char *ca;
char *p;
int fileset = 0;
progname = argv[0];
pf_selected = &pf_orig;
while (--argc) {
if ((*++argv)[0] == '-') {
ca = *argv;
for(ai = 1; ca[ai] != '\0'; ai++) {
switch (ca[ai]) {
case 'a':
asmout = 1;
break;
case 'p':
predef[npredef] = *++argv;
npredef++;
argc--;
break;
case 'r':
global_base_address = strtoul(*++argv, &p, 0);
if (*p)
crash("Base address must be specified");
bopt = RAW_BINARY;
argc--;
break;
case 'v':
global_vector_address = strtoul(*++argv, &p, 0);
if (*p)
crash("Vector address required");
argc--;
break;
case 'l':
bopt = ATARI_LOAD;
break;
case 'c':
bopt = C64_LOAD;
break;
case 'b':
bopt = ATARI_BOOT;
break;
case '7':
sevenbit = 1;
break;
case 'A':
pf_selected = &pf_as;
break;
case 'B':
pf_selected = &pf_beebasm;
break;
case 'C':
pf_selected = &pf_ca65;
break;
case 'L':
pf_selected = &pf_lanc;
break;
case 'O':
pf_selected = &pf_orig;
break;
default:
crash("Invalid option letter");
}
}
}
else if (!fileset) {
global_file = *argv;
fileset++;
}
else
usage();
}
if (!fileset) {
usage();
}
}