Wouldn't it defy the purpose of an emulator, designed to mimic a machine as perfect as possible, if it can be detected? In general, every detectable difference must be considered a bug one would expect to be removed ASAP.
Some programs notice if they are run on a real C64 or an emulator.
It would be great if you could add some examples. Especially with notes if these programs do the detection reliably or only in certain configuration/situations.
How is this done?
Assuming that any of the named emulators is good enough to run most C64 software, I would look out for discrepancies in handling of external devices, most likely floppy disk drives. For example, by measuring the response time for various commands send to a drive. Measuring can be done by taking a CIA timer, put in PHI2 counting mode.
Three basic results can be measured:
Direct response to a transfer
(i.e. reaction/round trip times)
Response to CPU only commands
(i.e. answer given by the external device CPU without accessing the drive)
Response to positioning and read commands
(i.e. mechanical response like moving 20 tracks)
Each of this will give indicators about having an unmodified or a modified C64. Modification in this sense can have many meanings
- Faster drive electronics
- Faster drives or solid state drives
- Improved protocol (fastloaders/DOS)
- Emulator usage
Differences are only gradual, not absolute. A real fast response may come from an emulation that does not care for being as slow in floppy operations as the original (or simply accept the faster operation of the host PC). It may respond almost instant.
But similar results may as well come from a genuine C64 equipped with solid state drives, SD2IEC for example. With increased processing power available such devices may at one point as well deliver instant response with the real C64.
So for sure timing can only reveal relative differences to a genuine setup, not how they are achieved (*1). For this method I would give the response time within a single transmission the highest chance to find something.
I found some code to identify a C128 in C64 mode, but no code to identify emulation.
Detection of a C128 vs. a C64 is a different issue, as these machines do differ in certain details.
*1 - Not to mention that these measurements are only valid within the reference system given, so an emulation delivering the right relative timing may still run faster or slower.