is there any programmatic setup you could do on a 64 that would make it safe to insert a cartridge with the power on ?
This calls for a clear No, But :)
Why is it Risky?
In general it's unhealthy for two reasons:
- Pluggin may disrupt a running program by changing addressed content
- A cartridge may damage computer parts due
- being electrostatic charged or
- generate unexpected signal combinations.
Thus, no a cartridge should not be plugged or removed while the machine is powered on. Powering the C64 with a cartridge will always start that cartridge due its build in auto-start / auto-configuration feature (*1) the memory mapper uses to bank ROM in and Kernel uses to detect and start it.
Risk Assessment
While it's a general issue that one should never plug any stuff when powered unless explicit made to work that way (*2), depending on device and care taken it's usually way less risky than expected (*3). Just, we talk about a consumer class device sold in millions to non trained laymen. So it's mandatory for manufacturers to educate their customers whenever interfaces are mentioned.
But I Want to Copy Carts.
This will put any program (*4) intended to copy that cartridge at a problem: It must be in control prior to the cartridge and stay in control, not letting it take over the computer.
A safe way to allow copying goes by disabling that auto-start / auto-configuration feature. At hardware level this can be done by pulling the /EXROM and /GAME signals high, as nicely described here. Countless boards have been made using this. At minimum it's only a board with two resistors to be plugged in between C64 and cartridge-to-be-read, most had switches, so it could be used either/or, while some went all the way to luxurious(*5). But all following the same basic scheme of disabling the way the Kernel detects presence of a cartridge.
To copy one one needs to:
- Insert the 'copy' board
- Switch it to 'no detection'
- Insert the cartridge to be copied
- Power the C64 as usual
- Load and start the copy software
- Wait for a prompt (*6)
- Switch to 'regular operation'
- Start the copy process
Even with such a board risk isn't completely eliminated as switching under power may still produce glitches. Although it's be mostly a low risk.
But I Want a Cheap Hack
Yeah, spending money for hardware when C15 cassettes are already eating up most of the allowance is hard. Someone needs to come up with a software only way ... and best one that can be pirated as well, so all it costs is another C15 ;))
But a pure software based solution can't do all of the above as it got no chance to survive a power on with a cartridge inserted. Being 13 and strapped on cache makes one take a bit more risk. In this case living with risk #2 and use some software executing above sequence as
- Power the C64 as usual
- Load and start the copy software
- Wait for a prompt (*6)
- Insert the cartridge to be copied
- Start the copy process
With some careful handling chances are good that it will work - most of the time (*3).
Bottom line
No,it's not guaranteed to be safe, but risks are minimized and can be kept at bay with proper handling.
Bonus Question
is there any programmatic setup you could do on a 64 that would make it safe to insert a cartridge with the power on
The 'programmatic setup' here is the same as for the board based solution: have the CPU execute a loop that is completely contained in RAM accessible when either ROM mode is enabled and access only resourced which are as well enabled in all of those modes. Those are:
- RAM at 0000-0FFF
- IO at Dxxx
Doing so doesn't eliminate all hardware related risk (#2) but gives a pretty good chance.
*1 - Always good to keep in mind that the C64 was originally developed as a game console. The way cartridges are handled is one of the left overs.
*2 - This includes not just computers but all devices including hair dryers :)
*3 - And add a minute of silent for the poor slobs that fried their C64 one way or another :))
*4 - At least as long it's supposed to be reliable.
*5 - Including solutions that present them self as cartridge, loading the copying program from ROM into RAM before copying whatever was plugged in, automating copying all the way.
*6 - Given when the program moved itself to a secure location and entered a wait loop so that avoids touching any resource where the cartridges would be.