1
0
mirror of https://github.com/AK6DN/dec-utilities-for-pdp.git synced 2026-01-11 23:42:54 +00:00

update Makefiles and add lbn2pbn utility

This commit is contained in:
AK6DN 2024-11-03 01:29:37 -07:00
parent 9c1bc9a32b
commit 51ba2b1388
10 changed files with 364 additions and 115 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
d8tape/z_pass
d8tape/z_fail
dumpbin8x/test
lbn2pbn/test
# Prerequisites
*.d

View File

@ -1,20 +1,24 @@
# makefile for pdp8 support routines
# makefile for pdp support routines
# system dependencies
ifeq ($(WINDIR),)
# unix
BINDIR=../bin
EXE=
ifeq ($(MAKE_HOST),x86_64-pc-cygwin)
# cygwin 64b
BINDIR=../exe64
EXE=.exe
else ifeq ($(MAKE_HOST),i686-pc-cygwin)
# cygwin 32b
BINDIR=../exe
EXE=.exe
else
# cygwin
BINDIR=../exe
EXE=.exe
# unix
BINDIR=../bin
EXE=
endif
# all the bins
BIN :=d8tape macro8x palbart
BIN :=d8tape lbn2pbn macro8x palbart
# all the scripts
SCR :=binchk dumpbin8x hex2mac rx_image_dump rx_image_convert config11 diffrom enet2hex img2sdcard simhtape
SCR :=binchk config11 diffrom dumpbin8x enet2hex hex2mac img2sdcard rx_image_dump simhtape
all: $(BIN)
for DIR in $^ ; do cd $$DIR && $(MAKE) $@ ; cd .. ; done
@ -28,4 +32,9 @@ install:: $(BIN)
install:: $(SCR)
for DIR in $^ ; do cp -v -p $$DIR/*.pl $(BINDIR) ; done
test::
@echo MAKE_HOST=$(MAKE_HOST)
@echo BINDIR=$(BINDIR)
@echo EXE=$(EXE)
# the end

View File

@ -18,6 +18,21 @@
# (or similar) to nullify its effects.
#
# system dependencies
ifeq ($(MAKE_HOST),x86_64-pc-cygwin)
# cygwin 64b
BINDIR=../../exe64
EXE=.exe
else ifeq ($(MAKE_HOST),i686-pc-cygwin)
# cygwin 32b
BINDIR=../../exe
EXE=.exe
else
# unix
BINDIR=../../bin
EXE=
endif
DEBUG = -g2
OBJECTS = main.o dasm.o flow.o
@ -38,7 +53,7 @@ flow.o: flow.c d8tape.h
dasm.o: dasm.c d8tape.h iot.h
install:
cp -v -p d8tape.exe ../../exe
cp -v -p d8tape$(EXE) $(BINDIR)
release:
make clean

53
lbn2pbn/Makefile Normal file
View File

@ -0,0 +1,53 @@
# makefile for pdp support routines
# system dependencies
ifeq ($(MAKE_HOST),x86_64-pc-cygwin)
# cygwin 64b
BINDIR=../../exe64
EXE=.exe
else ifeq ($(MAKE_HOST),i686-pc-cygwin)
# cygwin 32b
BINDIR=../../exe
EXE=.exe
else
# unix
BINDIR=../../bin
EXE=
endif
# omit frame pointer option needed for 25% speed improvment
OPTFLGS=-fno-strength-reduce -fomit-frame-pointer
# select compiler
CC=gcc
# cflags when making optimized version
CFLAGS=-O3 -Wall $(OPTFLGS)
# cflags when making debugging version
##CFLAGS=-g
# linker flags
LFLAGS=-lm
# system libs
LIBS=
# all the bins
BIN=lbn2pbn$(EXE)
all: $(BIN)
clean:
rm -f $(BIN) SRC.DSK DST.DSK SRC.RX2 DST.RX2
install:
cp -v -p $(BIN) $(BINDIR)
# make the binary
$(BIN): lbn2pbn.c
$(CC) $(CFLAGS) $(LFLAGS) $(LIBS) -o $@ $<
# run a test
test: $(BIN)
cd test && test.sh
# the end

22
lbn2pbn/ReadMe.txt Normal file
View File

@ -0,0 +1,22 @@
I used the technique you outlined in one of your early messages on thisthread. The only difference was that I used RT-11 rather than RSX:
- Boot RT-11 in simh (make sure RX is disabled and RY is enabled)
- Copy the logical disk image to RT-11 (say as dl0:disk.log)
- Attach a file to RY0:
^E
simh> attach ry0 disk.phy
simh> c
- Use DUP to copy the image to the RX02
.R DUP
*DY0:*=DL0:DISK.LOG/I/F
*^C
- Detach the file from RY0
The file “disk.phy” is now a physical copy of the original disk with track 0 present and the data
correctly interleaved and skewed. Ive been able to successfully boot the “AUTO”image mentioned above.

231
lbn2pbn/lbn2pbn.c Normal file
View File

@ -0,0 +1,231 @@
/*
* Sector layout converter for single-sided floppy disk images
* (Logical to Physical, and back)
*
* Copyright (c) 2024 Tony Lawrence
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names
* of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
inline
static size_t filesize(FILE* fp)
{
return fseek(fp, 0, SEEK_END) != 0 ? -1L : ftell(fp);
}
static int tracks = 0;
static int sectors = 0;
static int sector_size = 0;
static int interleave = 0;
static int track_skew = 0;
static int round = 0;
static int gcd(int a, int b)
{
while (a && b) {
if (a > b)
a %= b;
else
b %= a;
}
return a + b;
}
inline
static int lcm(int a, int b)
{
return (a * b) / gcd(a, b);
}
static int lbn2pbn(int lbn)
{
int track;
int sector;
track = lbn / sectors;
/* interleave */
sector = lbn % sectors;
sector *= interleave;
sector += sector / round;
/* track skew */
sector += track * track_skew;
/* PBN */
sector %= sectors;
track++;
track %= tracks;
return track * sectors + sector;
}
#ifdef __GNUC__
__attribute__((noreturn))
#endif
static void usage(const char* prog)
{
fprintf(stderr, "%s -T tracks -S sectors -B sector_size"
" -i interleave -k track_skew [-r] infile outfile\n", prog);
fprintf(stderr, "\nTypical parameters:\n"
"RX01: -T 77 -S 26 -B 128 -i 2 -k 6\n"
"RX02 (single density): -T 77 -S 26 -B 128 -i 2 -k 6\n"
"RX02 (double density): -T 77 -S 26 -B 256 -i 2 -k 6\n"
"RX50: -T 80 -S 10 -B 512 -i 2 -k 2\n"
"\nSupported sector sizes (in bytes): 128, 256, 512\n");
exit(2);
}
#ifndef __CYGWIN__
extern int opterr, optind;
extern char* optarg;
# ifndef _MSC_VER
# define _stricmp strcmp
# endif
#else
# define _stricmp strcasecmp
#endif
int main(int argc, char* argv[])
{
int reverse = 0;
const char* infile;
const char* outfile;
size_t max_size;
size_t size;
FILE* in;
FILE* out;
int p, q;
p = optind;
while ((q = getopt(argc, argv, "T:S:B:i:k:r")) != EOF) {
switch (q) {
case 'T':
tracks = atoi(optarg);
break;
case 'S':
sectors = atoi(optarg);
break;
case 'B':
sector_size = atoi(optarg);
if ((sector_size & (sector_size - 1))
|| sector_size < 128 || sector_size > 512) {
sector_size = 0;
}
break;
case 'i':
interleave = atoi(optarg);
break;
case 'k':
track_skew = atoi(optarg);
break;
case 'r':
if (!reverse) {
reverse = 1;
break;
}
/*FALLTHRU*/
default:
usage(argv[0]);
}
p = optind;
}
if (argv[p] && strcmp(argv[p], "--") == 0)
++p;
if (tracks <= 0 || sectors <= 0 || interleave <= 0 || track_skew < 0
|| interleave >= sectors || sector_size <= 0 || p != optind
|| !(infile = argv[p++]) || !(outfile = argv[p++]) || argv[p]
|| _stricmp(infile, outfile) == 0) {
usage(argv[0]);
}
if (!(in = fopen(infile, "rb"))) {
perror(infile);
return 1;
}
size = filesize(in);
q = tracks * sectors;
max_size = q * sector_size;
if (size > max_size) {
fprintf(stderr, "%s: file size (%zd) may not exceed %zu\n", infile, size, max_size);
return 1;
}
if (!(out = fopen(outfile, "wb"))) {
perror(outfile);
return 1;
}
rewind(in);
round = lcm(sectors, interleave);
for (p = 0; p < q; ++p) {
char sector[512];
int n = lbn2pbn(p);
#ifdef _DEBUG
printf("LBN %4d (%2d / %2d) = PBN %4d (%2d / %2d)\n",
p, p / sectors, p % sectors,
n, n / sectors, n % sectors);
#endif
if ( reverse && fseek(in, n * sector_size, SEEK_SET) != 0)
abort();
if (fread (sector, sector_size, 1, in) != 1)
memset(sector, 0, sector_size);
if (!reverse && fseek(out, n * sector_size, SEEK_SET) != 0)
abort();
if (fwrite(sector, sector_size, 1, out) != 1)
abort();
}
fclose(out);
fclose(in);
return 0;
}

