Re: 16BIT ROM CART THOUGHTS
Posted: 16 Oct 2018 18:19
Been a couple of months since last update.. But I have started to assemble this now.. Hopefully get it finished up this week....
We welcome retro users & hardware gurus alike! Come and join the party :)
https://www.exxosforum.co.uk/forum/
Code: Select all
function Convert-HexStringToByteArray
{
################################################################
#.Synopsis
# Convert a string of hex data into a System.Byte[] array. An
# array is always returned, even if it contains only one byte.
#.Parameter String
# A string containing hex data in any of a variety of formats,
# including strings like the following, with or without extra
# tabs, spaces, quotes or other non-hex characters:
# 0x41,0x42,0x43,0x44
# \x41\x42\x43\x44
# 41-42-43-44
# 41424344 ==
# The string can be piped into the function too.
################################################################
[CmdletBinding()]
Param ( [Parameter(Mandatory = $True, ValueFromPipeline = $True)] [String] $String )
#Clean out whitespaces and any other non-hex crud.
$String = $String.ToLower() -replace '[^a-f0-9\\,x\-\:]'
# Try to put into canonical colon-delimited format.
$String = $String -replace '0x|\x|\-|,',':'
#Remove beginning and ending colons, and other detritus.
$String = $String -replace '^:+|:+$|x|\'
#Maybe there's nothing left over to convert...
if ($String.Length -eq 0) { ,@() ; return }
#Split string with or without colon delimiters.
if ($String.Length -eq 1)
{ ,@([System.Convert]::ToByte($String,16)) }
elseif (($String.Length % 2 -eq 0) -and ($String.IndexOf(":") -eq -1))
{ ,@($String -split '([a-f0-9]{2})' | foreach-object { if ($_) {[System.Convert]::ToByte($_,16)}}) }
elseif ($String.IndexOf(":") -ne -1)
{ ,@($String -split ':+' | foreach-object {[System.Convert]::ToByte($_,16)}) }
else
{ ,@() }
#The strange ",@(...)" syntax is needed to force the output into an
#array even if there is only one element in the output (or none).
}
function Write-FileByte
{
################################################################
#.Synopsis
# Overwrites or creates a file with an array of raw bytes.
#.Parameter ByteArray
# System.Byte[] array of bytes to put into the file. If you
# pipe this array in, you must pipe the [Ref] to the array.
#.Parameter Path
# Path to the file as a string or as System.IO.FileInfo object.
# Path as a string can be relative, absolute, or a simple file
# name if the file is in the present working directory.
#.Example
# write-filebyte -bytearray $bytes -path outfile.bin
#.Example
# [Ref] $bytes | write-filebyte -path c:\temp\outfile.bin
################################################################
[CmdletBinding()] Param (
[Parameter(Mandatory = $True, ValueFromPipeline = $True)] [System.Byte[]] $ByteArray,
[Parameter(Mandatory = $True)] $Path )
if ($Path -is [System.IO.FileInfo])
{ $Path = $Path.FullName }
elseif ($Path -notlike "*\*") #Simple file name.
{ $Path = "$pwd" + "\" + "$Path" }
elseif ($Path -like ".\*") #pwd of script
{ $Path = $Path -replace "^\.",$pwd.Path }
elseif ($Path -like "..\*") #parent directory of pwd of script
{ $Path = $Path -replace "^\.\.",$(get-item $pwd).Parent.FullName }
else
{ throw "Cannot resolve path!" }
[System.IO.File]::WriteAllBytes($Path, $ByteArray)
}
$File1 = Read-Host "Enter Filename"
$CA_MAGIC = "ABCDEF42"
$CA_NEXT1 = "00000000"
$CA_INIT1 = "00000000"
$CA_RUN1 = "00FA0026"
$CA_TIMEDATE = "00000000"
$CA_SIZE1 = [string]("{0:X}" -f ((Get-ChildItem ".\$File1").Length)).PadLeft(8, '0')
$CA_NAME1 = (("$File1" | Format-Hex | Select-Object -Expand Bytes | ForEach-Object { '{0:X2}' -f $_ }) -join '').PadRight(28, '0')
$Pad = "2A6F000449FA008C41EC001C43ED0100202C0002D0AC0006D0AC000EE288538032D851C8FFFC200F082C000000196706202C000AD08932FC0000B0896EF84A90672043ED010022097000D3D8D39110186710B03C00016606D2FC00FE60F0D2C060EA43ED010022092B410008202C00022B40000CD2802B410010202C00062B400014D2802B4100182B6C000A001C91C84ED1"
$Program1 = [string]::join('', (gc ".\$File1" -en byte | % {'{0:X2}' -f $_}))
$Hex = ($CA_MAGIC+$CA_NEXT1+$CA_INIT1+$CA_RUN1+$CA_TIMEDATE+$CA_SIZE1+$CA_NAME1+$Pad+$Program1 | % {$_.PadRight(262144, '0')})
Convert-HexStringToByteArray $Hex | Write-FileByte -Path "$file1.stc"
Yeah, I manually do hex stuff when making complex carts. Can you test the yaart image from the previous page?exxos wrote: 24 Jan 2019 16:23 No idea what a powershell script is, but sure be useful for someone :)
I'm using good old hex workshop here :)
Now I remember you saying about that RAM disk think as well now! I don't think there is space in the ROM for it all though :(
The cart with the ramdisk is 128KB.exxos wrote: 24 Jan 2019 16:36Now I remember you saying about that RAM disk think as well now! I don't think there is space in the ROM for it all though :(
I think it might have been me who posted the cart image in the first place and I use it all the time, but I also need the TT one which czietz hasn't created yet.