;PROCEDURE WAIT( timer: integer; var ch: char );
;{
;LAST EDITED: 03/03/84 rep
;
;REQUIRES:
;	FUNCTION keyboard();
;}
;label 1;
;const	factor = 2625;{Z80 CPU at 4 mcps}
;var	i,j : integer;
;{$c-,r-,m-,f-}
C	SET	          0
R	SET	          0
M	SET	          0
F	SET	          0

;FUNCTION keyboard( var c:char ):boolean;external;
	EXT	KEYBOARD
	ENTRY	WAIT
WAIT:
	ENTR	D,2,4
;  for j:=1 to timer do begin
	MOV	-2(IX),A
	MVI	-3(IX),1
	PUSH	IX
	POP	H
	DCX	H
	DCX	H
	PUSH	H
	MOV	L,10(IX)
	MOV	H,11(IX)
	XTHL
L181:	MOV	D,M
	DCX	H
	MOV	E,M
	XTHL
	PUSH	H
	GE	D,0
	JNC	L182
;     for i:=1 to factor do begin
	MOV	0(IX),A
	MVI	-1(IX),1
	PUSH	IX
	LXI	H,2625
	XTHL
L199:	MOV	D,M
	DCX	H
	MOV	E,M
	XTHL
	PUSH	H
	GE	D,0
	JrNC	L200
;	if keyboard(ch) then goto 1
	MOV	H,9(IX)
	MOV	L,8(IX)
	PUSH	H
	CALL	KEYBOARD
	JrNC	L210
	JMP	L165
;     end;
L210:	POP	H
	XTHL
	INR	M
	INX	H
	JRNZ	L223
	INR	M
	JV	L224
L223:	JMP	L199
L200:	POP	D
L224:	POP	D
	POP	H
	XTHL
	INR	M
	INX	H
	JRNZ	L227
	INR	M
	JV	L228
L227:	JMP	L181
L182:	POP	D
L228:	POP	D
;1:{}
L165:	EXIT	D,4,4
