;
;THIS IS A VERY SHORT PROGRAM THAT WILL ALTER THE
;CURSOR ON A '-84'-BOARDED KAYPRO.
;
;CAN BE ASSEMBLED AND LOADED WITH ASM.COM AND
;LOAD.COM, RESPECTIVELY.
;
; by J. A. Sinning  --  6 March 1985
;
;===============================================
;USAGE:
;	CURSOR		;Set cursor to non-blink
;			;block
;	CURSOR M	;Select Cursor from Menu
; (Actually ANY argument will get the Menu)
;
; Patch the BYTE as 0103H for the default value
; of cursor if other than 00H
; The following are possible:
;
;	VALUE	RESULTING CURSOR
;	 00H	BLOCK - NO Blink
;	 60H	BLOCK - Normal Blink
;	 4DH	UNDERLINE - Fast Blink
;	 6DH	UNDERLINE - Slow Blink
;
;===============================================
;		EQUATES
;
CRTSTAT	EQU	1CH	;CRT Status/Control Port
CRTDAT	EQU	1DH	;CRT Data Port
CURSREG	EQU	10	;CRT Cursor Control Register
;
BDOS	EQU	0005H	;BDOS Jump Location
FCB	EQU	005CH	;CP/M Default FCB
CONIN	EQU	01H	;BDOS Console Input
CONOUT	EQU	02H	;BDOS Console Char Out
;
CR	EQU	0DH	;ASCII Carriage Return
LF	EQU	0AH	;ASCII Line Feed
BELL	EQU	07H	;ASCII Bell
;
;==================================================
;
	XREF	;For LASM of Mar-84 - Comment out
		;for use with ASM.COM
;
;--------------------------------------------------
;		PROGRAM STARTS HERE
;
	ORG 0100H
;
START:
	JMP BEGIN	;Jump Over Default Byte
;
CURSOR:
	DB 00H		;Default to BLOCK - No Blink
;
BEGIN
	LDA FCB+1	;No argument specified?
	CPI ' '		;CP/M fills with spaces if
			;no argument.
	LDA CURSOR	;Assume yes, get default
	JZ SETCURS
; If not ' ', then fall thru to menu
;
MENU:
	CALL ILP	;Print the Prompt
;
	DB CR,LF,'Select Desired Cursor:'
	DB CR,LF,'  1) BLOCK - NO Blink'
	DB CR,LF,'  2) BLOCK - Blinking'
	DB CR,LF,'  3) UNDERLINE - Fast Blink'
	DB CR,LF,'  4) UNDERLINE - Slow Blink'
	DB CR,LF,LF,'==>> WHICH ONE ?? ',0
;
	MVI C,CONIN	;Now Get The Answer
	CALL BDOS
	SUI '0'		;Make binary
	JZ BADINP	;Must be > 0
	CPI 5		;Must be < 5
	JNC BADINP
	MOV C,A
	CPI 1		;Is it 1 ?
	MVI A,00H	;Assume yes
	JZ SETCURS
	MOV A,C
	CPI 2		;Is it 2 then ?
	MVI A,60H	;Assume yes
	JZ SETCURS
	MOV A,C
	CPI 3		;Is it 3 then ?
	MVI A,4DH	;Assume yes
	JZ SETCURS
	MVI A,6DH	;If not 1-3, then assume 4
;
SETCURS:
	MOV C,A		;Save the setting byte
	MVI A,CURSREG	;Select the Cursor Control
			;Register
	OUT CRTSTAT	;Send it to Controller
	MOV A,C		;Get the setting byte back
	OUT CRTDAT	;Send it
	RET		;RETURN to CP/M
;
;------------------------------------
;BADINP - Tell user he screwed up and
; start over
;
BADINP:
	CALL ILP
	DB CR,LF,LF,BELL,'==>> ONLY 1-4 YOU @#$%^&*'
	DB ' DUMMY <<==',CR,LF,0
	JMP MENU
;
;------------------------------------
;ILP - In-Line-Print Subroutine
;
ILP:
	XTHL		;Get Address of string
			;from stack
ILP1:
	MOV A,M		;Get a byte
	INX H		;Point next byte
	ORA A		;Done if 0
	JZ ILP2
	CALL OUTCHAR	;Not done, print byte
	JMP ILP1	;Loop
ILP2:
	XTHL		;Put return address on stack
	RET
;
;------------------------------------
;OUTCHAR - Send char to CRT via BDOS
;
OUTCHAR:
	PUSH H		;Here we only need save HL
	MOV E,A		;Char in E for BDOS
	MVI C,2		;Select CONOUT
	CALL BDOS
	POP H
	RET
;
;------------------------------------
	END START
;
