Jump to content

Windows: Fast turnaround for VHD (SD Card) debugging


Recommended Posts

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.


  • 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


  • 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 -n 2 > nul
copy out\*.PRG X:\
copy out\*.BIN X:\
VhdAttach.exe /detach test.vhd
ping -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.

Edited by AndyMt
Figured out how to put "RUN" into the clipboard, too.
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

Please review our Terms of Use