possible to tell if running on emulator ?

General Chit Chat about Sinclair Computers and their Clones
Post Reply
User avatar
Andy Rea
Posts: 1503
Joined: Fri May 09, 2008 2:48 pm
Location: notts UK

possible to tell if running on emulator ?

Post by Andy Rea » Thu Aug 10, 2017 6:46 pm

is there a way to tell from within a running program if we are running on an emulator or real hardware ?

regards Andy
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

dr beep
Posts: 1127
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: possible to tell if running on emulator ?

Post by dr beep » Thu Aug 10, 2017 8:21 pm

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: 2813
Joined: Thu May 08, 2008 5:45 pm

Re: possible to tell if running on emulator ?

Post by sirmorris » 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

User avatar
Andy Rea
Posts: 1503
Joined: Fri May 09, 2008 2:48 pm
Location: notts UK

Re: possible to tell if running on emulator ?

Post by Andy Rea » Thu Aug 10, 2017 9:09 pm

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:
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

dr beep
Posts: 1127
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: possible to tell if running on emulator ?

Post by dr beep » Thu Aug 10, 2017 9:15 pm

Well,

EightyOne has the vars-last-byte-bug, but then again your code would not load on real machine.

User avatar
1024MAK
Posts: 2152
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 » Thu Aug 10, 2017 9:32 pm

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

sirmorris
Posts: 2813
Joined: Thu May 08, 2008 5:45 pm

Re: possible to tell if running on emulator ?

Post by sirmorris » Fri Aug 11, 2017 7:54 am

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: 2813
Joined: Thu May 08, 2008 5:45 pm

Re: possible to tell if running on emulator ?

Post by sirmorris » Fri Aug 11, 2017 7:54 am

That's only EO though. I doubt such back doors exist for other emulators.

User avatar
Andy Rea
Posts: 1503
Joined: Fri May 09, 2008 2:48 pm
Location: notts UK

Re: possible to tell if running on emulator ?

Post by Andy Rea » Fri Aug 11, 2017 8:33 am

Cool...
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

Post Reply