Page 1 of 1

Windows: Fast turnaround for VHD (SD Card) debugging

Posted: Tue Apr 06, 2021 9:41 am
by AndyMt

During the last few days I've spent a lot of time debugging my software in the emulator, running from an SD card (VHD file). This is because some things in the emulator behave differently when loading stuff from SD card instead of the host file system.

Anyway: in Windows I found it quite fiddly to update the SD card VHD file for every debug cycle, so I came up with a solution to do speed things up.

After a cc65 build I now only have to run a single cmd file which even puts the LOAD"MYPROGRAM.PRG" and "RUN" into the clipboard. 

Now I just have to press CTRL+V and the PRG is loaded and started.

Prerequisites:


  • VHD Attach tool (OSFMount wasn't flexible enough for this, but maybe someone else figures it out)


  • an SD card VHD image (this is the one from the X16 github repo)


  • X16-emulator install directory is added to the system PATH environment variable


  • VHD Attach install directory is added to the system PATH environment variable


  • compiled PRG and BIN files of your software are to be found in the "out" subdirectory


Preparations:


  • attach (aka mount) the vhd file once by right clicking and selecting "attach"


  • note the drive letter which is assigned (in my case X:, it will stay the same)


  • put a first set of your files into the VHD


  • detach the VHD file (right click)


Now create a batch or cmd file which does the following:


  • attach the VHD file


  • wait 2 seconds 


  • copy PRG and BIN files to the assigned drive letter 


  • wait 2 seconds


  • detach the VHD file (so the emulator can use it)


  • put the load command into the clipboard


  • run emulator


Here is a sample .cmd file I've used:


VhdAttach.exe /attach test.vhd



ping 127.0.0.1 -n 2 > nul



copy out\*.PRG X:\



copy out\*.BIN X:\



VhdAttach.exe /detach test.vhd



ping 127.0.0.1 -n 2 > nul





(echo LOAD"INVADERZ.PRG",8 && echo RUN) | clip





x16emu.exe -sdcard test.vhd -scale 2 -keymap de-ch 


Replace "test.vhd" with the filename of your VHD file, the PRG name with yours and also select the correct keymap parameter (or remove it).

This saved me a lot of time, maybe it helps others, too.