3030Begin
3131 If f.getByte(noteTabId) Then exit;
3232 // read ID
33- If noteTabId>maxNoteTables-1 Then haltError(' Bad index of note table definition ' );
33+ If noteTabId>maxNoteTables-1 Then haltError(ERR_SMMFILE_NOTETABLE_BAD_ID );
3434
3535 f.getBlock(IOBuf,NOTETABnameLength+64 );
3636 // read data
@@ -54,31 +54,31 @@ Begin
5454
5555 If (isSFX) Then
5656 Begin
57- If id>maxSFXs-1 Then haltError(' Bad index of SFX definition ' );
57+ If id>maxSFXs-1 Then haltError(ERR_SMMFILE_SFX_BAD_ID );
5858
5959 If f.getByte(_sfxMode) Then exit;
6060 // read SFX Modulation Type
61- If _sfxMode>3 Then haltError(' ' );
61+ If _sfxMode>3 Then haltError(ERR_SMMFILE_SFX_MOD_BAD_ID );
6262
6363 sfxmodes[id] := _sfxMode;
6464
6565 If f.getByte(_sfxNoteTabOfs) Then exit;
6666 // read SFX note table index
67- If _sfxNoteTabOfs>3 Then haltError(' Bad note table of SFX definition ' );
67+ If _sfxNoteTabOfs>3 Then haltError(ERR_SMMFILE_SFX_NOTETABLE_BAD_ID );
6868 sfxnote[id] := _sfxNoteTabOfs*$40 ;
6969 inc(totalSFX);
7070 End
7171 Else
7272 Begin
73- If id-64 >maxTABs-1 Then haltError(' ' );
73+ If id-64 >maxTABs-1 Then haltError(ERR_SMMFILE_TAB_BAD_ID );
7474 id := id-64 ;
7575
7676 inc(totalTAB);
7777 End ;
7878
7979 If f.getBlock(dataSize,2 ) Then exit;
8080 // read data size
81- If dataSize>256 +nameLength Then haltError(' Incorrect length of SFX/TAB data ' );
81+ If dataSize>256 +nameLength Then haltError(ERR_SMMFILE_INCORRECT_DATA_LENGTH );
8282
8383 f.getBlock(IOBuf,dataSize);
8484 // read data
@@ -93,13 +93,15 @@ Begin
9393 move(IOBuf[0 ],sfxnames[id][1 ],len);
9494 sfxptr[id] := topPtr;
9595 sfxSizes[id] := dataSize;
96+ sfxUsage[id] := id;
9697 End
9798 Else
9899 Begin
99100 tabnames[id][0 ] := char(len);
100101 move(IOBuf[0 ],tabnames[id][1 ],len);
101102 tabptr[id] := topPtr;
102103 tabSizes[id] := dataSize;
104+ tabUsage[id] := id;
103105 End ;
104106 move(IOBuf[nameLength],data[topPtr],dataSize);
105107 inc(topPtr,dataSize);
@@ -118,7 +120,7 @@ Begin
118120
119121 If f.getBlock(dataSize,2 ) Then exit;
120122 // read data size
121- If dataSize>256 Then haltError(' Incorrect song data length ' );
123+ If dataSize>256 Then haltError(ERR_SMMFILE_INCORRECT_SONG_DATA_LENGTH );
122124
123125 f.getBlock(song,dataSize);
124126 // read data
@@ -138,49 +140,49 @@ Begin
138140End ;
139141
140142Begin
141- // TODO: Sprawdź najpierw, czy plik źródłowy istnieje!
142- // TODO: Przerwij z błędem, jeżeli nie istnieje!
143-
144143 if verbose>0 then
145144 begin
146- writeLn(stdout) ;
147- write(stdout, ' Reading ` ' +fn+ ' ` file... ' );
145+ EOLStdOut ;
146+ writeStdOut(STDOUT_READING_SMM_FILE,[fn] );
148147 end ;
148+ if not fileExists(fn) then
149+ haltError(ERR_SOURCE_NOT_EXIST);
150+
149151 totalSFX := 0 ;
150152 totalTAB := 0 ;
151153 f.openFile(fRead,fn);
152154 While (f.IOErr=0 ) And (Not f.EOF) Do
153- Begin
154- // get tag
155- If (Not f.getBlock(IOBuf,5 )) Then
156- Begin
157- If compareTag(section_main) Then
158- loadMain()
159- Else If compareTag(section_NOTE) Then
160- loadNoteTab()
161- Else If compareTag(section_SFX) Then
162- loadDefinition(true,SFXNameLength)
163- Else If compareTag(section_TAB) Then
164- loadDefinition(false,TABNameLength)
165- Else If compareTag(section_SONG) Then
166- loadSONG()
167- Else
168- haltError(' Incorrect TAG in source file ' );
169- End
170- Else
171- haltError(' Unexpected end of file ' );
172- // break;
173- End ;
155+ Begin
156+ // get tag
157+ If (Not f.getBlock(IOBuf,5 )) Then
158+ Begin
159+ If compareTag(section_main) Then
160+ loadMain()
161+ Else If compareTag(section_NOTE) Then
162+ loadNoteTab()
163+ Else If compareTag(section_SFX) Then
164+ loadDefinition(true,SFXNameLength)
165+ Else If compareTag(section_TAB) Then
166+ loadDefinition(false,TABNameLength)
167+ Else If compareTag(section_SONG) Then
168+ loadSONG()
169+ Else
170+ haltError(ERR_SMMFILE_INCORRECT_TAG );
171+ End
172+ Else
173+ haltError(ERR_SMMFiLE_UNEXPECTED_EOF );
174+ // break;
175+ End ;
174176 If f.IOErr<>0 Then
175- haltError(' Unexpected end of file ' );
177+ haltError(ERR_SMMFiLE_UNEXPECTED_EOF );
176178 f.closeFile();
177179
178180 if verbose>0 then
179181 begin
180- writeLn(stdout );
181- writeLn(stdout, totalSFX, ' SFX(s) declared ' );
182- writeLn(stdout, totalTAB, ' TAB(s) declared ' );
183- writeLn(stdout, ' Data (SFXs & TABs) size: ' , topPtr, ' byte(s) ' );
184- writeLn(stdout) ;
182+ EOLStdOut( 2 );
183+ writeLnStdOut(STDOUT_SUMMARY_SFX,[ totalSFX] );
184+ writeLnStdOut(STDOUT_SUMMARY_TAB,[ totalTAB] );
185+ writeLnStdOut(STDOUT_SUMMARY_DATA_SIZE,[ topPtr] );
186+ EOLStdOut ;
185187 end ;
186188End ;
0 commit comments