Compucolor.org – Virtual Media

Listing of file='SWARE2.MAC;01' on disk='vmedia/joystick_sound-sector.ccvf'

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;	SOUNDWARE/SCROLL/NO-ECHO PATCH A LA CAP ELECTRONICS
;
	TITLE	SWARE
;
	ENTRY	SWARE
	ENTRY	SOUND

	PUBLIC	PITCH,DURN,NSTEPS,STEP1,STEP2

SNDADR	EQU	176
SNDDAT	EQU	177

PITCH:	DB	50,0
DURN:	DB	15,0
NSTEPS:	DB	0
STEP1:	DB	0
STEP2:	DB	0

SWARE:	MOV	A,E
	CPI	0
	JNZ	SCRL
SOUND:			;SAVE 2 BYTES HERE
	CALL	STOP	;ADD 3 BYTES
	LDA	STEP1
	MOV	D,A
	LDA	STEP2
	CPI	0
	JNZ	SW10
	MOV	A,D
	STA	STEP2
SW10:	LHLD	PITCH
	SHLD	SW30+1
	LHLD	DURN
	SHLD	SW25+1
	DI		;MOVED TO HERE
SW20:	CALL	SND	;INSERT CALL TO MAKE SOUND
SW25:	LXI	H,DURN
SW30:	LXI	B,PITCH
SW40:	DCX	B
	MOV	A,B
	ORA	C
	JNZ	SW40
	MOV	A,E

	MOV	E,A	;CHANGE XRI AND OUT TO
	MOV	A,E	;   MOV'S TO EVEN UP
	MOV	E,A	;   THE TIMING
	MOV	A,E	;(BYTE FOR BYTE CHANGE)

	MOV	E,A
	DCX	H
	MOV	A,H
	ORA	L
	JNZ	SW30
	LDA	NSTEPS
	CPI	0
	JZ	SW50
	DCR	A
	STA	NSTEPS
	LDA	SW30+1
	ADD	D
	STA	SW30+1
	LDA	STEP2
	MOV	H,A
	MOV	A,D
	STA	STEP2
	MOV	D,H
	JMP	SW20
SW50:	CALL	STOP
	CALL	RSTSND
	EI
	RET

	DS	9	;NEEDED TO FIX ADDRESSES

	ENTRY	SCRL
	ENTRY	SCROLL

	PUBLIC	STADR,NOLINS,WIDTH,DOUBLE,ENDADR

SCRL:	CPI	1
	JNZ	NOEC
SCROLL:	DB	21H	;LXI	H,STADR
STADR:	DW	7000H
	DB	06H	;MVI	B,NOLINS
NOLINS:	DB	4
SC10:	DB	0EH	;MVI	C,WIDTH
WIDTH:	DB	128
SC20:	LXI	D,128
	DAD	D
	MOV	A,M
	LXI	D,-128
	DAD	D
	MOV	M,A
	INX	H
DOUBLE:	NOP		;POKE AN 'INX H' IN HERE
	DCR	C
	JNZ	SC20
	DB	11H	;LXI	D,ENDADR
ENDADR:	DW	08H
	DAD	D
	DCR	B
	JNZ	SC10
	RET

	ENTRY	NOEC
	ENTRY	NOECHO

KEYTST	EQU	0024H
READY	EQU	81FFH

NOEC:	CPI	02
	JNZ	MORE
NOECHO:	PUSH	PSW
	PUSH	H
	PUSH	B
NO10:	CALL	KEYTST
	JNZ	NO10
	MOV	E,A
	XRA	A
	MOV	D,A
	STA	READY
	POP	B
	POP	H
	POP	PSW
	RET

MORE:	RET
;
;	INITIATE A SOUND
;
SND:	PUSH	D
	LHLD	SW30+1	;GET CURRENT PITCH
	MOV	D,H	;COPY TO DE
	MOV	E,L
	DAD	D	;DOUBLE IT
	XRA	A	;CALCULATE HALF OF IT
	MOV	A,D
	RAR
	MOV	D,A
	MOV	A,E
	RAR
	MOV	E,A
	DAD	D	;AND ADD THIS IN TOO
			;   TO GET 2.5 TIMES THE VALUE
	MVI	A,1
	OUT	SNDADR
	MOV	A,H
	OUT	SNDDAT
	XRA	A
	OUT	SNDADR
	MOV	A,L
	OUT	SNDDAT
	MVI	A,8
	OUT	SNDADR
	MVI	A,15
	OUT	SNDDAT
	POP	D
	RET
;
;	STOP THE SOUND
;
STOP:	MVI	A,8	;TURN OFF SOUND
	OUT	SNDADR
	XRA	A
	OUT	SNDDAT
	MVI	A,7	;SET UP FOR CHANNEL 'A' ONLY
	OUT	SNDADR
	MVI	A,62
	OUT	SNDDAT
	RET
;
;	RESET THE SOUND PARAMETERS
;
RSTSND:	XRA	A
	STA	STEP2
	STA	DURN+1
	STA	PITCH+1
	MVI	A,15
	STA	DURN
	MVI	A,50
	STA	PITCH
	RET

	END