I want a test ;)
ZXNet echo conference «code.zx»
From Oleg Grigoriev → To Eugene Palenock 15 November 2000
Let your enemies, Eugene, die without sons!
15 November 2000 at 03:30, Eugene Palenock => All:
EP> Give me some test
go to the pharmacy. :)
EP> which the emulator can distinguish from the real thing.
EP> Or have emulators finally won? ;)
probably. here is my creation - written quite a long time ago, though... in real life
should blink blue. compile in a storm.
== { Begin } ======================================================== { emultest.C } ==
;emulator test
;
DRIVE EQU #5CF6
IM2TB EQU #BE00
ORG #6000:DI
; LD SP,#6000
; LD HL,#0000:PUSH HL
; LD HL,#3D2F:PUSH HL
LD HL,IM2TB,A,H,I,A
LD (HL),H:INC (HL),L:JR NZ,$-#03
INC H:LD (HL),H,L,H
LD (HL),#C9
IM 2
LD A,(DRIVE):OR #3C:CALL TOPRFF
LD A,#08:CALL TOPR1F,INTRQ
LD B,#0A
EI:HALT
DJNZ$-#02
LOOP XOR A:LD (ENEMY+#01),A
CALL TEST1
CALL TEST2
CALL TEST3
LD A,#20:CALL TOPR1F,INTRQ
ENEMY LD A,#00
OR A:LD A,#01:JR Z,$+#03:INC A
CALL FILL
XOR A:CALL FILL
LD B,#0A
WAIT EI:HALT
XOR A:IN (#FE):CPL:AND #1F
RET NZ
DJNZ WAIT
JR LOOP
;************************************************
TEST1 LD D,#00,A,#C3,HL,TEST1R
LD (#5CC2),A,(#5CC3),HL LD (TEST1R+#01),SP
LD HL,#2740:PUSH HL
LD HL,#2A53:PUSH HL
LD A,#08,C,#1F
JP #3D2F
TEST1R LD SP,#0000
CALL INTRQ
LD A,(#5CCD):AND #01
LD B,A
LD A,(ENEMY+#01):OR B
LD (ENEMY+#01),A
RET
;***************************************
TEST2 LD D,#00,A,#C3,HL,TEST2R
LD (#5CC2),A,(#5CC3),HL
LD (TEST2R+#01),SP
LD HL,#2740:PUSH HL
LD B,#08,HL,#2A55
PUSH HL:DJNZ $-#01
LD HL,#2A53:PUSH HL
LD A,#08,C,#1F
JP #3D2F
TEST2R LD SP,#0000
CALL INTRQ
LD A,(#5CCD):AND #01:XOR #01
LD B,A
LD A,(ENEMY+#01):OR B
LD (ENEMY+#01),A
RET
;***************************************
TEST3 LD D,#00,A,#C3,HL,TEST3R
LD (#5CC2),A,(#5CC3),HL
LD (TEST3R+#01),SP
LD HL,#2740:PUSH HL
LD B,#00,HL,#2A55
PUSH HL:DJNZ $-#01
LD HL,#2A53:PUSH HL
LD A,#08,C,#1F
JP #3D2F
TEST3R LD SP,#0000
CALL INTRQ
LD A,(#5CCD):AND #01
LD B,A
LD A,(ENEMY+#01):OR B
LD (ENEMY+#01),A
RET
;***************************************
;
FILL PUSH AF,BC
EI:HALT
OUT (#FE)
ADD A,A,A,A,A,A
LD (FILL1+#01),SP
LD B,#30,D,A,E,A,SP,#5B00
.8 PUSH DE
DJNZ $-#08
FILL1 LD SP,#0000
POP BC,AF
RET
;***************************************
;
INTRQ LD IX,#3EF5:CALL DOS:DI:RET
TOPR1F LD C,#1F:JR TOPR
TOPRFF LD C,#FF
TOPR LD IX,#2A53
DOS PUSH IX:JP #3D2F
== { End } =========================================== { emultest.C } ==
[ WBR, Oleg. ]
[ 13:49 15 November XXXV A.S. ]
From Aleksey Malov → To Eugene Palenock 15 November 2000
Greetings, Eugene!
Wed 15 Nov 2000 at 03:30:13 Eugene Palenock and All were talking
I want a test on the topic ;).
EP> Give me some test that can distinguish the emulator from the real thing.
EP> Or have emulators finally won? ;)
I’m throwing, for the umpteenth time, a test that can distinguish the emulator from the real thing.
Here's the source:
═══════════════════ FUCKEMUL.a ══════════════════
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'a
ld 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 halt
;and here is the third test
;On a real Z80 the EI command disables
;interrupts for the duration of the next command,
;however, if the next command
;is the command LD A,I, then the flag
;parity/overflow will show that
;interrupts enabled
;It’s possible that even the R80 won’t be able to
;take this test
ei
ld a,i
jppe,real2
inc e
real2 push de
;we're swearing again
ld e,#40
ld hl,report
call prn
ld b,40
call pause
pop de
pop af
rl exor 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 a
ret 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
;messagessysmes db " 2000 Brainwave of X-Project. "
db "System checking! Please wait... ",0
report db "System checking report:",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
════════════════════════════════════════════════
Счастливо, Eugene! С вами был Vivid/Brainwave^X-Project.
[ZX] [Sailor Moon]