Compucolor.org – Virtual Media

Listing of file='PATCH.MAC;08' on disk='vmedia/asm_utility_routines-sideB-sector.ccvf'

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;	SOUNDWARE/SCROLL/NO-ECHO/CLOCK PATCH
;
;	SOUND ROUTINE IS A LA CAP ELECTRONICS
;
	TITLE	PATCH
;
;	TO USE THE PATCH, RUN IT FROM FCS. THIS TURNS THE
;	CLOCK DISPLAY ON, AND SETS UP THE BASIC CALL VECTOR.
;
;	NOTE: THE END OF BASIC MUST BE MOVED BACK BY 512
;	      (200H) BYTES FIRST.
;
;	FROM BASIC, CALL VALUES ARE:
;	   0 = SOUNDWARE
;	   1 = SCROLL
;	   2 = NOECHO
;	 100 = GET ADDRESS FOR SOUNDWARE DATA
;	 101 = GET ADDRESS FOR SCROLL DATA
;	 200 = TURN CLOCK DISPLAY ON
;	 201 = TURN CLOCK DISPLAY OFF
;
;	ALL OTHER VALUES ARE IGNORED.
;
;	ASSEMBLY LANGUAGE ROUTINES MAY CALL DIRECTLY:
;	   SOUND, SCROLL, NOECHO AND CLOCK
;
	ENTRY	PATCH

CALVEC	EQU	8202H		;BASIC CALL(X) VECTOR

PATCH:	LXI	H,SWARE		;SET UP JUMP FOR BASIC CALL(X)
	SHLD	CALVEC+1
	MVI	A,0C3H
	STA	CALVEC
	JMP	CLOCK		;EXIT VIA CLOCK ROUTINE TO
				;   START CLOCK DISPLAY

;
;	SOUNDWARE ROUTINE - SEE CAP ELECTRONICS DOCUMENTATION
;
;	OTHER (BETTER) ROUTINES EXIST, BUT THIS IS PROVIDED
;	FOR COMPATIBILITY
;
	ENTRY	SWARE
	ENTRY	SOUND

	PUBLIC	PITCH,DURN,NSTEPS,STEP1,STEP2

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

SWARE:	MOV	A,E
	ORA	A
	JNZ	SCRL
SOUND:	MVI	E,8
	DI
	LDA	STEP1
	MOV	D,A
	LDA	STEP2
	ORA	A
	JNZ	SW10
	MOV	A,D
	STA	STEP2
SW10:	LHLD	PITCH
	SHLD	SW30+1
	LHLD	DURN
	SHLD	SW20+1
SW20:	LXI	H,DURN
SW30:	LXI	B,PITCH
SW40:	DCX	B
	MOV	A,B
	ORA	C
	JNZ	SW40
	MOV	A,E
	XRI	02
	OUT	04
	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:	STA	STEP2
	STA	DURN+1
	STA	PITCH+1
	MVI	A,15
	STA	DURN
	MVI	A,50
	STA	PITCH
	EI
	RET

;
;	SCROLL PATCH - SEE COLORCUE VOL I.1 PAGES 2-3
;
;	VALUES ARE:
;	   STADR  = 28672 + 2*X + 128*Y
;	   NOLINS = H (>1)
;	   WIDTH  = W (1-64)
;	   DOUBLE = C (0 OR 1)
;
;	THE FOLLOWING ARE AS PER COLORCUE:
;	X,Y = COORDS OF TOP LEFT CORNER OF SCROLL AREA
;	H   = NUMBER OF LINES
;	W   = WIDTH IN CHARACTERS
;	C   = COLOR FLAG (1=SCROLL COLOR, 0=DO NOT)
;
	ENTRY	SCRL
	ENTRY	SCROLL

	PUBLIC	STADR,NOLINS,WIDTH,DOUBLE

STADR:	DW	7000H	;TOP OF SCREEN
NOLINS:	DB	4	;4 LINES
WIDTH:	DB	64	;64 CHRS  - WHOLE LINE
DOUBLE:	DB	1	;CCI FLAG - SCROLL COLOR TOO

SCRL:	CPI	1
	JNZ	NOEC
SCROLL:	LHLD	STADR
	LDA	NOLINS
	MOV	B,A
	DCR	B
SC10:	LDA	WIDTH
	MOV	C,A
	PUSH	H
	PUSH	H
	LXI	D,128
	DAD	D
SC20:	MOV	A,M
	INX	H
	XTHL
	MOV	M,A
	INX	H
	XTHL
	LDA	DOUBLE
	ORA	A
	JZ	SC30
	INX	H
	XTHL
	JMP	SC40
SC30:	MOV	A,M
	INX	H
	XTHL
	MOV	M,A
SC40:	INX	H
	XTHL
	DCR	C
	JNZ	SC20
	POP	H
	POP	H
	LXI	D,128
	DAD	D
	DCR	B
	JNZ	SC10
	POP	H
	RET

;
;	NOECHO PATCH - SEE COLORCUE VOL I.2 PAGES 7-8
;
;	MODIFIED VERSION - TIME DELAY (SECONDS) IN D REG.
;	I.E. IN BASIC USE: CALL(256*DELAY + 2)
;	IF DELAY IS ZERO, ROUTINE WAITS INDEFINITELY FOR
;	A CHARACTER.
;	RETURNS -1 (DE = FFFFH) IF TIME-OUT OCCURS.
;
	ENTRY	NOEC
	ENTRY	NOECHO

KEYTST	EQU	0024H
READY	EQU	81FFH

NOEC:	CPI	02
	JNZ	ADDR
NOECHO:	MOV	H,D
NOEC10:	LXI	B,2300H
NOEC20:	CALL	KEYTST
	JZ	NOEC30
	MOV	A,H
	ORA	A
	JZ	NOEC20
	DCX	B
	MOV	A,C
	ORA	B
	JNZ	NOEC20
	DCR	D
	JNZ	NOEC10
	LXI	D,0FFFFH
	JMP	NOEC40
NOEC30:	MOV	E,A
	XRA	A
	MOV	D,A
NOEC40:	XRA	A
	STA	READY
	RET

;
;	RETURN THE ADDRESSES OF DATA AREAS FOR ROUTINES
;

ADDR:	CPI	100	;SOUNDWARE DATA
	JNZ	ADDR10
	LXI	D,PITCH
	RET
ADDR10:	CPI	101	;SCROLL DATA
	JNZ	CLK
	LXI	D,STADR
	RET

;
;	TURN CLOCK DISPLAY ON OR OFF AS REQD
;
	EXTRN	CLOCK,CLKOFF
;
;	NOTE: CLOCK REQUIRES ROUTINE DECOUT
;

CLK:	CPI	200	;TURN ON
	JZ	CLOCK
	CPI	201	;TURN OFF
	RNZ
	MVI	A,0FFH
	STA	CLKOFF
	RET

	END	PATCH