Compucolor.org – Virtual Media

Listing of file='TIM2VC.MAC;02' on disk='vmedia/taylor_8-sector.ccvf'

;********************************************************
;*							*
;*	TIMER2 ROUTINE					*
;*							*
;*	LINKED TO WHEN THE TIMER 2 GOES OFF, THIS	*
;*	ROUTINE MAINTAINS THE MASTER COUNTER (0-255)	*
;*	AND CALLS THE VOICE ROUTINE, WHICH MANIPULATES	*
;*	THE AY-3-8910 CHIP REGISTERS ACCORDING TO THE	*
;*	CALLER'S PARAMETERS IN THE "VOICE" TABLES.	*
;*							*
;********************************************************
;
	ENTRY	TIM2RTN
	EXTRN	VOICE1,VOICE2,VOICE3
	EXTRN	COUNTER,TIMEVALUE
	EXTRN	MIXERVALUE
TIM2RTN: PUSH	PSW
	PUSH	B
	PUSH	D
	PUSH	H
	LDA	TIMEVALUE	;GET TIME DELAY VAL
	OUT	10		;AND HIT TIMER
	LDA	COUNTER
	INR	1		;INCREMENT MAIN COUNTER
	STA	COUNTER
	JZ	EXIT		;256 TIMES ONLY
	LXI	H,VOICE1
	CALL	SOUNDER		;DO IT FOR FIRST VOICE
	LXI	H,VOICE2
	CALL	SOUNDER		;2ND
	LXI	H,VOICE3
	CALL	SOUNDER		;3RD
EXIT:	POP	H
	POP	D
	POP	B
	POP	PSW
	RET
	PAGE
;********************************************************
;*							*
;*	VOICE ROUTINE					*
;*							*
;*	THIS ROUTINE TURNS THE VOICE TABLE INTO		*
;*	SOUND IF THE MAIN COUNTER IS WITHIN LIMITS.	*
;*							*
;********************************************************
;
SOUNDER:
	PUSH	PSW
	INX	H
	INX	H		;STEP OVER INITIAL VALUES
	CMP	M		;COMPARE COUNTER TO START VAL
	JC	ELSE		;COUNTER LESS
	INX	H		;COMPARE TO STOP VALUE
	CMP	M
	JNC	ELSE		;COUNTER >=
	INX	H
	MOV	E,M
	INX	H
	MOV	D,M		;INCREMENT IN D,E
 	INX	H
	MOV	C,M
	INX	H
	MOV	B,M		;COARSE, FINE VALS IN B,C
	INX	H
	MOV	A,M		;FINE TONE REG
	OUT	48
	MOV	A,C		;FINE TONE
	OUT	49		;AND OUT
	MOV	A,M
	INR	A		;COARSE TONE REG
	OUT	48
	MOV	A,B		;COARSE TONE
	OUT	49		;AND OUT
	XCHG
	DAD	B		;H,L NOW = CRS/FINE + INCR
	XCHG			;D,E NOW
	DCX	H
	DCX	H
	MOV	M,E
	INX	H
	MOV	M,D		;RESTORE ADJUSTED TONE VALUES
	INX	H		;FOR NEXT TIME
	INX	H
	MOV	A,M		;NOISE VALUE TO A
	CPI	0
	JZ	NONOISE
	MOV	B,A
	MVI	A,6		;NOISE REG IS 6
	OUT	48
	MOV	A,B
	OUT	49		;OUTPUT NOISE VALUE
NONOISE:  INX	H
	MOV	B,M		;VOLUME VALUE
	INX	H
	MOV	A,M		;VOLUME REGISTER
	OUT	48
	MOV	A,B
	OUT	49		;OUTPUT VOLUME VALUE
	INX	H
	MOV	B,M		;MIXER VALUE MASK
	LDA	MIXERVALUE
	ANA	B		;AND OUR VALUE INTO MASK
	STA	MIXERVALUE	;AND STORE IT
	MOV	B,A
	MVI	A,7
	OUT	48		;PREPARE TO OUTPUT MIXER VALU
	MOV	A,B
	OUT	49
;SOUND NOW ALL DONE. THIS VOICE'S REGS ARE ALL SET. TABLES ARE
;READY FOR NEXT TIME.
ELSE:
	POP	PSW		;RESTORE MAIN COUNTER
	RET

	END