Skip to content

Commit b98c0e5

Browse files
committed
refactor: rename null_termination to null_trailing
1 parent b0f33ea commit b98c0e5

4 files changed

Lines changed: 28 additions & 28 deletions

File tree

‎README.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ xa-replacer path/to/target.str path/to/source.xa 7
6161
## Manifest
6262
The manifest text file must be in the following format:
6363
```
64-
chunk,type,file,null_termination,xa_file_number,xa_channel_number,xa_null_subheader
65-
```
66-
| Field | Value | Information |
67-
|-------------------|------------------|--------------------------------------------------------------------------------------------------|
68-
|`chunk` |`1`-`<stride>` |Sector chunk size to write between strides. Cannot be higher than the `<stride>` command. |
69-
|`type` |`xa` `xacd` `null`|`xa` for 2336 sector file. `xacd` for 2352 sector file. `null` for empty sectors. |
70-
|`file` |`my file.xa` |File name or path. Can be a relative or absolute path, but without "quotes". (omitted for `null`) |
71-
|`null_termination` |`0` or more |***OPTIONAL*** number of null-termination sectors after the end of the file. Defaults to `0`. |
72-
|`xa_file_number` |`0`-`255` |***OPTIONAL*** subheader file number identifier. Defaults to `file` original value (RAW copy). |
73-
|`xa_channel_number`|`0`-`254` |***OPTIONAL*** subheader channel number identifier. Defaults to `file` original value (RAW copy). |
74-
|`xa_null_subheader`|`0xFFFFFFFF` |***OPTIONAL*** subheader value for null-termination sectors. Defaults to 0x`xa_file_number`000000.|
64+
chunk,type,file,null_trailing,xa_file_number,xa_channel_number,xa_null_subheader
65+
```
66+
| Field | Value | Information |
67+
|-------------------|------------------|-------------------------------------------------------------------------------------------------|
68+
|`chunk` |`1`-`<stride>` |Sector chunk size to write between strides. Cannot be higher than the `<stride>` command. |
69+
|`type` |`xa` `xacd` `null`|`xa` for 2336 sector file. `xacd` for 2352 sector file. `null` for empty sectors. |
70+
|`file` |`my file.xa` |File name or path. Can be a relative or absolute path, but without "quotes". (omitted for `null`)|
71+
|`null_trailing` |`0` or more |***OPTIONAL*** number of trailing null sectors after the end of the file. Defaults to `0`. |
72+
|`xa_file_number` |`0`-`255` |***OPTIONAL*** subheader file number identifier. Defaults to `file` original value (RAW copy). |
73+
|`xa_channel_number`|`0`-`254` |***OPTIONAL*** subheader channel number identifier. Defaults to `file` original value (RAW copy).|
74+
|`xa_null_subheader`|`0xFFFFFFFF` |***OPTIONAL*** subheader value for `null_trailing` sectors. Defaults to 0x`xa_file_number`000000.|
7575

7676
>[!NOTE]
7777
>The deinterleaver's `sector_beg-end` and `stride` fields are purely informative and do not affect interleaving.

‎libxa_deinterleaver.hxx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public:
2020
int sectorChunk = 1;
2121
int sectorCount;
2222
int sectorStride;
23-
int nullTermination;
23+
int nullTrailing;
2424
uint8_t filenum;
2525
uint8_t channel;
2626
alignas(int) uint8_t nullSubheader[4];
@@ -252,16 +252,16 @@ private:
252252

253253
if (entry.filenum != buffer[FILENUM_OFFSET])
254254
goto END;
255-
else if (entry.nullTermination > 0)
255+
else if (entry.nullTrailing > 0)
256256
{
257257
if (entry.nullSubheader[1] == buffer[CHANNEL_OFFSET] && (entry.nullSubheader[2] | 0x80) == (buffer[SUBMODE_OFFSET] | 0x80) && isNull())
258-
entry.nullTermination++;
258+
entry.nullTrailing++;
259259
else
260260
goto END;
261261
}
262262
else if (isNull())
263263
{
264-
entry.nullTermination++;
264+
entry.nullTrailing++;
265265
memcpy(&entry.nullSubheader, &buffer[FILENUM_OFFSET], sizeof(entry.nullSubheader));
266266
}
267267
else if (eof || entry.channel != buffer[CHANNEL_OFFSET])
@@ -276,7 +276,7 @@ private:
276276
} while (true);
277277

278278
END:
279-
const int nullSectors = entry.nullTermination / entry.sectorChunk * entry.sectorStride + entry.nullTermination;
279+
const int nullSectors = entry.nullTrailing / entry.sectorChunk * entry.sectorStride + entry.nullTrailing;
280280
entry.endSec = currentSector - entry.sectorStride - nullSectors - 1;
281281

282282
if (entry.sectorStride > 0)
@@ -303,11 +303,11 @@ private:
303303
return;
304304
}
305305

306-
fprintf(manifest, "chunk,type,file,null_termination,xa_file_number,xa_channel_number" /*",xa_null_subheader"*/ ",sector_beg-end,stride\n");
306+
fprintf(manifest, "chunk,type,file,null_trailing,xa_file_number,xa_channel_number" /*",xa_null_subheader"*/ ",sector_beg-end,stride\n");
307307
for (const FileInfo &entry : entries)
308308
{
309309
fprintf(manifest, "%d,%s,%s,%d,%hhu,%hhu" /*",0x%02X%02X%02X%02X"*/ ",%d-%d,%d\n", entry.sectorChunk, type,
310-
entry.fileName.c_str(), entry.nullTermination, entry.filenum, entry.channel,
310+
entry.fileName.c_str(), entry.nullTrailing, entry.filenum, entry.channel,
311311
/*entry.nullSubheader[0], entry.nullSubheader[1], entry.nullSubheader[2], entry.nullSubheader[3],*/
312312
entry.begSec, entry.endSec, entry.sectorChunk + entry.sectorStride);
313313
}

‎libxa_interleaver.hxx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public:
2727
int sectorChunk = 1;
2828
int sectorCount;
2929
int sectorSize;
30-
int nullTermination;
30+
int nullTrailing;
3131
std::optional<uint8_t> filenum;
3232
std::optional<uint8_t> channel;
3333
alignas(int) uint8_t nullSubheader[4];
@@ -131,7 +131,7 @@ public:
131131

132132
if ((field = strtok_r(NULL, ",", &saveptr)))
133133
{
134-
entry.nullTermination = atoi(field);
134+
entry.nullTrailing = atoi(field);
135135
if ((field = strtok_r(NULL, ",", &saveptr)))
136136
{
137137
entry.filenum = atoi(field);
@@ -153,9 +153,9 @@ public:
153153
const int sectorCount = entry.sectorCount - 1;
154154
const int quotChunks = sectorCount / entry.sectorChunk;
155155
const int remChunks = sectorCount % entry.sectorChunk;
156-
const int nullTerm = (remChunks + entry.nullTermination) / entry.sectorChunk;
156+
const int nullTrail = (remChunks + entry.nullTrailing) / entry.sectorChunk;
157157
entry.endSec = entry.begSec + quotChunks * sectorStride + remChunks;
158-
nextBase = (entry.endSec / sectorStride + 1 + nullTerm) * sectorStride;
158+
nextBase = (entry.endSec / sectorStride + 1 + nullTrail) * sectorStride;
159159
}
160160

161161
for (int i = 0; i < entry.sectorChunk; ++i)
@@ -188,7 +188,7 @@ public:
188188
activeFiles++;
189189
auto &slot = slots[index];
190190
slot.entry = entry;
191-
slot.entry.nullTermination = ((entry.sectorCount - 1) % entry.sectorChunk + entry.nullTermination) / entry.sectorChunk;
191+
slot.entry.nullTrailing = ((entry.sectorCount - 1) % entry.sectorChunk + entry.nullTrailing) / entry.sectorChunk;
192192
slot.inputFile = fopen(slot.entry.filePath.string().c_str(), "rb");
193193
setvbuf(slot.inputFile, slot.stdiBuf.get(), _IOFBF, STDIO_IOFBF_SIZE);
194194
};
@@ -240,7 +240,7 @@ public:
240240

241241
if (inputFile != nullptr &&
242242
sectorCount >= entry.sectorCount &&
243-
entry.nullTermination-- <= 0)
243+
entry.nullTrailing-- <= 0)
244244
{
245245
activeFiles--;
246246
sectorCount = 0;
@@ -306,7 +306,7 @@ private:
306306
if (*reinterpret_cast<int *>(entry.nullSubheader) != 0)
307307
return;
308308
entry.nullSubheader[0] = entry.filenum.value_or(emptyBuffer[FILENUM_OFFSET]);
309-
//entry.nullSubheader[1] = entry.nullTermination >= 0 ? entry.channel.value_or(0) : 0;
309+
//entry.nullSubheader[1] = entry.nullTrailing >= 0 ? entry.channel.value_or(0) : 0;
310310
//entry.nullSubheader[2] = 0x48;
311311
//entry.nullSubheader[3] = 0x00;
312312
}

‎xa-replacer.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
6565
size_t track = 0;
6666
printf("Track AudioSectors NullSectors Beg-End_AudioSector\n");
6767
for (const auto &entry : entries)
68-
printf("#%-5zu%-13d%-12d%d-%d\n", track++, entry.sectorCount, entry.nullTermination, entry.begSec, entry.endSec);
68+
printf("#%-5zu%-13d%-12d%d-%d\n", track++, entry.sectorCount, entry.nullTrailing, entry.begSec, entry.endSec);
6969

7070
printf("Enter track number: #");
7171
const int ret = scanf("%zu", &track);
@@ -91,9 +91,9 @@ int main(int argc, char *argv[])
9191

9292
// Validate target available space
9393
const int srcSectorCount = srcSize / srcSectorSize;
94-
if (srcSectorCount > entry.sectorCount + entry.nullTermination)
94+
if (srcSectorCount > entry.sectorCount + entry.nullTrailing)
9595
{
96-
fprintf(stderr, "Error: Source exceeds target stream size by %d sector(s).\n", srcSectorCount - (entry.sectorCount + entry.nullTermination));
96+
fprintf(stderr, "Error: Source exceeds target stream size by %d sector(s).\n", srcSectorCount - (entry.sectorCount + entry.nullTrailing));
9797
return EXIT_FAILURE;
9898
}
9999

0 commit comments

Comments
 (0)