#! /usr/bin/perl # ptreader.pl - Papertape decoder for the Simh Data General Nova/Eclipse Simulator # The linux file PTP.OUT is produced by the RDOS BPUNCH command # PTP.OUT is a binary file that has a lot of leading and trailing nulls # The nulls are stripped off and the remainder is copied to the output # file PTP.TXT. Line endings are converted. # # ptreader provides a way to copy text files from # the simulated RDOS filesystem to the linux filesystem # # RDOS -> PTP.OUT -> ptreader.pl -> PTP.TXT # # Created by: James M. Lynes jr. # Created on: January 29,2024 # Last Modified: 01/29/2024 - Initial version # 01/30/2024 - Additional comments, fix line ending(0x0A) # # Usage: On RDOS: BPUNCH filename # Creates the (binary formatted) linux file: PTP.OUT # # On linux: ./ptreader.pl # Reads PTP.OUT and creates the reformated linux text file PTP.TXT # # Note: Use ptwriter.pl to format a linux text file to be read by RDOS use strict; use warnings; open(my $in, '<:raw', "PTP.OUT") or die; open(my $out, '>', "PTP.TXT") or die; my $content; my $length; my $maxlength = 4000; my @inbytes; my @outbytes; $length = read($in, $content, $maxlength); # Read the binary file print "Length: $length\n"; # Show total bytes read @inbytes = unpack("C*", $content); # Unpack bytes into an array foreach(@inbytes) { # Delete null bytes next if($_ == 0); push(@outbytes, $_); } foreach(@outbytes){printf ("0x%02X ", $_)}; # Show a hex dump of array print "\n"; foreach(@outbytes) { # Show the text read my $code = chr($_); if($_ == 0x0D) { $code = chr(0x0A); # Fix linux line ending } print "$code"; print $out $code; # Copy text to output file } close $in; close $out;