Friday, April 11, 2025

Create MSX-2 deploy script with AI. (Draft)

MSX-2 Disk Deployment Script Requirements

This document outlines the complete functionality for a PowerShell script that builds a bootable MSX-2 .dsk image from a BASIC project.

Input Parameters

  • MainBasPath (Required, String): Full path to the main .BAS file.
  • ProjectName (Optional, String): Optional project name. Defaults to the base name of the .BAS file.

Folder and File Structure

Work Folder

  • Location: Sibling to the folder containing MainBasPath.
  • Name Format: ProjectName_Hash (the hash is 6 characters from a GUID).
  • Contents: Renumbered .BAS files and AUTOEXEC.BAS.

Disk Image

  • Name: ProjectName.dsk.
  • Location: Same parent folder as the folder containing MainBasPath.
  • Base: Created by copying the "New 720KB Boot Disk.dsk" template.
  • Overwrite: If the file already exists, it is overwritten.

Steps

  1. Resolve and Print All Paths
    • Compute all paths (folders, tools, and output) at the top of the script and print them.
  2. Create Work Folder
    • Create a work folder as a sibling to the project folder using the format: ProjectName_Hash.
  3. Create AUTOEXEC.BAS
    • Create AUTOEXEC.BAS in the work folder.
    • The file content should be: RUN "MainFile.BAS" (using the actual main file name), written in ASCII.
  4. Copy and Renumber .BAS Files
    1. Copy all .BAS files from the folder containing MainBasPath to the work folder.
    2. Renumber each .BAS file by calling the external renumbering script:
      D:WorkspaceMSXtoolsrenumber.ps1 -FilePath -Step 10 -Start 10
  5. Create and Populate Disk Image
    1. Copy the template image "New 720KB Boot Disk.dsk" to the destination DiskImage path, overwriting any existing file.
    2. Add each file from the work folder to the disk image using the command:
      dsktool.exe A "C:pathtoimage.dsk" "C:pathtofile.ext"
    3. If adding a file fails, print the exact command used for troubleshooting.
  6. Cleanup or Error Handling
    1. If all files are added successfully, delete the work folder and print "Deployment Complete".
    2. If any file fails to add, do not delete the work folder and print "Deployment Failed" along with the error information and the failed command.

Additional Notes

  • All paths are fully resolved and printed before any processing begins.
  • Original file casing is preserved in the disk image.
  • The final disk image will overwrite any existing file with the same name.
  • Failures in file addition are clearly reported along with the command used.