This is another "delay" using int 15h
with ah=86h
, test it in your game :
;DELAY 500000 (7A120h).
delay proc
mov cx, 7 ;HIGH WORD.
mov dx, 0A120h ;LOW WORD.
mov ah, 86h ;WAIT.
int 15h
ret
delay endp
Another "delay" using system time, it should repeat about 5 times per second :
delay proc
system_time:
;GET SYSTEM TIME.
mov ah, 2ch
int 21h ;RETURN HUNDREDTHS IN DL.
;CHECK IF 20 HUNDREDTHS HAVE PASSED.
xor dh, dh ;MOVE HUNDREDTHS...
mov ax, dx ;...TO AX REGISTER.
mov bl, 20
div bl ;HUNDREDTHS / 20.
cmp ah, 0 ;REMAINDER.
jnz system_time
ret
delay endp
Next is the third delay in seconds, it requires one variable :
seconds db 0 ;?■■ VARIABLE IN DATA SEGMENT.
delay proc
delaying:
;GET SYSTEM TIME.
mov ah, 2ch
int 21h ;?■■ RETURN SECONDS IN DH.
;CHECK IF ONE SECOND HAS PASSED.
cmp dh, seconds ;?■■ IF SECONDS ARE THE SAME...
je delaying ; ...WE ARE STILL IN THE SAME SECONDS.
mov seconds, dh ;?■■ SECONDS CHANGED. PRESERVE NEW SECONDS.
ret
delay endp
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…