Yeah, I guess when I say "contemporary" I also think "vaguely hardware equivalent" - at least in terms of overall power. Obviously there's always been some level of emulation on high-end equipment going on (that's how they generally wrote software in the first place, before dev kits became commonplace). I'm sure someone could easily write an Intellivision emulator on a 1979-era mainframe - but I'm thinking an INTV emulator on a Colecovision, or similar.
I think this breaks down into two parts. If we assume that the host is Turing complete
, I believe the only absolute constraint to emulating a target is having enough memory and / or backing store on the host to represent the full state of the target. Even this constraint can be relaxed in some circumstances by using greater memory compression in the host than is present in the target. Typically this ratio of required memory is close to 1:1 because the size of the target machine state is typically dominated by memory and backing store. Other bits a pieces like registers are negligible. You can artificially raise this ratio trading memory efficiency in order to gain performance, which brings us to the second aspect.
The second part is the performance of the emulated system relative to the target. Here I think your suggested ratio of 10:1 is typical of a simple interpreting emulator. This can vary quite a bit depending on how well matched the target and host are. This ratio can also be reduced significantly using techniques like Just-In-Time compilation
. I think the best example of this is Apple's Rosetta software
used in the switch from PowerPC to Intel processors. Although the numbers are disputed there are suggestions
that the ratio was about 2:1 in this case.
Bringing this back to StudioVision, things are not quite as they seem, because of the PML interpreter / emulator within the Studio II. What we have is that the combined performance of the CP1610 native and COSMAC emulated bits of the StudioVision PML interpreter are roughly the same as the Studio II's all COSMAC PML interpreter running half the time. When stated like this it is not nearly so impressive. The only reason StudioVision is in the same ballpark is because the Studio II is also running an emulator. As I think I said earlier, the most important thing when emulating on the Intellivision is to be really
picky about what you target.
I have not measured the relative performance of COSMAC CPU emulator within StudioVision to the actual COSMAC CPU, but I would expect it is nearer 20:1 than 10:1. This is primarily because of the poor architectural match between the CPU's. The COSMAC has 16, 16 bit registers in addition to its 8 bit accumulator (so these have to be stored in memory on the Intellivision not in registers), all of which must be manipulated 1 byte at a time because of the 8 bit accumulator (something the CP1610 cannot do natively) and any of which could be selected to be either the program counter or stack pointer (again has to be modelled in software on the Intellivision).
The native bits of the StudioVision PML interpreter make up for this complexity by being run more of the time (the 50% the real Studio II spends drawing the screen) and being optimised to the CP1610's 8 16bit register architecture, rather than being a straight translation. For example here is the main PML decode loop of the COSMAC PML interpreter, as reverse engineered by Paul Robson:
And here is the alternative CP1610 equivalent also present in StudioVision, you can still see traces of the original in the comments, but much of the hard stuff is now done 16 bits at a time using lookup tables, rather than bashing the high (ghi / phi) and low (glo, plo) bytes of various 16 bit registers:
Something that has occurred to me is StudioVision does show that back in the day Mattel could have produced a relatively simple hardware adapter, similar to the ShockVision adapter, that would have allowed the Intellivision to play any of the RCA Studio II game cartridges directly, potentially without infringing on RCA's copyrights. And this could have given Studio II owners with games an upgrade path to the Intellivision. Clearly given that the Studio II was not a commercial success this is unlikely to ever have been considered, but I think the technical possibility is interesting.
Edited by decle, Thu Jan 19, 2017 12:57 AM.