#! /usr/bin/perl # ptwriter.pl - Papertape encoder for the Simh Data General Nova/Eclipse Simulator # The linux file PTR.IN is a binary formatted file which can # be read from the RDOS $PTR1 device. # # The user is prompted for the linux text file to convert # # ptwriter provides a way to copy text files from # the linux filesystem to the simulated RDOS filesystem # # linux file -> ptwriter.pl -> PTR.IN -> RDOS # # Created by: James M. Lynes jr. # Created on: January 30,2024 # Last Modified: 01/30/2024 - Initial version # # # Usage: On linux: ./ptwriter.pl # Creates the (binary formatted) linux file: PTR.IN # User is prompted for the linux text file name # # On RDOS: XFER/A $PTR1 filename # Copies linux file PTP.IN to RDOS file filename # # # Note: Use ptreader.pl to format a RDOS binary file into a linux text file use strict; use warnings; print "\n\n"; print "ptwriter - convert linux text file to RDOS papertape input file\n"; print "===============================================================\n"; print "Input linux text file name: "; my $lfile = ; chomp($lfile); open(my $in, '<', $lfile) or die; open(my $out, '>', "PTR.IN") or die; my @inbytes; my @bytes; my @outbytes; my $outbytes; my @binbytes; while(my $line = <$in>) { # Read text file convert to binary @bytes = unpack('C*', $line); push(@outbytes, @bytes); } my $len = $#outbytes + 1; print "Characters Read: $len\n\n"; #foreach(@outbytes){printf ("0x%02X ", $_)}; # Show a hex dump of array #print "\n\n"; foreach(@outbytes) { my $code = $_; if($code == 0x0A) { # Convert linux line end to RDOS line end $code = 0x0C; } # printf("0x%02X ", $code); # Show the converted text push(@binbytes, $code); } #print "\n\n"; #foreach(@binbytes) {printf ("0x%02X ", $_)}; # *** Output data looks good at this point *** #print "\n\n"; my $ctr = 0; foreach(@binbytes) { # *** This code not producing correct my $c = $binbytes[$ctr]; # binary file *** print "$c"; print $out $c; $ctr = $ctr + 1; } close $in; close $out;