Compucolor.org – Virtual Media

Listing of file='SPIN.SRC;01' on disk='vmedia/chip_129-sector.ccvf'


			;20 MARCH 1981

			;SPIN

			;ADD CLEAR SCREEN AND ACCURACY
			LO    EQU 17C8H
			VTP   EQU 1E94H
			POUND EQU 1EB1H
			STEPS EQU 1EC0H
			WATL  EQU 185FH
			TDRV  EQU 80E6H
			DFUN  EQU 80F2H
			ORG 0A000H

START:	MVI	A,06H
	CALL	LO
	MVI	A,02H
	CALL	LO
	MVI	A,0FH
	CALL	LO
	MVI	A,0CH
	CALL	LO

	DI

	LDA	DFUN	;GET DEFAULT
	ANI	0FH
	STA	TDRV
	INR	A
	RLC
	RLC
	RLC
	RLC
	MOV	D,A	;STORE DEV MASK

	CALL	POUND
	CALL	VTP
	MVI	A,28H
	CALL	STEPS
	MVI	A,30H
	CALL	WATL
			;
			;
			;NOW MARK THE DISC

	DI
	MVI	A,10H	;SET X8 BAUD AND XMIT=0
	OUT	04H
	MVI	A,0C0H	;SET 9K6 BAUD WITH 1 STOP
	OUT	05H	;SERIAL NOW=76K8 BAUD

	MOV	A,E	;WHERE IS STEPPER MOTOR?
	ORA	D	;DEV
	ORI	08H	;WRITE

	OUT	07H	;TURN ON AND WRITE
	MVI	A,1FH
	CALL	WATL	;WRITE A '0' FOR 3 REVS
	MVI	A,12H
	OUT	04H	;WRITE A 15 U.SEC '1'
	MOV	A,E	;REMEMBER STEPPER
	ANI	07H
	ORA	D	;DEV
	OUT	07H	;NOW JUST READ FOREVER

			;CLEAR SERIAL
	MVI	A,11H
	OUT	04H
			;
			;
			;CALCULATE AND DISPLAY REVOLUTION TIME

	LXI	H,7000H	;SET UP SCREEN
	XRA	A
	MOV	C,A	;CLEAR REGISTERS
	MOV	D,A
	MOV	E,A
	MVI	B,0BH
	PUSH	B	;SAVE ELEVEN COUNT
	PUSH	H	;POSITION SCREEN

			;C=FLAG
			;DE=BINARY COUNT

TIME:	IN	03H	;LOOK FOR MARKER
	ANI	80H
	CPI	80H	;GOT IT?
	JZ	YES
	JMP	NO
YES:	INR	C	;SET FLAG=1
	MVI	A,11H
	OUT	04H	;RESET SERIAL
NO:	LXI	H,SCRAP	;CLUMSY MOVE SO PROCESSOR INDEPT.
	MOV	M,C
	MOV	A,M	;THIS MEANS EXACTLY 100 CYCLE TIMING
	CPI	01H	;IF FLAG =1 THEN CONTINUE
	JNZ	NTIM
	INX	D	;TIMER COUNT (50 U.SEC PER LOOP)
	JMP	TIME	;GO AND LOOK FOR NEXT MARKER

NTIM:	MOV	A,C
	CPI	0H	;GOT IT
	JZ	TIME	;IS IT THE FIRST?
			;NO! GO AND DISPLAY COUNT

			;COMPENSATE DELAY
	MVI	A,01
ADJ:	DCR	A
	JNZ	ADJ

			;DIVIDE BY 2 FOR 100 U.SEC/COUNT
			;AND ROUND UP LSB BEFORE-HAND
	XRA	A
	MOV	A,E
	RAR		;DOES IT NEED ROUNDING?
	JNC	SMALL
	RAL		;YES. RESTORE VALUE
	ADI	01H	;ROUNDUP
	MOV	E,A
	MVI	A,0	;ADD CARRY (IF ANY) TO MSN
	ADC	D
	MOV	D,A	;END ROUNDUP

SMALL:	XRA	A
	MOV	A,D	;PUT IN MSBYTE
	RAR		;NOTE CARRY SET
	MOV	D,A
	MOV	A,E	;PUT IN LSBYTE
	RAR
	MOV	E,A	;END

			;COUNT ROUTINE CHECK     GJC
			;FEB 1981

			;16 BIT COUNT IN HL
			;PARTIAL SUMS IN DE
			;DECIMAL VALUE IN BC

	XCHG		;PUT COUNT IN HL
	LXI	B,00	;CLEAR DECIMAL NIBBLES

	LXI	D,0FC18H
	XRA	A

MINUS1:	DAD	D	;1ST PARTIAL SUM (SUBTRACT 1000)
	JNC	NEG1	;SUBTRACTED TOO MANY IF NO CARRY
	INR	B
	JMP	MINUS1
NEG1:	MOV	A,B
	RLC
	RLC
	RLC
	RLC
	MOV	B,A	;THIS SETS UP MSB NIBBLE

	LXI	D,3E8H	;FINALLY ADD 1000
	DAD	D
	CMC		;CARRY WILL HAVE BEEN SET HERE

	LXI	D,0FF9CH
MINUS2:	DAD	D
	JNC	NEG2	;SUBTRACT 100'S
	INR	B
	JMP	MINUS2

NEG2:	NOP
	LXI	D,64H	;ADD 100
	DAD	D
	CMC
			;NO FURTHER NEED FOR 16 BIT CALC
	MOV	A,L

MINUS3:	SUI	0AH	;SUBTRACT 10'S
	JC	NEG3
	INR	C
	JMP	MINUS3

NEG3:	ADI	0AH	;YES, TOO MANY 10'S
	CMC
	PUSH	PSW
	MOV	A,C
	RLC
	RLC
	RLC
	RLC
	MOV	C,A
	POP	PSW
	ORA	C	;PUT IT INTO UNITS
	MOV	C,A

	POP	H	;WHERE IS THE SCREEN?
	POP	D	;PUT B REG LINE COUNT IN D

	MOV	A,B
	RRC
	RRC
	RRC
	RRC
	CALL	DISP	;MSB TO SCREEN
	MOV	A,B
	CALL	DISP
	MOV	A,C
	RRC
	RRC
	RRC
	RRC
	CALL	DISP
	MOV	A,C
	CALL	DISP	;LSB TO SCREEN

	INX	H
	INX	H
	INX	H
	INX	H

	MOV	A,D
	ANA	A
	DCR	A	;11 PER LINE
	MOV	D,A
	JNZ	LINE
	DCX	H
	DCX	H
	DCX	H
	DCX	H
	MVI	D,0BH	;RESET 11

LINE:	PUSH	D
	PUSH	H

	XRA	A
	MOV	C,A
	MOV	D,A
	MOV	E,A

	JMP	TIME


DISP:	ANI	0FH	;DISPLAY ROUTINE
	ADI	30H
	MOV	M,A
	INX	H
	INX	H
	MOV	A,H
	RAL
	RNC		;PLENTY SCREEN
	LXI	H,7000H
	RET

		SCRAP:  DS 2



	END	START