|
|
|
@ -1,9 +1,16 @@ |
|
|
|
param([string]$Platform = "", [string]$Config = "", [int]$RomSize = 512, [string]$RomName = "") |
|
|
|
param([string]$Platform = "", [string]$Config = "", [int]$RomSize = 512, [string]$ROMName = "") |
|
|
|
|
|
|
|
# |
|
|
|
# This PowerShell script performs the heavy lifting in the build of RomWBW. It handles the assembly |
|
|
|
# of the HBIOS and then creates the final ROM image imbedding the other components such as the OS |
|
|
|
# images, boot loader, and ROM disk image. |
|
|
|
# If a PowerShell exception occurs, just stop the script immediately. |
|
|
|
$ErrorAction = 'Stop' |
|
|
|
|
|
|
|
# This PowerShell script is used to prepare the build environment for |
|
|
|
# HBIOS. It starts by validating and/or prompting the user for several |
|
|
|
# key variables that control the build: Platform, Config, ROM size, and |
|
|
|
# optionally an override for the output ROM name. These variables are |
|
|
|
# then placed in a generated batch command file allowing them to be |
|
|
|
# exposed to the subsequent build steps. Next, it generates a |
|
|
|
# small TASM include file that exposes some variables to the subsequent |
|
|
|
# assembly process. |
|
|
|
# |
|
|
|
# The RomWBW build is heavily dependent on the concept of a hardware "platform" and the associated |
|
|
|
# "configuration". The build process selects a pair of files that are included in the HBIOS assembly |
|
|
|
@ -19,6 +26,7 @@ param([string]$Platform = "", [string]$Config = "", [int]$RomSize = 512, [string |
|
|
|
# setup mechanism so that multiple configuration are not needed. When building for UNA, the pre-built |
|
|
|
# UNA BIOS is simply imbedded, it is not built here. |
|
|
|
# |
|
|
|
|
|
|
|
$PlatformListZ80 = "SBC", "MBC", "ZETA", "ZETA2", "RCZ80", "RCZ280", "EZZ80", "UNA" |
|
|
|
$PlatformListZ180 = "N8", "MK4", "RCZ180", "SCZ180", "DYNO" |
|
|
|
$PlatformListZ280 = "RCZ280" |
|
|
|
@ -28,6 +36,7 @@ $PlatformListZ280 = "RCZ280" |
|
|
|
# $Platform and loop requesting a new value as long as it is not valid. The valid platform |
|
|
|
# names are just hard-coded for now. |
|
|
|
# |
|
|
|
|
|
|
|
$PlatformList = $PlatformListZ80 + $PlatformListZ180 + $PlatformListZ280 |
|
|
|
$Prompt = "Platform [" |
|
|
|
ForEach ($PlatformName in $PlatformList) {$Prompt += $PlatformName + "|"} |
|
|
|
@ -45,6 +54,7 @@ while ($true) |
|
|
|
# if the requested ConfigFile exists. Config files must be named <platform>_<config>.asm where <platform> is |
|
|
|
# the platform name established above and <config> is the value of $Config determined here. |
|
|
|
# |
|
|
|
|
|
|
|
while ($true) |
|
|
|
{ |
|
|
|
$PlatformConfigFile = "Config/plt_${Platform}.asm" |
|
|
|
@ -63,6 +73,7 @@ while ($true) |
|
|
|
# are just hard-coded for now. The ROM size does nothing more than determine the size of the |
|
|
|
# ROM disk portion of the ROM image. |
|
|
|
# |
|
|
|
|
|
|
|
while ($true) |
|
|
|
{ |
|
|
|
if (($RomSize -eq 128) -or ($RomSize -eq 256) -or ($RomSize -eq 512) -or ($RomSize -eq 1024)) {break} |
|
|
|
@ -73,84 +84,33 @@ while ($true) |
|
|
|
# TASM should be invoked with the proper CPU type. Below, the CPU type is inferred |
|
|
|
# from the platform. |
|
|
|
# |
|
|
|
|
|
|
|
$CPUType = "80" |
|
|
|
if ($PlatformListZ180 -contains $Platform) {$CPUType = "180"} |
|
|
|
if ($PlatformListZ280 -contains $Platform) {$CPUType = "280"} |
|
|
|
|
|
|
|
# |
|
|
|
# The $RomName variable determines the name of the image created by the script. By default, |
|
|
|
# The $ROMName variable determines the name of the image created by the script. By default, |
|
|
|
# this will be <platform>_<config>.rom. Unless the script was invoked with a specified |
|
|
|
# ROM filename, the name is established below. |
|
|
|
# |
|
|
|
if ($RomName -eq "") {$RomName = "${Platform}_${Config}"} |
|
|
|
while ($RomName -eq "") |
|
|
|
{ |
|
|
|
$CP = (Read-Host -prompt "ROM Name [${Config}]").Trim() |
|
|
|
if ($RomName -eq "") {$RomName = $Config} |
|
|
|
} |
|
|
|
|
|
|
|
# If a PowerShell exception occurs, just stop the script immediately. |
|
|
|
$ErrorAction = 'Stop' |
|
|
|
|
|
|
|
# Directories of required build tools (TASM & cpmtools) |
|
|
|
$TasmPath = '..\..\tools\tasm32' |
|
|
|
$CpmToolsPath = '..\..\tools\cpmtools' |
|
|
|
|
|
|
|
# Add tool directories to PATH and setup TASM's TABS directory path |
|
|
|
$env:TASMTABS = $TasmPath |
|
|
|
$env:PATH = $TasmPath + ';' + $CpmToolsPath + ';' + $env:PATH |
|
|
|
|
|
|
|
# Initialize working variables |
|
|
|
$OutDir = "../../Binary" # Output directory for final image file |
|
|
|
$RomFmt = "wbw_rom${RomSize}" # Location of files to imbed in ROM disk |
|
|
|
$BlankROM = "Blank${RomSize}KB.dat" # An initial "empty" image for the ROM disk of proper size |
|
|
|
$RomDiskFile = "RomDisk.tmp" # Temporary filename used to create ROM disk image |
|
|
|
$RomFile = "${OutDir}/${RomName}.rom" # Final name of ROM image |
|
|
|
$ComFile = "${OutDir}/${RomName}.com" # Final name of COM image (command line loadable HBIOS/CBIOS) |
|
|
|
$ImgFile = "${OutDir}/${RomName}.img" # Final name of IMG image (memory loadable HBIOS/CBIOS image) |
|
|
|
$UpdFile = "${OutDir}/${RomName}.upd" # Final name of System ROM image |
|
|
|
|
|
|
|
# Select the proper CBIOS to include in the ROM. UNA is special. |
|
|
|
if ($Platform -eq "UNA") {$Bios = 'una'} else {$Bios = 'wbw'} |
|
|
|
|
|
|
|
# List of RomWBW proprietary apps to imbed in ROM disk. |
|
|
|
$RomApps = "assign","mode","rtc","syscopy","xm" |
|
|
|
if ($RomSize -gt "256") |
|
|
|
if ($ROMName -eq "") {$ROMName = "${Platform}_${Config}"} |
|
|
|
while ($ROMName -eq "") |
|
|
|
{ |
|
|
|
$RomApps += "fdu","format","survey","sysgen","talk","timer","inttest" |
|
|
|
$CP = (Read-Host -prompt "ROM Name [${Config}]").Trim() |
|
|
|
if ($ROMName -eq "") {$ROMName = $Config} |
|
|
|
} |
|
|
|
|
|
|
|
"" |
|
|
|
"Building ${RomName} ${ROMSize}KB ROM configuration ${Config} for Z${CPUType}..." |
|
|
|
"" |
|
|
|
|
|
|
|
# Current date/time is queried here to be subsequently imbedded in image |
|
|
|
$TimeStamp = '"' + (Get-Date -Format 'yyyy-MM-dd') + '"' |
|
|
|
|
|
|
|
# Function to run TASM and throw an exception if an error occurs. |
|
|
|
Function Asm($Component, $Opt, $Architecture=$CPUType, $Output="${Component}.bin", $List="${Component}.lst") |
|
|
|
{ |
|
|
|
$Cmd = "tasm -t${Architecture} -g3 -e ${Opt} ${Component}.asm ${Output} ${List}" |
|
|
|
$Cmd | write-host |
|
|
|
Invoke-Expression $Cmd | write-host |
|
|
|
if ($LASTEXITCODE -gt 0) {throw "TASM returned exit code $LASTEXITCODE"} |
|
|
|
} |
|
|
|
|
|
|
|
# Function to concatenate two binary files. |
|
|
|
Function Concat($InputFileList, $OutputFile) |
|
|
|
{ |
|
|
|
Set-Content $OutputFile -Value $null |
|
|
|
foreach ($InputFile in $InputFileList) |
|
|
|
{ |
|
|
|
Add-Content $OutputFile -Value ([System.IO.File]::ReadAllBytes($InputFile)) -Encoding byte |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
# |
|
|
|
# Since TASM has no mechanism to include files dynamically based on variables, a file |
|
|
|
# is built on-the-fly here for imbedding in the build process. This file is basically |
|
|
|
# just used to include the platform and config files. It also passes in some values |
|
|
|
# from the build to include in the build. |
|
|
|
# from the build to include in the assembly. |
|
|
|
# |
|
|
|
|
|
|
|
@" |
|
|
|
; RomWBW Configured for ${Platform} ${Config}, $(Get-Date -Format "s") |
|
|
|
@ -163,102 +123,17 @@ ROMSIZE .EQU ${ROMSize} |
|
|
|
; |
|
|
|
"@ | Out-File "build.inc" -Encoding ASCII |
|
|
|
|
|
|
|
# # Bring over previously assembled binary copy of Forth for later use. |
|
|
|
# Copy-Item '..\Forth\camel80.bin' 'camel80.bin' |
|
|
|
|
|
|
|
# Bring over previously generated font files. |
|
|
|
Copy-Item '..\Fonts\font*.asm' '.' |
|
|
|
|
|
|
|
# Assemble individual components. Note in the case of UNA, there is less to build. |
|
|
|
$RomComponentList = "dbgmon", "romldr", "eastaegg" |
|
|
|
ForEach ($RomComponentName in $RomComponentList) {Asm $RomComponentName} |
|
|
|
|
|
|
|
if ($Platform -ne "UNA") |
|
|
|
{ |
|
|
|
Asm 'hbios' '-dROMBOOT' -Output 'hbios_rom.bin' -List 'hbios_rom.lst' |
|
|
|
Asm 'hbios' '-dAPPBOOT' -Output 'hbios_app.bin' -List 'hbios_app.lst' |
|
|
|
Asm 'hbios' '-dIMGBOOT' -Output 'hbios_img.bin' -List 'hbios_img.lst' |
|
|
|
|
|
|
|
Asm 'nascom' |
|
|
|
Asm 'tastybasic' |
|
|
|
Asm 'game' |
|
|
|
Asm 'usrrom' |
|
|
|
Asm 'updater' |
|
|
|
Asm 'imgpad2' |
|
|
|
} |
|
|
|
|
|
|
|
# |
|
|
|
# Once all of the individual binary components have been created above, the final |
|
|
|
# ROM image is created by simply concatenating the pieces together as needed. |
|
|
|
# We need to pass the key variables controling the assembly process back |
|
|
|
# out to the calling batch file. We do this by generating a small |
|
|
|
# batch file which can be invoked by the calling batch file to expose |
|
|
|
# the variables. |
|
|
|
# |
|
|
|
"Building ${RomName} output files..." |
|
|
|
|
|
|
|
# Build 32K OS chunk containing the loader, debug monitor, and two OS images |
|
|
|
Concat 'romldr.bin', 'dbgmon.bin', "..\zsdos\zsys_${Bios}.bin", "..\cpm22\cpm_${Bios}.bin" osimg.bin |
|
|
|
|
|
|
|
# Build 20K OS chunk containing the loader, debug monitor, and one OS image |
|
|
|
Concat 'romldr.bin','dbgmon.bin', "..\zsdos\zsys_${Bios}.bin" osimg_small.bin |
|
|
|
|
|
|
|
# Build second and third 32K chunks containing supplemental ROM apps (not for UNA) |
|
|
|
if ($Platform -ne "UNA") |
|
|
|
{ |
|
|
|
Concat '..\Forth\camel80.bin', 'nascom.bin', 'tastybasic.bin', 'game.bin', 'eastaegg.bin', 'netboot.mod', 'updater.bin', 'usrrom.bin' osimg1.bin |
|
|
|
Concat 'imgpad2.bin' osimg2.bin |
|
|
|
} |
|
|
|
|
|
|
|
# |
|
|
|
# Now the ROM disk image is created. This is done by starting with a |
|
|
|
# blank ROM disk image of the correct size, then cpmtools is used to |
|
|
|
# add the desired files. |
|
|
|
# |
|
|
|
|
|
|
|
"Building ${RomSize}KB ${RomName} ROM disk data file..." |
|
|
|
|
|
|
|
# Create a blank ROM disk image to create a working ROM disk image |
|
|
|
Set-Content -Value ([byte[]](0xE5) * (([int]${RomSize} * 1KB) - 128KB)) -Encoding byte -Path $RomDiskFile |
|
|
|
|
|
|
|
if ($RomSize -gt 128) |
|
|
|
{ |
|
|
|
# Copy all files from the appropriate directory to the working ROM disk image |
|
|
|
cpmcp -f $RomFmt $RomDiskFile ../RomDsk/ROM_${RomSize}KB/*.* 0: |
|
|
|
|
|
|
|
# Add any platform specific files to the working ROM disk image |
|
|
|
if (Test-Path "../RomDsk/${Platform}/*.*") |
|
|
|
{ |
|
|
|
cpmcp -f $RomFmt $RomDiskFile ../RomDsk/${Platform}/*.* 0: |
|
|
|
} |
|
|
|
|
|
|
|
# Add the proprietary RomWBW applications to the working ROM disk image |
|
|
|
foreach ($App in $RomApps) |
|
|
|
{ |
|
|
|
cpmcp -f $RomFmt $RomDiskFile ../../Binary/Apps/$App.com 0: |
|
|
|
} |
|
|
|
|
|
|
|
# Add the CP/M and ZSystem system images to the ROM disk (used by SYSCOPY) |
|
|
|
cpmcp -f $RomFmt $RomDiskFile ..\cpm22\cpm_${Bios}.sys 0:cpm.sys |
|
|
|
cpmcp -f $RomFmt $RomDiskFile ..\zsdos\zsys_${Bios}.sys 0:zsys.sys |
|
|
|
|
|
|
|
# Set all the files in the ROM disk image to read only for extra protection under flash file system. |
|
|
|
cpmchattr -f $RomFmt $RomDiskFile r 0:*.* |
|
|
|
} |
|
|
|
|
|
|
|
# |
|
|
|
# Finally, the individual binary components are concatenated together to produce |
|
|
|
# the final images. |
|
|
|
# |
|
|
|
if ($Platform -eq "UNA") |
|
|
|
{ |
|
|
|
Copy-Item 'osimg.bin' ${OutDir}\UNA_WBW_SYS.bin |
|
|
|
Copy-Item $RomDiskFile ${OutDir}\UNA_WBW_ROM${ROMSize}.bin |
|
|
|
|
|
|
|
Concat '..\UBIOS\UNA-BIOS.BIN','osimg.bin','..\UBIOS\FSFAT.BIN',$RomDiskFile $RomFile |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Concat 'hbios_rom.bin','osimg.bin','osimg1.bin','osimg2.bin',$RomDiskFile $RomFile |
|
|
|
Concat 'hbios_rom.bin','osimg.bin','osimg1.bin','osimg2.bin' $UpdFile |
|
|
|
Concat 'hbios_app.bin','osimg_small.bin' $ComFile |
|
|
|
} |
|
|
|
|
|
|
|
# Remove the temporary working ROM disk file |
|
|
|
Remove-Item $RomDiskFile |
|
|
|
@" |
|
|
|
set Platform=${Platform} |
|
|
|
set Config=${Config} |
|
|
|
set ROMName=${ROMName} |
|
|
|
set ROMSize=${ROMSize} |
|
|
|
set CPUType=${CPUType} |
|
|
|
"@ | Out-File "build_env.cmd" -Encoding ASCII |
|
|
|
|