Page 1 of 1
possible to tell if running on emulator ?
Posted: Thu Aug 10, 2017 6:46 pm
by Andy Rea
is there a way to tell from within a running program if we are running on an emulator or real hardware ?
regards Andy
Re: possible to tell if running on emulator ?
Posted: Thu Aug 10, 2017 8:21 pm
by dr beep
If an emulator is well coded you can't.
Only when the hardware is not well emulated you might have a wrong read from i.e. not connected hardware.
Like the ZX Spectrum emulator on the SAM coupe that reads BASIC IN from the SAM and without fix would return a value that is not available on any ZX Spectrum.
Re: possible to tell if running on emulator ?
Posted: Thu Aug 10, 2017 8:50 pm
by sirmorris
+1 Dr. Beep. IO is the usual way.
10 PRINT "IO IO IS THIS RUNNING IN AN EMULATOR?"
20 INPUT A$
30 IF A$ = "YES" THEN EMULATOR = 1
Re: possible to tell if running on emulator ?
Posted: Thu Aug 10, 2017 9:09 pm
by Andy Rea
sirmorris wrote: ↑Thu Aug 10, 2017 8:50 pm
+1 Dr. Beep. IO is the usual way.
10 PRINT "IO IO IS THIS RUNNING IN AN EMULATOR?"
20 INPUT A$
30 IF A$ = "YES" THEN EMULATOR = 1
I had actually considered asking the user such a question....
Then i remembered the monkey
Re: possible to tell if running on emulator ?
Posted: Thu Aug 10, 2017 9:15 pm
by dr beep
Well,
EightyOne has the vars-last-byte-bug, but then again your code would not load on real machine.
Re: possible to tell if running on emulator ?
Posted: Thu Aug 10, 2017 9:32 pm
by 1024MAK
Simple, ask the
monkey sorry user to press [CONTROL]+[ALT]+[DELETE] or if they can't find the those keys, instead press [NEW LINE]
Mark
Re: possible to tell if running on emulator ?
Posted: Fri Aug 11, 2017 7:54 am
by sirmorris
You can tell if you're running on EO by using OUT (1) and IN (1) which returns you a config byte.
Code: Select all
switch(Address&255)
{
case 0x01:
{
char *config;
config=(char *)(&zx81);
return(config[configbyte]);
}
...
typedef struct config
{
CFGBYTE emuid, major,minor,testver;
So
would give you 0x85.
Re: possible to tell if running on emulator ?
Posted: Fri Aug 11, 2017 7:54 am
by sirmorris
That's only EO though. I doubt such back doors exist for other emulators.
Re: possible to tell if running on emulator ?
Posted: Fri Aug 11, 2017 8:33 am
by Andy Rea
Cool...