Skip to content

Commit a541054

Browse files
added ability to set path for output files of the converter
1 parent d215148 commit a541054

3 files changed

Lines changed: 35 additions & 9 deletions

File tree

smm-conv/src/inc/parseParams.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ begin
7373
if paramCount<1 then
7474
showInstruction();
7575
sourceFN:=paramStr(1);
76-
outFN:=paramStr(2);
76+
outFN:=extractFileName(paramStr(2));
77+
outPath:=extractFilePath(paramStr(2));
7778
currentParam:=3;
7879
while currentParam<=paramCount do
7980
begin

smm-conv/src/inc/save_asm.inc

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,25 @@ var
129129
if (addr<>0) then
130130
begin
131131
temp_org:=org; org:=addr;
132-
assign(f,subFn+'.asm');
132+
o:=concat(outPath,subFn,'.asm');
133+
assign(f,o);
134+
write(o);
133135
rewrite(f);
134-
writeLn(fres,resLabel,' rcasm ''',subFn,'.asm'';');
136+
writeLn(fres,resLabel,' rcasm ''',outPath+subFn,'.asm'';');
135137
result:='RESOURCE.RESOURCE.RCASM??.RESOURCE._SFX_API.'+resLabel;
136138
end
137139
else
138140
begin
139-
assign(f,fn);
140-
append(f);
141+
o:=concat(outPath,fn);
142+
assign(f,o);
143+
if not fileExists(o) then
144+
rewrite(f)
145+
else
146+
append(f);
147+
write(o);
141148
result:='';
142149
end;
150+
writeLn();
143151
write(f,'; org $',hexstr(org,4));
144152
writeLn(f,' ; ',stringOfChar('-',40));
145153
writeLn(f);
@@ -208,18 +216,34 @@ var
208216
begin
209217
temp_org:=0; oorg:=org;
210218
NOTE_TABLE_ADDR:=NOTE_TABLE_PAGE shl 8;
219+
if not directoryExists(outPath) then
220+
begin
221+
write('Creating directory `'+outPath+'`...');
222+
if createDir(outPath) then
223+
writeLn('OK')
224+
else
225+
begin
226+
haltError('Fail');
227+
end;
228+
end;
229+
if fileExists(outPath+fn) then
230+
begin
231+
deleteFile(outPath+fn);
232+
end;
211233

212234
if length(confFN)<>0 then
213235
begin
214-
assign(fconf,confFN);
236+
writeLn(outPath+confFN);
237+
assign(fconf,outPath+confFN);
215238
rewrite(fconf);
216239
end
217240
else
218241
fconf:=stdout;
219242

220243
if length(resFN)<>0 then
221244
begin
222-
assign(fres,resFN);
245+
writeLn(outPath+resFn);
246+
assign(fres,outPath+resFN);
223247
rewrite(fres);
224248
end
225249
else
@@ -306,7 +330,7 @@ begin
306330

307331
if (org<>oorg) then
308332
begin
309-
writeLn(fres,'SFX_ORG rcasm ''',fn,''';');
333+
writeLn(fres,'SFX_ORG rcasm ''',outPath+fn,''';');
310334
end;
311335

312336
if length(resFN)<>0 then

smm-conv/src/smm-conv.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
uses SysUtils;
2-
{$I-}
2+
// {$I-}
33

44
type
55
TTag = array[0..4] of byte;
@@ -63,6 +63,7 @@
6363

6464
sourceFN:string = '';
6565
outFN:string = '';
66+
outPath:string = '';
6667
confFN:string = '';
6768
resFN:string = '';
6869

0 commit comments

Comments
 (0)