possible to tell if running on emulator ?

General Chit Chat about Sinclair Computers and their Clones
Post Reply
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

possible to tell if running on emulator ?

Post 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
what's that Smell.... smells like fresh flux and solder fumes...
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: possible to tell if running on emulator ?

Post 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.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: possible to tell if running on emulator ?

Post 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
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: possible to tell if running on emulator ?

Post 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
:lol: :lol: :lol:

I had actually considered asking the user such a question....

Then i remembered the monkey :mrgreen:
what's that Smell.... smells like fresh flux and solder fumes...
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: possible to tell if running on emulator ?

Post by dr beep »

Well,

EightyOne has the vars-last-byte-bug, but then again your code would not load on real machine.
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: possible to tell if running on emulator ?

Post 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] :P

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: possible to tell if running on emulator ?

Post 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

Code: Select all

XOR A
OUT (1),a
IN a,(1)
would give you 0x85.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: possible to tell if running on emulator ?

Post by sirmorris »

That's only EO though. I doubt such back doors exist for other emulators.
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: possible to tell if running on emulator ?

Post by Andy Rea »

Cool...
what's that Smell.... smells like fresh flux and solder fumes...
Post Reply