diff --git a/Source/BuildROM.cmd b/Source/BuildROM.cmd index 772e40d1..f1d11f4e 100644 --- a/Source/BuildROM.cmd +++ b/Source/BuildROM.cmd @@ -1,6 +1,4 @@ @echo off setlocal -rem pushd HBIOS && Powershell -ExecutionPolicy Unrestricted .\Build.ps1 %* || exit /b & popd - pushd HBIOS && call Build %* || exit /b & popd diff --git a/Source/BuildShared.cmd b/Source/BuildShared.cmd index 9805cdeb..fd88b2c1 100644 --- a/Source/BuildShared.cmd +++ b/Source/BuildShared.cmd @@ -11,3 +11,4 @@ pushd ZPM3 && call Build || exit /b & popd pushd Apps && call Build || exit /b & popd pushd Forth && call Build || exit /b & popd pushd Fonts && call Build || exit /b & popd +pushd RomDsk && call Build || exit /b & popd diff --git a/Source/Clean.cmd b/Source/Clean.cmd index c94afc65..a5e88c6c 100644 --- a/Source/Clean.cmd +++ b/Source/Clean.cmd @@ -15,3 +15,4 @@ pushd BPBIOS && call Clean.cmd & popd pushd HBIOS && call Clean.cmd & popd pushd Images && call Clean & popd pushd Prop && call Clean & popd +pushd RomDsk && call Clean & popd diff --git a/Source/HBIOS/Build.cmd b/Source/HBIOS/Build.cmd index b0b568af..f6639106 100644 --- a/Source/HBIOS/Build.cmd +++ b/Source/HBIOS/Build.cmd @@ -1,6 +1,103 @@ @echo off setlocal +:: +:: Build [ [ [ []]]] +:: + set TOOLS=../../Tools +set PATH=%TOOLS%\tasm32;%TOOLS%\zx;%PATH% + +set TASMTABS=%TOOLS%\tasm32 + +set ZXBINDIR=%TOOLS%/cpm/bin/ +set ZXLIBDIR=%TOOLS%/cpm/lib/ +set ZXINCDIR=%TOOLS%/cpm/include/ + PowerShell -ExecutionPolicy Unrestricted .\Build.ps1 %* || exit /b + +call build_env.cmd + +echo Building %ROMSize%K ROM %ROMName% for Z%CPUType% CPU... + +if %Platform%==UNA goto :UNA + +copy ..\Fonts\font*.asm . || exit /b + +:: +:: Build HBIOS Core (all variants) +:: +tasm -t%CPUType% -g3 -dROMBOOT hbios.asm hbios_rom.bin hbios_rom.lst || exit /b +tasm -t%CPUType% -g3 -dAPPBOOT hbios.asm hbios_app.bin hbios_app.lst || exit /b +tasm -t%CPUType% -g3 -dIMGBOOT hbios.asm hbios_img.bin hbios_img.lst || exit /b + +:: +:: Build ROM Components +:: +call :asm dbgmon +call :asm romldr +call :asm eastaegg +call :asm nascom +call :asm tastybasic +call :asm game +call :asm usrrom +call :asm updater +call :asm imgpad2 + +:: +:: Create ROM bank images by assembling components +:: + +copy /b romldr.bin + dbgmon.bin + ..\zsdos\zsys_wbw.bin + ..\cpm22\cpm_wbw.bin osimg.bin || exit /b +copy /b romldr.bin + dbgmon.bin + ..\zsdos\zsys_wbw.bin osimg_small.bin || exit /b +copy /b ..\Forth\camel80.bin + nascom.bin + tastybasic.bin + game.bin + eastaegg.bin + netboot.mod + updater.bin + usrrom.bin osimg1.bin || exit /b +copy /b imgpad2.bin osimg2.bin || exit /b + +:: +:: Create final ROM images +:: + +set RomDiskDat= +if %ROMSize% GTR 128 set RomDiskDat=..\RomDsk\rom%ROMSize%_wbw.dat + +copy /b hbios_rom.bin + osimg.bin + osimg1.bin + osimg2.bin + ..\RomDsk\rom%ROMSize%_wbw.dat %ROMName%.rom || exit /b +copy /b hbios_rom.bin + osimg.bin + osimg1.bin + osimg2.bin %ROMName%.upd || exit /b +copy /b hbios_app.bin + osimg_small.bin %ROMName%.com || exit /b + +:: +:: Copy to output directory +:: + +copy %ROMName%.rom ..\..\Binary || exit /b +copy %ROMName%.upd ..\..\Binary || exit /b +copy %ROMName%.com ..\..\Binary || exit /b + +goto :eof + +:: +:: UNA specific ROM creation +:: + +:UNA + +call :asm dbgmon +call :asm romldr + +copy /b romldr.bin + dbgmon.bin + ..\zsdos\zsys_una.bin + ..\cpm22\cpm_una.bin osimg.bin || exit /b + +copy /b osimg.bin ..\..\Binary\UNA_WBW_SYS.bin || exit /b +copy /b ..\RomDsk\rom%ROMSize%_una.dat ..\..\Binary\UNA_WBW_ROM%ROMSize%.bin || exit /b + +copy /b ..\UBIOS\UNA-BIOS.BIN + osimg.bin + ..\UBIOS\FSFAT.BIN + ..\RomDsk\rom%ROMSize%_una.dat %ROMName%.rom || exit /b + +copy %ROMName%.rom ..\..\Binary || exit /b + +goto :eof + +:asm +echo. +echo Building %1... +tasm -t80 -g3 -fFF %1.asm %1.bin %1.lst || exit /b +goto :eof + diff --git a/Source/HBIOS/Build.ps1 b/Source/HBIOS/Build.ps1 index afec56a6..4c519d01 100644 --- a/Source/HBIOS/Build.ps1 +++ b/Source/HBIOS/Build.ps1 @@ -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 _.asm where is # the platform name established above and 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,93 +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 _.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 an arbitrary command line, check the result, and throw an exception if an error occurs -Function RunCmd($Cmd) -{ - $Cmd | write-host - Invoke-Expression $Cmd | write-host - if ($LASTEXITCODE -gt 0) {throw "Application Error $LastExitCode"} -} - - -# 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") @@ -172,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. -# -"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. +# 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 ${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 - RunCmd "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}/*.*") - { - RunCmd "cpmcp -f $RomFmt $RomDiskFile ../RomDsk/${Platform}/*.* 0:" - } - - # Add the proprietary RomWBW applications to the working ROM disk image - foreach ($App in $RomApps) - { - RunCmd "cpmcp -f $RomFmt $RomDiskFile ../../Binary/Apps/$App.com 0:" - } - - # Add the CP/M and ZSystem system images to the ROM disk (used by SYSCOPY) - RunCmd "cpmcp -f $RomFmt $RomDiskFile ..\cpm22\cpm_${Bios}.sys 0:cpm.sys" - RunCmd "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. - RunCmd "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 diff --git a/Source/HBIOS/Clean.cmd b/Source/HBIOS/Clean.cmd index c2194335..d35f7fcb 100644 --- a/Source/HBIOS/Clean.cmd +++ b/Source/HBIOS/Clean.cmd @@ -5,10 +5,12 @@ if exist *.bin del *.bin if exist *.com del *.com if exist *.img del *.img if exist *.rom del *.rom +if exist *.upd del *.upd if exist *.lst del *.lst if exist *.exp del *.exp if exist *.tmp del *.tmp if exist *.mrk del *.mrk if exist *.sys del *.sys if exist build.inc del build.inc -if exist font*.asm del font*.asm \ No newline at end of file +if exist font*.asm del font*.asm +if exist build_env.cmd del build_env.cmd diff --git a/Source/RomDsk/Build.cmd b/Source/RomDsk/Build.cmd new file mode 100644 index 00000000..965a2dd0 --- /dev/null +++ b/Source/RomDsk/Build.cmd @@ -0,0 +1,59 @@ +@echo off +setlocal + +set TOOLS=../../Tools + +set PATH=%TOOLS%\tasm32;%TOOLS%\zx;%TOOLS%\srecord;%TOOLS%\cpmtools;%PATH% + +set TASMTABS=%TOOLS%\tasm32 + +set ZXBINDIR=%TOOLS%/cpm/bin/ +set ZXLIBDIR=%TOOLS%/cpm/lib/ +set ZXINCDIR=%TOOLS%/cpm/include/ + +:: +:: Make all variants of the ROM Disk contents image. Three sizes are +:: created for each of the different ROM sizes possible (256K, 512K, 1024K). +:: Also, the UNA ROM Disks contain different versions of the OS files. +:: +:: Note that the sizes specified below are not the size of the final +:: ROM. The ROM reserves 128K for code space. So, the size created is +:: the final ROM size less 128K. +:: + +:: MakeDisk + +set RomApps=assign mode rtc syscopy xm + +call :MakeDisk rom256_wbw 0x20000 wbw_rom256 ROM_256KB wbw +call :MakeDisk rom256_una 0x20000 wbw_rom256 ROM_256KB una + +set RomApps=%RomApps% fdu format survey sysgen talk timer inttest + +call :MakeDisk rom512_wbw 0x60000 wbw_rom512 ROM_512KB wbw +call :MakeDisk rom512_una 0x60000 wbw_rom512 ROM_512KB una + +call :MakeDisk rom1024_wbw 0xE0000 wbw_rom1024 ROM_1024KB wbw +call :MakeDisk rom1024_una 0xE0000 wbw_rom1024 ROM_1024KB una + +goto :eof + +:MakeDisk +set Output=%1 +set Size=%2 +set Format=%3 +set Content=%4 +set Bios=%5 + +echo Making ROM Disk %Output% + +srec_cat -Generate 0 %Size% --Constant 0xE5 -Output %Output%.dat -Binary || exit /b + +cpmcp -f %Format% %Output%.dat %Content%/*.* 0: || exit /b +for %%f in (%RomApps%) do cpmcp -f %Format% %Output%.dat ../../Binary/Apps/%%f.com 0: || exit /b +cpmcp -f %Format% %Output%.dat ..\cpm22\cpm_%Bios%.sys 0:cpm.sys || exit /b +cpmcp -f %Format% %Output%.dat ..\zsdos\zsys_%Bios%.sys 0:zsys.sys || exit /b + +cpmchattr -f %Format% %Output%.dat r 0:*.* || exit /b + +goto :eof diff --git a/Source/RomDsk/Clean.cmd b/Source/RomDsk/Clean.cmd new file mode 100644 index 00000000..0b90e072 --- /dev/null +++ b/Source/RomDsk/Clean.cmd @@ -0,0 +1,4 @@ +@echo off +setlocal + +if exist *.dat del *.dat