UHR_MOD ASM;---------------------------------------
;    QUELLTEXT "Uhr mit M001/M003"
;
;	(EDAS 1.5/1.6)
;
;UHR.ASM	` ML-Soft 17/11/93
;---------------------------------------
;Hinweis: Bei Verwendung eines M003 mu~
;die Verbindung ZC/TO2-CLK/TRG3 am CTC
;(Pin 9 und 20) erst hergestellt wer-
;den!
;---------------------------------------
;Berechnung der Taktzeit f}r Sekunden-
;takt von CTC3:
;
;Systemtaktfrequenz f=1,751938 MHz
;
;		   f
;	T = ---------------
;	    VT2 * ZK2 * ZK3
;
;	     1.751938 MHz
;	T = --------------
;	    256 * 29 * 236
;
;	T = 0.999928
;
;-> Uhr geht am Tag ca. 6 Sekunden vor.
;---------------------------------------
MODUL	EQU	001	;001=M001
			;003=M003
	ORG	200H
SEK	EQU	100H 	;Sekundenz{hler
MIN	EQU	SEK+1	;Minutenz{hler
STD  	EQU	MIN+1 	;Stundenz{hler
WINON	EQU	0B79CH
WINLG	EQU	0B79EH
CURSO	EQU	0B7A0H
STBT	EQU	0B7A2H
COLOR	EQU	0B7A3H
PV1	EQU	0F003H
CRT	EQU	00H
LF	EQU 0AH
CR	EQU 0DH
LARG	EQU	15H
AHEX	EQU	1CH
OSTR	EQU	23H
MODU	EQU	26H
CTC0	EQU	MODUL-1*6
CTC2	EQU	CTC0+2
CTC3	EQU	CTC0+3
MOD	EQU	3-MODUL/2
STB	EQU	0EEH+MOD
;-------
;ISR des CTC-Kanal 3 im Minutentakt
;-rettet WINON, WINLG, CURSO, STBT
;-IRM-Schaltzustand
;
ISRC2:	EI
	PUSH	HL
	PUSH	AF
	LD	HL,SEK
	LD	A,M
	ADD	1	;sek+1
	DAA
	LD	M,A
	CP	60H
	JR	NZ,TIME
	LD	M,0
	INC	HL
	LD	A,M
	ADD	1	;min+1
	DAA
	LD	M,A
	CP	60H
	JR	NZ,TIME
	LD	M,0
	INC	HL
	LD	A,M
	ADD	1	;std+1
	DAA
	LD	M,A
	CP 	24H
	JR	NZ,TIME
	LD	M,0
TIME:	LD	A,(IX+4)
	PUSH	AF
	IN	A,(88H)
	LD	H,A
	SET	2,A	;IRM on
	OUT	(88H),A
	LD	A,(IX+1)
	LD	L,A
	PUSH	HL
	AND	0F9H
	BIT	0,L
	JR	Z,TIM2
	SET	2,A	;angezeigtes
TIM2:	LD	(IX+1),A;Bild
	OUT	(84H),A
	LD	A,L
	LD	HL,(WINON)
	PUSH	HL
	LD	HL,(WINLG)
	PUSH	HL
	LD	HL,(CURSO)
	PUSH	HL
	LD	HL,(STBT);+COLOR
	PUSH	HL
	LD	L,A
	LD	A,10H	;rot/schwarz
	BIT	3,L	;im HIRES-
	JR	NZ,TIM3	;und Normal-
	XOR	A	;Modus!
TIM3:	LD	(COLOR),A
	XOR	A
	LD	(STBT),A;Pixel & Farbe
	LD	HL,0
	LD	(WINON),HL
	LD	HL,2028H
	LD	(WINLG),HL
	LD	HL,20H
	LD	(CURSO),HL
	LD	A,(STD)
	CALL	PV1
	DB	AHEX
	LD	A,(SEK)
	BIT	0,A
	LD	L,':'
	JR	Z,TIM1
	LD	L,' '
TIM1:	LD	A,L
	CALL	PV1
	DB	CRT
	LD	A,(MIN)
	CALL	PV1
	DB	AHEX
	LD	A,L
	CALL	PV1
	DB	CRT
	LD	A,(SEK)
	CALL	PV1
	DB	AHEX
	POP	HL
	LD	(STBT),HL
	POP	HL
	LD	(CURSO),HL
	POP	HL
	LD	(WINLG),HL
	POP	HL
	LD	(WINON),HL
	POP	HL
	LD	A,L
	LD	(IX+1),A
	OUT	(84H),A
	LD	A,H
	OUT	(88H),A
	POP	AF
	LD	(IX+4),A
	OUT	(86H),A
	POP	AF
	POP	HL
	RETI
;-------
AADR:	DW	7F7FH
	DB	'UHR',1
	LD	BC,0780H
MSU:	IN	A,(C)
	CP	STB	;M001?
	JR	Z,SWI
	INC	B
	JR	NZ,MSU
	CALL	PV1
	DB	OSTR
	DB	'Kein M00'
	DEFB	'0'+MODUL
	DB	' gefungen!'
	DB	CR,LF,7,0
	RET
SWI:	LD	A,2
	LD	L,B	;Steckplatz
	LD	D,1
	CALL	PV1
	DB	MODU	;einschalten
	CALL	PV1
	DB	LARG
	AND	A
	JR	Z,NOSET	;keine Arg's
	CP	3
	JR	NZ,OFF	;stoppen
	LD	A,L
	LD	HL,STD
	LD	M,A	;Stunden
	DEC	HL
	LD	M,E	;Minuten
	DEC	HL
	LD	M,C	;Sekunden
NOSET:	DI
	LD	A,0
	OUT	(CTC0),A  ;IVEK
	LD	HL,ISRC2
	LD	(106H),HL ;ITAB
	LD	A,37H
	OUT	(CTC2),A  ;DI, ZG, VT256
	LD	A,29
	OUT	(CTC2),A  ;ZK
	LD	A,0C7H
	OUT	(CTC3),A  ;EI, Z{hler
	LD	A,236
	OUT	(CTC3),A  ;ZK
	EI
	RET
OFF:	LD	A,3		;DI
	OUT	(CTC2),A
	OUT	(CTC3),A
	RET
А@Аt(Аp6АnTop of Text: End of Text: Start of MC: ASM-Offset : хЫ€ц$У€сЙхЫ€жЫ,3		;DI
	OUT	(CTC2),A
	OUT	(CTC3),A
	RET
А@Аt(Аp6АnTop of Text: End of Text: Start of MC: ASM-Offset : хЫ€ц$У€сЙхЫ€жЫ