View File

@ -1,14 +1,18 @@
# makefile for pdp8 support routines
# system dependencies
ifeq ($(WINDIR),)
# unix
BINDIR=../../bin
EXE=
ifeq ($(MAKE_HOST),x86_64-pc-cygwin)
# cygwin 64b
BINDIR=../../exe64
EXE=.exe
else ifeq ($(MAKE_HOST),i686-pc-cygwin)
# cygwin 32b
BINDIR=../../exe
EXE=.exe
else
# cygwin
BINDIR=../../exe
EXE=.exe
# unix
BINDIR=../../bin
EXE=
endif
# omit frame pointer option needed for 25% speed improvment

View File

@ -1,14 +1,18 @@
# makefile for pdp8 support routines
# system dependencies
ifeq ($(WINDIR),)
# unix
BINDIR=../../bin
EXE=
ifeq ($(MAKE_HOST),x86_64-pc-cygwin)
# cygwin 64b
BINDIR=../../exe64
EXE=.exe
else ifeq ($(MAKE_HOST),i686-pc-cygwin)
# cygwin 32b
BINDIR=../../exe
EXE=.exe
else
# cygwin
BINDIR=../../exe
EXE=.exe
# unix
BINDIR=../../bin
EXE=
endif
# omit frame pointer option needed for 25% speed improvment

