Home
Home
First Prev Contents Next Last
First - Prev - Contents - Next - Last
Deutsch
Deutsch

Appendix F: Emulator Detection - Where am I?

Writers of software on the VIC-20 or emulators may wish to know if the "machine" their code is executing on is a real VIC-20, or not (e.g. for disabling fastloaders). The following standard method for emulator detection has been derived from the C64 emulator detection standard by Roland Lieger for Power20. Several other emulator authors have stated that they too will support this standard is future versions of their programs.

Emulator detection is based on a special use of the addresses $9F80-$9FFF. See the following listing for details.

If you want to test this program on Power20, just copy the text from this document and paste it into an open Power20 emulator window. Power20 will respond with the following message:

    Power20 (4.9.5)
   Commodore VIC-20
  for Power Macintosh
(C) 2008 Roland Lieger

If the emulator detection awareness of Power20 should cause trouble with a program it can be disabled using the Options/ROM Patches dialog.

100 REM ********* WHERE AM I? *********
110 REM -------------------------------
120 REM THIS IS THE RECOMMENDED METHOD
130 REM HOW TO DETECT A VIC20 EMULATOR,
140 REM E.G. FOR DISABLING FAST LOADERS
150 REM
160 REM - THE BYTE AT $9FFF CHANGES
170 REM   BETWEEN $55 AND $AA ON EVERY
180 REM   WRITE ACCESS
190 REM - THE BYTE AT $9FFE CONTAINS
200 REM   THE EMULATOR ID LETTER:
210 REM   / = POWER20
220 REM   M = EMULATOR OF MATT BROWNE
230 REM   V = VICE
240 REM   P = PFAU ZEH
250 REM   C = PCVIC
260 REM   L = V20
270 REM - THE WORD AT $9FFC CONTAINS
280 REM   THE EMULATOR VERSION NUMBER,
290 REM   E.G. $0120 FOR VERSION 1.2
300 REM - THE BYTES FROM $9FA0 CONTAIN
310 REM   A COPYRIGHT STRING WITH
320 REM   EMULATOR NAME, VERSION AND
330 REM   COPYRIGHT, $0D AND $00.
340 REM -------------------------------
350 :
500 PRINT
510 X=40959: REM $9FFF
520 IF PEEK(X)=85 THEN POKE X,0
530 IF PEEK(X)<>170 THEN 1000
540 POKE X,0
550 IF PEEK(X)<>85  THEN 1000
560 POKE X,0
570 IF PEEK(X)<>170 THEN 1000
580 POKE X,0
590 IF PEEK(X)<>85  THEN 1000
595 :
600 M$=CHR$(PEEK(40958)): REM $9FFE
610 PRINT "EMU-ID='"; M$; "' ";
620 IF M$="/" THEN PRINT "(POWER20)";
630 IF M$="M" THEN PRINT "(MATT BROWNE)";
640 IF M$="V" THEN PRINT "(VICE)";
650 IF M$="P" THEN PRINT "(PFAU ZEH)";
660 IF M$="C" THEN PRINT "(PCVIC)";
670 IF M$="L" THEN PRINT "(V20)";
680 PRINT
690 :
700 V=PEEK(40957)*256 + PEEK(40956): REM $9FFD/$9FFC
710 H$="0123456789ABCDEF"
720 FOR I=0 TO 3
730 V$=MID$(H$,1+(V AND 15),1)+V$
740 V=INT(V/16)
750 NEXT
760 PRINT "VERSION=$";V$
770 PRINT
780 :
800 I=40864: REM $9FA0
810 X=PEEK(I)
820 IF X=0 THEN PRINT: END
830 PRINT CHR$(X);
840 I=I+1
850 GOTO 810
860 :
1000 PRINT "THIS IS AN ORIGINAL VIC-20"
Home First Prev Contents Next Last Top of Page

Source: http://www.infinite-loop.at/Power20/Documentation/Power20-ReadMe/AF-Emulator_Detection.html
Power20 Homepage: http://www.infinite-loop.at and http://www.salto.at - EMail:
© Roland Lieger, Goethegasse 39, A-2340 Mödling, Austria - Europe
Last Changed: Feb. 29, 2008
Valid HTML 4.01!