Skip to content

Commit ff3bf1f

Browse files
- changed parameter handling
1 parent b6b224b commit ff3bf1f

File tree

1 file changed

+49
-22
lines changed

1 file changed

+49
-22
lines changed

smm-conv/src/inc/parseParams.inc

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,36 +73,52 @@ var
7373
begin
7474
if paramCount<1 then
7575
showInstruction();
76-
sourceFN:=paramStr(1);
77-
outFN:=extractFileName(paramStr(2));
78-
outPath:=extractFilePath(paramStr(2));
79-
currentParam:=3;
76+
currentParam:=1;
8077
while currentParam<=paramCount do
8178
begin
8279
param:=paramStr(currentParam);
83-
if param[1]<>'-' then haltError('Invalid parameter');
80+
// if param[1]<>'-' then haltError('Invalid parameter');
8481
inc(currentParam);
8582

83+
if not check('-') then
84+
begin
85+
if length(sourceFN)=0 then
86+
begin
87+
sourceFN:=param;
88+
writeLn('Music file: ',sourceFN);
89+
end
90+
else
91+
begin
92+
outFN:=param;
93+
writeLn('Out file: ',outFN);
94+
end;
95+
continue;
96+
end;
97+
98+
if check('version') or check('-v') then
99+
begin
100+
WriteLn(VERSION); halt;
101+
end;
86102
//
87103
//
88104

89-
if check('-org:') or check('-Ao:') then
105+
if check('org:') or check('Ao:') then
90106
begin
91107
getAddr(MSG_ORIGIN+' set: ',org,$A000,ERR_BAD_ADDRESS+MSG_ORIGIN+MSG_SET_TO_DEFAULT+'($A000)');
92108
continue;
93109
end;
94110

95-
if check('-audiobuffer:') or check('-Aa:') then
111+
if check('audiobuffer:') or check('Aa:') then
96112
begin
97113
getAddr(MSG_AUDIO_BUFFER+' set:',AUDIO_BUFFER_ADDR,$E8,ERR_BAD_ADDRESS+MSG_SFX_CHANNELS_REGS+MSG_SET_TO_DEFAULT+'($00E8)');
98114
continue;
99115
end;
100-
if check('-regs:') or check('-Ar:') then
116+
if check('regs:') or check('Ar:') then
101117
begin
102118
getAddrB(MSG_SFX_REGISTERS+' set:',SFX_REGISTERS,$F0,ERR_BAD_ADDRESS+MSG_SFX_CHANNELS_REGS+MSG_SET_TO_DEFAULT+'($00F0)');
103119
continue;
104120
end;
105-
if check('-chnregs:') or check('-Ac:') then
121+
if check('chnregs:') or check('Ac:') then
106122
begin
107123
getAddr(MSG_SFX_CHANNELS_REGS+' set:',SFX_CHANNELS_ADDR,$6C0,ERR_BAD_ADDRESS+MSG_SFX_CHANNELS_REGS+MSG_SET_TO_DEFAULT+'($06C0)');
108124
continue;
@@ -111,38 +127,38 @@ begin
111127
//
112128
//
113129

