Not sure about the firmware side of things but if I use "charlieplexing" I can control the 4 row and the reset optocoupler switches using 3 pins and the 10 column optocoupler switches with 4 wires. This allows plenty to have both ISP for an SD card and serial memory and I2C for a display even when using a Nano.
You can get a bit more memory when using a Nano by changing the boot loader to a Nano one.
Have done a schematic in Kicad and now to breadboard the design and see if it works. Not sure what value to use for the resistors as there are 2 resisters in series for each optocoupler with the "charlieplexing" design
. Need to check the current drawn and what is a good "on" current - must remember to read the datasheets.
I'll let you know how I get on - although there might be a slight delay as the PCB I have done for a fix to the Nascom 2 has just turned up so I need to test that first
Cheers
David