Emulator recognition - corrected version.

ZXNet echo conference «code.zx»

From Aleksey Malov To All 1 May 2000

Greetings, All! Corrected version of the emulator recognizer. org #6000 ;clean the screen di ld hl,#5aff ld (hl),#7 dec hl bit 3,h jr nz,$-5 xor a ld(hl),a or(hl) dec hl jr z,$-3 ;install im 2 ld hl,#fd00 ld de,#fd01 ld b,e ld c,l ld (hl),#fe ld a,h ld i,a ldir ld a,#c3 ;jp nn ld (#fefe),a ld hl,imob ld (#feff),hl im 2 ;decommission a bunch of NOPs ld hl,#8000 ld de,#8001 ld bc,#7Bff ld (hl),0 ;nop ldir ld (hl),#c9 ;ret ei ;cursing ld e,0 ld hl, systems call prn ;enter the initial value into the counter ld a,#ff ld(count),a halt ld b,20 ;call a bunch of NOPs 20 times w1 call #8000 djnz w1 di ld a,(count) ;let's deactivate a bunch of EI commands (not to be confused with ;Eternity Industry ;) ) ld hl,#8000 ld de,#8001 ld bc,#7BfE ld (hl),#FD ;EI ldir ldc,a ld a,#ff ld(count),a ei halt ld b,20 ;call a bunch of EI commands 20 times w2 call #8000 djnz w2 di ;compare the number of ints in the first ;and in the second cases with an accuracy of е 1 int'ald a,(count) sub c inc a cp 3 ;if cf=1, then we are under the emulator, because ;z80 does not respond during EI command ;for interruptions => number of ints on real ;spectrum in the first and second measurements ;differs by more than 1 PUSH AF ei ;also if during the arrival of an interrupt ;executed the command ld a,i (ld a,r), ;the processor will consider that interrupts ;prohibited LD E,0 ld bc,0 w3 ld a,i jppo,real1 djnz w3 dec c jr nz,w3 inc e real1 push de ;we're swearing again ld e,#40 ld hl,report call prn ld b,40 call pause pop de pop af rl e xor a or e ;if in the first and second tests ;results correspond to real ;z80, then we print about it ld hl,realmes jr z,real ;otherwise we print that we are being emulated ld hl,emulmes real ld e,#60 call prn ;print press any key ld b,100 call pause ld hl,anykey call prn ;query any key key xor a in a,(#fe) cpl and 31 jr z,key ;we go out to basic or somewhere else di ld a,#3f ld i,a im 1 ei ret ;procedure for printing a string at the top ;one third of the screen by teletype ;hl- asciiz-string ;e-ml. byte prn ld a,(hl):inc hl or aret z push hl ld b,5 add a,a ld l,a cp " "*2 jr z,prn0 ld c,40 xor a beep ld b,c xor #18 out (#fe),a djnz $ dec c jr nz,beep inc b prn0 halt djnz prn0 ld h,0 add hl,hl add hl,hl ld a,h add a,#3c ld h,a ld b,4 ld d,#40 prn1 ld a,(hl) ld (de),a inc l inc d djnz prn1 ld b,4 prn2 ld a,(hl) srl a or (hl) ld (de),a inc l inc d djnz prn2 pop hl inc e jr prn ;мессаги sysmes db " 2000 Brainwave of X-Project. " db "System checking! Please wait... ",0 report db "System checking repot:",0 emulmes db " Warning! General failure: " db "CPU not found! Press F1 for " db "software emulation... ;-) ",0 realmes db "Congratulations!!! Test detected" db "the Real ZX-Spectrum. May be. ;)",0 anykey db "Press any key to exit...",0 pause halt djnz pause ret ;обработчик прерываний imob push af ld a,#3e count equ $-1 inc a ld (count),a pop af ei ret Желаю вам здоровья, счастья и творческих узбеков. Aleksey Malov aka VIVID/Brainwave.