Login
Back to forumReply to this topicGo to last reply

Posted By

George
on 2024-11-20
05:09:25
 Detect if a program runs on real hardware or emulator

Hi all,

is there a way for a programm to find out, if it runs on an emulator or real hardware?

Posted By

Csabo
on 2024-11-20
08:20:41
 Re: Detect if a program runs on real hardware or emulator

If you open Giana Sisters in VICE for example, you will see a message that says "THIS EMULATOR IS NOT RECOMMENDED".


VICE is unfortunately not able to run a lot of the modern games or demos. Due to it's poor emulation, it is possible to detect VICE specifically, see this example program.

YAPE and Plus4Emu on the other hand are so accurate that you can't tell - at least I'm not aware of any detection methods for the current versions, I haven't seen this in any program.

Posted By

George
on 2024-11-20
08:34:30
 Re: Detect if a program runs on real hardware or emulator

@Csabo, thank you!

As suggestion would be to define an unused register in the Emulator with a specific value.

Posted By

Csabo
on 2024-11-20
09:38:39
 Re: Detect if a program runs on real hardware or emulator

This came up on the forum a couple of times ([ 1 ], [ 2 ]) but that was years ago. IIRC the consensus was that we should not do anything like this. The goal should be the opposite: everything as close to the original as possible, and Plus/4 software should not be concerned with emulation.

Posted By

gerliczer
on 2024-11-20
12:02:31
 Re: Detect if a program runs on real hardware or emulator

Testing unstable unintended instructions?

Posted By

George
on 2024-11-20
13:40:08
 Re: Detect if a program runs on real hardware or emulator

or initialize a series of registers with naturally random values with specific values..

Posted By

Lavina
on 2024-11-20
13:47:20
 Re: Detect if a program runs on real hardware or emulator

There are still some TED specific features that YAPE does not emulate in a 100% way... but how to detect that with a program, I'm not sure and those features have not even been used in any released sw. However, Plus4Emu appears to correctly emulate those as well...

Posted By

Crown
on 2024-11-20
15:54:09
 Re: Detect if a program runs on real hardware or emulator

RAM refresh is a feature which has the highest chance of not being emulated for the longest.

The easier way is to verify if RAM refresh cycles are executed, that they are actually reading the $ffxx area via reading unconnected I/O space the cycle after. But this is also easy to emulate properly.

The harder method would be, to interfere with the RAM refresh address counter (it's easy to reset) deny a certain set of address space to ever being READ, repeat this for a given time (multiple seconds for certain types of RAM chips), then check whether there was any bit decay in the READ denied address space. Of course this is possible to emulate as well, but slightly more complex.

Posted By

SukkoPera
on 2024-11-20
16:36:03
 Re: Detect if a program runs on real hardware or emulator

This might give false positives on a machine where the memory has been replaced with SRAM! happy

I tend to agree with @Csabo though: this should just not be done. I tried to do it myself in the past, in order to circumvent some VICE bugs, but in the end it's just better to write the most compatible code in the first place, which works everywhere.

Posted By

SVS
on 2024-11-21
04:16:15
 Re: Detect if a program runs on real hardware or emulator

Time ago I asked for this feature. IMO it could be very useful in the case of emulator running. For example a program able to understand if it is running at 2x or 3x speed (by emulator) could automatically fix the timing of some operations.
It would be sufficient to set a memory cell, normally=0 in the real machine, with a non-null value. If still =0 it is the real machine, =1 emulator at 100%, =2 emulator at 200%.
My proposal was not accepted claiming some purist motivations, but be mind that there are already some non-standard features, for example the IEC drive emulations.

Posted By

gerliczer
on 2024-11-21
05:12:01
 Re: Detect if a program runs on real hardware or emulator

Dear SVS, if you must, you may call those of us purists who think it is better not emulating non-existent features, but please show us one single memory cell that is normally=0 in the real machine ... If still =0 it is the real machine, =1 emulator at 100%, =2 emulator at 200% and has no or cannot have function or purpose.

Posted By

SVS
on 2024-11-21
08:54:30
 Re: Detect if a program runs on real hardware or emulator

Hi gerliczer,
I don't think that purist is offensive word, but if yes pls. forgive me. I meant who has the opinion that the emulation must be nearest possible to the original.
Regarding my suggestion: it is clear that the original value of the cell we define as flag for emulator/true-machine could have any original value. When not original, then it is an emulator.
For example, the Solder's OS96 uses FCEF FCF0 just to sign the version of his O.S. (this use also demonstrates that these locations are never used by standard O.S.).

Posted By

George
on 2024-11-21
07:42:34
 Re: Detect if a program runs on real hardware or emulator

Another Idea:
It could be defined as a user definable option in the emulator.
Like: Initiate Adresss XYZ with Value xy. (Standard off)

So its not a standard feature, but could be checked on if needed for development purposes.

I need it, because my in my "3d-Engine" the OPEN command behaves defferent on emulator and on real machine (SD2IEC-drive). Emulator loads sequential files without .prg suffix of the filename. Real machine needs "".prg" suffix. Just an example.

Posted By

gerliczer
on 2024-11-21
09:03:59
 Re: Detect if a program runs on real hardware or emulator

@SVS: Let me try to explain what out problem is with an imaginary conversation.

(Imaginary Wheat Harvester Machine "Purist") This machine is such a cool one. I liked it from my early childhood.
(Imaginary Wheat Harvester Machine "SVS") Yes, indeed. It is my favourite, too. How cool would that be, if it were able to harvest maize and rice, too.
(IWHMP) Sure, it can be modified. That way, it will be a fine Super Combined Harvester.
(IWHMS) No, no, no! It most certainly is and definitely will be a Wheat Harvester.
(IWHMP) But Wheat Harvesters cannot work on maize or rice. You cannot call a machine capable of things no Wheat Harvester can do a WH.
(IWHMS) Yes I can and will. My WH is capable of harvesting not only wheat, but rice and corn too. What is this nonsense about Super Combined Harvesters?

This is why we told you, that what you want is not an emulator but a fantasy computer. If the real machine is not capable of doing even just one thing the emulator can, from the perspective of the running programme, then that emulator is not an emulator any more.

Regarding the offensiveness of the word purist, it is again a question of semantics. I (we) don't have much problem with CPLD based memory expansions, or 6502 based CPU replacements, or even with SD2IEC or tcbm2sd like devices. A purist would. I (we) find it not fitting when you are using it to describe me (us). If it makes you feel better then call me (us) purist(s), but you will use the word incorrectly.

@George: It is not a fault lying with the real machines or the highly accurate emulators if an SD2IEC does not properly emulate a real IEC drive. It is the fault of the drive emulator. Your programme should be capable of working around these problems. An SD2IEC, AFAIK, can be identified within the means standard CBMDOS provides.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon