Grant Searle had created a set of programs for transferring files from Windows computers to CP/M systems via serial transfer. You use his packer Windows program to transform the original binary file into a hex formatted representation of the original binary file. Mr. Searle was kind enough to publish the format of his file format, as such I created a PowerShell script to convert files compatible with his download.com format.
This has been tested on Windows 7, 10, 11 (ARM) and I have been using it when setting up my own RC2014’s.
I thought I’d share it incase others may find it useful.
Examples:
fileconvert.ps1 -infile cpm22.sys -outfile cpm_hex.txt -fileappend
fileconvert.ps1 -infile cpm22.sys -outfile cpm_hex.txt
-userno 0 -fileappend
fileconvert.os1 -infile cpm22.sys -console
Parameters:
infile - This specifies the file to be read for conversion
outfile - This specifies the HEX file to be created or appended
to
fileappend - This causes the converted file to be added to
the end of the output file.
console - This causes the file to be converted to HEX but it’s
written to the screen instead of a file.
userno - Defines the CP/M user number (0-F) to be used,
typically user 0 is correct.
To use this file the text below needs to be copied to a file who's file name has a .PS1 extension. Then you would run the script from a PowerShell window.
<#
.SYNOPSIS
Powershell script
to convert a binary file into a RC2014 download.com hex formatted file.
.DESCRIPTION
Powershell script
to convert a binary file into a hex file suitable for uploading to a RC2014
using Grant Searle download.com CP/M utility and specifications. You specify a file to read and it's converted
and sent console or an output file. You
can append several conversions to a single output file, which makes it easier for batch uploads to your flashcard.
Example:
fileconvert.ps1 -infile cpm22.sys -outfile cpm_hex.txt -fileappend
fileconvert.ps1 -infile cpm22.sys -outfile cpm_hex.txt -userno 0
-fileappend
fileconvert.os1 -infile cpm22.sys -console
Created by Jim Bailey on July 15, 2020 (ver 1.0)
.PARAMETER infile
This specifies the file to be read for conversion
.PARAMETER outfile
This specifies
the HEX file to be created or appeneded to
.PARAMETER fileappend
This causes the
converted file to be added to the end of the output file.
.PARAMETER console
This causes the
file to be converted to HEX but its written to the screen instead of a file.
The append and outfile parameters will be ignored if the console is specified.
.PARAMETER userno
Defines the CP/M
user number (0-F) to be used, typically user 0 is correct.
#>
param(
[Parameter(Mandatory=$true)][string]$infile,
[Parameter(Mandatory=$false)][string]$outfile,
[Parameter(Mandatory=$false)][switch]$fileappend = $false,
[Parameter(Mandatory=$false)][switch]$console = $false,
[Parameter(Mandatory=$false)][string]$userno = 0
)
$userno = $userno.ToUpper()
if (!($userno -match "^[0-9A-F]{1}$")) {
write-output
"Error: UserNo must be between a hex value between 0-F."
write-output
" If not specified it defaults
to zero."
exit
}
if (Test-Path $infile) {
$bytes =
get-content $infile -encoding byte
# Convert string from binarary data to Hex data, also create
a var that contains the sum from each byte.
foreach ($byte in
$bytes)
{
$bytesum =
$bytesum + $byte
$byteinhex =
[string]::Format("{0:X}", $Byte)
$paddedhex +=
$byteinhex.PadLeft(2,"0")
}
#Extract "low byte" of file count in hex
$Bytecount =
$bytes.count
$bytecount =
$bytecount.ToString("X").padleft(2,'0')
$bytecount =
$bytecount.substring($bytecount.Length-2,2)
# Extract "Low byte" of stream sum (poor man's
CRC)
$bytesum =
$bytesum.ToString("X").padleft(2,'0')
$bytesum =
$bytesum.substring($bytesum.length-2,2)
# Format and output in RC2014 download.com format
$output =
"A:DOWNLOAD $infile`r`nU$userno`r`n:$paddedhex>$bytecount$bytesum"
if ($console) {
write-output
$output
} else {
if ($fileappend
-eq $true) {
Out-File
-FilePath $outfile -Append -InputObject $output -Encoding ASCII
} else {
if
(!(Test-Path $outfile)) {
Out-File
-FilePath $outfile -InputObject $output -Encoding ASCII
} else {
write-output "Error: Target/Destination file already
exists.`r`n Use the -fileappend
option to add to an existing file."
}
}
}
} Else {
write-output
"Error: '$infile' input file not found."
}
--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/cef630c7-6302-4689-8d1a-9b15ef4e29dan%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/036da668-4c80-4956-9475-fcb0d82b6a65n%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/036da668-4c80-4956-9475-fcb0d82b6a65n%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/036da668-4c80-4956-9475-fcb0d82b6a65n%40googlegroups.com.