;
;
;PROCEDURE ACREMO(HCODE,UCODE,OPCODE,TIME: BYTE);
;
; THIS PROCEDURE WILL OUTPUT TO THE HOUSE CODE (HCODE) AND
; UNIT CODE (UCODE) THE OPERATION DENOTED BY OPCODE.
; THESE CODES ARE RECOGNIZED BY A SCITRONICS BSR INTERFACE
; BOARD AND THE BSR REMOTE COMMAND MODULES. UPON RECEIPT
; OF ONE OF THE CODE TYPES NOTED:
;	ON=		18
;	OFF=		50
;	ALL LIGHTS OFF=	34
;	ALL OFF=	2
;	BRIGHT=		42
;	DIM=		10
;	AND=		26
;	STOP=		0
;
; AN OPERATION WILL BE EXECUTED. WHEN PERFORMING A DIM FUNCTION
; THE TIME VALUE WILL BE USED. IN THIS CASE A TIME VALUE OF 255 MEANS
; THAT THE DIM WILL BE EXECUTED FOR 4 SECS. TIME VALUES ARE
; THEN LINEAR DOWN TO ZERO, WHERE ZERO MEANS NO OUTPUT.
;
;
; CONSTANTS:
SCIADDR	EQU	20H;	SCITRONICS CONTROLLER ADDRESS
DIM	EQU	10;	DIM FUNCTION = 10
BRIGHT	EQU	42;	BRIGHTENING FUNCTION
STOP	EQU	0;	CLEAR FUNCTION
BUSY	EQU	128;	BUSY BIT FOR SCI CONTROLLER
;
; STACK OFFSETS FOR VARIABLE ENTRY
TIME	EQU	8;
OPCODE	EQU	9;
UCODE	EQU	10;
HCODE	EQU	11;
;
; START OF PROCEDURE
;
	NAME	REMOTE
	ENTRY	ACREMO
ACREMO:	ENTR	D,2,0;	MACRO SETUP ROUTINE
	MVI	A,STOP
	OUT	SCIADDR;	CLEAR CONTROLLER
	MOV	A,HCODE(IX);	GET HOUSE CODE
	OUT	SCIADDR
	MOV	A,UCODE(IX);	GET USER CODE
	OUT	SCIADDR
	MOV	A,OPCODE(IX);	OUTPUT OPERATION
	OUT	SCIADDR
	CPI	DIM;	SEE IF IT IS THE DIM FUNCTION
	JZ	DIMCHK
	CPI	BRIGHT;	SEE IF IT IS BRIGHTEN FUNCTION
	JZ	DIMCHK
FIN:	IN	SCIADDR
	ANI	BUSY	;SEE IF CONTROLLER IS FINISHED
	JZ	FIN
	EXIT	D,4;	IF FINISHED DO EXIT MACRO
DIMCHK:	MOV	D,TIME(IX);	STORE TIME VALUE
LP1:	MVI	C,09H;	FIRST LOOP
LP2:	MVI	B,0FFH;	SECOND LOOP
LP3:	DCR	B;	THIRD LOOP
	JNZ	LP3
	DCR	C
	JNZ	LP2
	DCR	D
	JNZ	LP1
	MVI	A,STOP;	TURNING OFF DIM FUNCTION
	OUT	SCIADDR;
	JMP	FIN;	IF FINISHED GO TO FIN ROUTINE
