possible to tell if running on emulator ?

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

possible to tell if running on emulator ?

Post by Andy Rea » Thu Aug 10, 2017 5: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: 1045
Joined: Thu Jun 16, 2011 7:35 am
Location: Boxmeer

Re: possible to tell if running on emulator ?

Post by dr beep » Thu Aug 10, 2017 7: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.

User avatar
sirmorris
Posts: 2671
Joined: Thu May 08, 2008 4:45 pm
Location: oxon, uk

Re: possible to tell if running on emulator ?

Post by sirmorris » Thu Aug 10, 2017 7: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
--=== ZXpand+ ... A more moderner all-in-one upgrade solution for ZX81 ===--
* SD/MMC storage * 32K Hires-capable RAM * AY sound chip * Joystick port * Serial *
* BASIC enhancements - plug & play * Reset button * Auto-boot facility *

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

Re: possible to tell if running on emulator ?

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

sirmorris wrote:
Thu Aug 10, 2017 7: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: 1045
Joined: Thu Jun 16, 2011 7:35 am
Location: Boxmeer

Re: possible to tell if running on emulator ?

Post by dr beep » Thu Aug 10, 2017 8: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: 1780
Joined: Mon Sep 26, 2011 9: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 8: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

User avatar
sirmorris
Posts: 2671
Joined: Thu May 08, 2008 4:45 pm
Location: oxon, uk

Re: possible to tell if running on emulator ?

Post by sirmorris » Fri Aug 11, 2017 6: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.
--=== ZXpand+ ... A more moderner all-in-one upgrade solution for ZX81 ===--
* SD/MMC storage * 32K Hires-capable RAM * AY sound chip * Joystick port * Serial *
* BASIC enhancements - plug & play * Reset button * Auto-boot facility *

User avatar
sirmorris
Posts: 2671
Joined: Thu May 08, 2008 4:45 pm
Location: oxon, uk

Re: possible to tell if running on emulator ?

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

That's only EO though. I doubt such back doors exist for other emulators.
--=== ZXpand+ ... A more moderner all-in-one upgrade solution for ZX81 ===--
* SD/MMC storage * 32K Hires-capable RAM * AY sound chip * Joystick port * Serial *
* BASIC enhancements - plug & play * Reset button * Auto-boot facility *

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

Re: possible to tell if running on emulator ?

Post by Andy Rea » Fri Aug 11, 2017 7: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

Who is online

Users browsing this forum: No registered users and 1 guest