mirror of
https://github.com/open-simh/simtools.git
synced 2026-04-15 16:11:15 +00:00
LBN2PBN: Apply minor fixes and mention reverse conversion in README
This commit is contained in:
committed by
Timothe Litt
parent
405010f948
commit
ca2930c70a
@@ -27,7 +27,7 @@ gt7cvt | Convert a gt7 magtape dump to a SIMH magtape
|
|||||||
hpconvert | Convert an HP disc image between SIMH and HPDrive formats
|
hpconvert | Convert an HP disc image between SIMH and HPDrive formats
|
||||||
imd2dsk | Convert an ImageDisk (IMD) file to DSK (pure data)
|
imd2dsk | Convert an ImageDisk (IMD) file to DSK (pure data)
|
||||||
indent | Convert simulator sources to 4-column tabs
|
indent | Convert simulator sources to 4-column tabs
|
||||||
lbn2pbn | Logical-to-physical converter for single-sided floppy disk images
|
lbn2pbn | Logical-to-physical (and reverse) converter for single-sided floppy disk images
|
||||||
littcvt | Remove density maker from litt format tapes
|
littcvt | Remove density maker from litt format tapes
|
||||||
m8376 | Assembles 8 PROM files into a 32bit binary file
|
m8376 | Assembles 8 PROM files into a 32bit binary file
|
||||||
mt2tpc | Convert a simh simulated magtape to TPC format
|
mt2tpc | Convert a simh simulated magtape to TPC format
|
||||||
|
|||||||
@@ -44,6 +44,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define SECTOR_MIN_SIZE 128
|
||||||
|
#define SECTOR_MAX_SIZE 512
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
static size_t filesize(FILE* fp)
|
static size_t filesize(FILE* fp)
|
||||||
@@ -162,8 +165,8 @@ int main(int argc, char* argv[])
|
|||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
sector_size = atoi(optarg);
|
sector_size = atoi(optarg);
|
||||||
if ((sector_size & (sector_size - 1))
|
if (sector_size < SECTOR_MIN_SIZE || sector_size > SECTOR_MAX_SIZE
|
||||||
|| sector_size < 128 || sector_size > 512) {
|
|| (sector_size & (sector_size - 1))) {
|
||||||
sector_size = 0;
|
sector_size = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -198,7 +201,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
if (!(in = fopen(infile, "rb"))) {
|
if (!(in = fopen(infile, "rb"))) {
|
||||||
perror(infile);
|
perror(infile);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = filesize(in);
|
size = filesize(in);
|
||||||
@@ -206,18 +209,18 @@ int main(int argc, char* argv[])
|
|||||||
max_size = q * sector_size;
|
max_size = q * sector_size;
|
||||||
if (size > max_size) {
|
if (size > max_size) {
|
||||||
fprintf(stderr, "%s: file size (%zd) may not exceed %zu\n", infile, size, max_size);
|
fprintf(stderr, "%s: file size (%zd) may not exceed %zu\n", infile, size, max_size);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(out = fopen(outfile, "wb"))) {
|
if (!(out = fopen(outfile, "wb"))) {
|
||||||
perror(outfile);
|
perror(outfile);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rewind(in);
|
rewind(in);
|
||||||
round = lcm(sectors, interleave);
|
round = lcm(sectors, interleave);
|
||||||
for (p = 0; p < q; ++p) {
|
for (p = 0; p < q; ++p) {
|
||||||
char sector[512];
|
static unsigned char sector[SECTOR_MAX_SIZE];
|
||||||
int n = lbn2pbn(p);
|
int n = lbn2pbn(p);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
printf("LBN %4d (%2d / %2d) = PBN %4d (%2d / %2d)\n",
|
printf("LBN %4d (%2d / %2d) = PBN %4d (%2d / %2d)\n",
|
||||||
@@ -236,5 +239,5 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
fclose(out);
|
fclose(out);
|
||||||
fclose(in);
|
fclose(in);
|
||||||
return 0;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user