View File

@ -1,46 +0,0 @@
# makefile for pdp8 support routines
# system dependencies
ifeq ($(WINDIR),)
# unix
BINDIR=../../bin
EXE=
else
# cygwin
BINDIR=../../exe
EXE=.exe
endif
# omit frame pointer option needed for 25% speed improvment
OPTFLGS=-fno-strength-reduce -fomit-frame-pointer
# select compiler
CC=gcc
# cflags when making optimized version
CFLAGS=-O3 -Wall $(OPTFLGS)
# cflags when making debugging version
##CFLAGS=-g
# linker flags
LFLAGS=-lm
# system libs
LIBS=
# all the bins
BIN=dy$(EXE)
all: $(BIN)
clean:
rm -f $(BIN)
install:
cp -v -p $(BIN) $(BINDIR)
# make the binary
dy$(EXE): dy.c
$(CC) $(CFLAGS) $(LFLAGS) $(LIBS) -o $@ $<
# the end

View File

@ -1,44 +0,0 @@
#include <stdio.h>
#define DY_TRACKS 77
#define DY_SECTORS 26
#define DY_NUM_BLOCKS ((DY_TRACKS-1) * DY_SECTORS)
int lbn2dy (int lbn)
{
int track;
int sector;
int half;
track = lbn / DY_SECTORS;
/* interleave 2 */
sector = lbn % DY_SECTORS;
half = sector >= DY_SECTORS / 2 ? 1 : 0;
sector <<= 1;
sector |= half;
/* track skew of 6 */
sector += track << 1;
sector += track << 1;
sector += track << 1;
sector %= DY_SECTORS;
track++;
track %= DY_TRACKS;
return track * DY_SECTORS + sector;
}
int main()
{
int n, m, t, s;
for (n = 0; n < DY_NUM_BLOCKS; ++n) {
m = lbn2dy(n);
t = m / DY_SECTORS;
s = 1 + (m % DY_SECTORS);
printf("Log Blk %4d -> Phy Trk %2d Sec %2d\n", n, t, s);
if (n % DY_SECTORS == DY_SECTORS-1) printf("\n");
}
}