114-
if check('-notetable:') or check('-An:') then
130+
if check('notetable:') or check('An:') then
115131
begin
116132
getAddrP(MSG_NOTE_TABLE_DATA+' set:',NOTE_TABLE_ADDR,0,ERR_BAD_ADDRESS+MSG_NOTE_TABLE_DATA+MSG_ORIGIN_CONTINUE);
117133
NOTE_TABLE_PAGE:=NOTE_TABLE_ADDR shr 8;
118134
continue;
119135
end;
120-
if check('-sfxnotetable:') or check('-Ae:') then
136+
if check('sfxnotetable:') or check('Ae:') then
121137
begin
122138
getAddr(MSG_TABLE_OF_SFX_NOTE+' set:',SFX_NOTE_SET_ADDR,0,ERR_BAD_ADDRESS+MSG_TABLE_OF_SFX_NOTE+MSG_ORIGIN_CONTINUE);
123139
continue;
124140
end;
125-
if check('-sfxmodetable:') or check('-Am:') then
141+
if check('sfxmodetable:') or check('Am:') then
126142
begin
127143
getAddr(MSG_TABLE_OF_SFX_MODE+' set:',SFX_MODE_SET_ADDR,0,ERR_BAD_ADDRESS+MSG_TABLE_OF_SFX_MODE+MSG_ORIGIN_CONTINUE);
128144
continue;
129145
end;
130-
if check('-sfxtable:') or check('-As:') then
146+
if check('sfxtable:') or check('As:') then
131147
begin
132148
getAddr(MSG_TABLE_OF_SFX_PTRS+' set:',SFX_TABLE_ADDR,$0,ERR_BAD_ADDRESS+MSG_TABLE_OF_SFX_PTRS+MSG_ORIGIN_CONTINUE);
133149
continue;
134150
end;
135-
if check('-tabtable:') or check('-At:') then
151+
if check('tabtable:') or check('At:') then
136152
begin
137153
getAddr(MSG_TABLE_OF_TAB_PTRS+' set:',TAB_TABLE_ADDR,$F0,ERR_BAD_ADDRESS+MSG_TABLE_OF_TAB_PTRS+MSG_ORIGIN_CONTINUE);
138154
continue;
139155
end;
140-
if check('-songdata:') or check('-Ag:') then
156+
if check('songdata:') or check('Ag:') then
141157
begin
142158
getAddr(MSG_SONG_DATA+' set:',SONG_ADDR,$F0,ERR_BAD_ADDRESS+MSG_SONG_DATA+MSG_ORIGIN_CONTINUE);
143159
continue;
144160
end;
145-
if check('-data:') or check('-Ad:') then
161+
if check('data:') or check('Ad:') then
146162
begin
147163
getAddr(MSG_SFXTAB_DATA+' set:',SFX_DATA_ADDR,$F0,ERR_BAD_ADDRESS+MSG_SFXTAB_DATA+MSG_ORIGIN_CONTINUE);
148164
continue;
@@ -151,12 +167,12 @@ begin
151167
//
152168
//
153169

154-
if check('-makeconfig') or check('-MC') then
170+
if check('makeconfig') or check('MC') then
155171
begin
156172
confFN:=CONFIG_FILENAME;
157173
continue;
158174
end;
159-
if check('-makeresource') or check('-MR') then
175+
if check('makeresource') or check('MR') then
160176
begin
161177
If check(':') Then
162178
confFn := param
@@ -169,7 +185,7 @@ begin
169185
//
170186
//
171187

172-
if check('-reduce:') or check('-R:') then
188+
if check('reduce:') or check('R:') then
173189
begin
174190
if verbose>0 then write('Reducing: ');
175191
if pos('sfxonly',param)=1 then
@@ -195,7 +211,7 @@ begin
195211
continue;
196212
end;
197213

198-
if check('-reindex:') or check('-I:') then
214+
if check('reindex:') or check('I:') then
199215
begin
200216
if verbose>0 then write('Reindex: ');
201217
if pos('sfxonly',param)=1 then
@@ -221,16 +237,27 @@ begin
221237
continue;
222238
end;
223239

224-
if check('-verbose') or check('-v') then
240+
if check('verbose') or check('v') then
225241
begin
226242
verbose:=2; continue;
227243
end;
228-
if check('-silent') or check('-s') then
244+
if check('silent') or check('s') then
229245
begin
230246
verbose:=0; continue;
231247
end;
232248

233249
writeLn(stderr,'What is this `',param,'`? :O');
234250
haltError('Unrecognized parameter');
235251
end;
252+
253+
if length(outFN)>0 then
254+
begin
255+
outPath:=extractFilePath(outFN);
256+
outFN:=extractFileName(outFN);
257+
end
258+
else
259+
begin
260+
outPath:=extractFilePath(sourceFN);
261+
outFN:=extractFileName(sourceFN)+'.asm';
262+
end;
236263
end;

0 commit comments

Comments
 (0)