
;	***** BOOT *****
;	~~~~~~~~~~~~~~~~

XFDFE:	DI				;zakaz preruseni

	LD	HL,XEA4C		;zmena boot na wboot
	LD	(PEA01),HL

	LD	A,(PEA34)		;0-15 barva tisku na obrazovku
	SET	4,A
	OUT	(0F0H),A

	LD	A,(PEA33)		;0-15 barva pozadi a border
	OUT	(0F0H),A
	LD	BC,6CFH
	OUT	(C),A

	LD	A,0C4H			;vektor preruseni L pio-a
	OUT	(0FCH),A

	LD	A,83H			;ei pio-a   povoleni preruseni
	OUT	(0FCH),A

	LD	BC,9B1H			;inicializace sio-a 0b1h
	LD	HL,PEA43		;rs-232   priznak prer. 0 zak. 1 povol.
	PUSH HL
	OTIR

	LD	BC,9B3H			;inicializace sio-b 0b3h
	POP HL
	OTIR

	LD	SP,100H			;zasobnik 100h

	IM	2			;preruseni int typu 2

	LD	A,0F3H			;vektor preruseni H i registr
	LD	I,A

	LD	BC,80H			;setdma nastavit dma adresu
	CALL	SF2E0

	LD	C,8			;bc-0008
	LD	D,B			;de-0000
	LD	E,B
	LD	HL,CFF99		;hl-ff99
	PUSH	BC
	PUSH	HL
	LDIR				;prenos system parametr area

	POP	HL			;hl-ff99
	POP	BC			;bc-0008
	LD	DE,PEA44		;de-ea44
	LDIR				;prenos system parametr area

	IN	A,(0E0H)		;cg rom vram on
	CALL	SF753			;zobrazeni klicu
	IN	A,(0E1H)		;cg rom vram off

	LD	HL,PEA37		;fyzicke parametry disku
	PUSH	HL
	LD	A,(HL)
	INC	HL
	OR	(HL)
	INC	HL
	OR	(HL)
	INC	HL
	OR	(HL)
	BIT	2,A
	JR	Z,LFE79
	LD	HL,CFDBA
	LD	(WFAD5),HL
	LD	HL,CFDB2
	LD	(WFACD),HL
	LD	A,2
	LD	HL,PEA36		;cislo poslesledniho disku v systemu
	CP	(HL)
	JR	NC,LFE79
	LD	(HL),A
LFE79:	POP	HL
	LD	B,4
	LD	DE,XF28B
LFE7F:	LD	A,(HL)
	INC	HL
	PUSH	HL
	LD	H,D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
	AND	A
	JR	Z,LFF46
	LD	HL,CFFBB
	CALL	SFF8C			;print
	LD	HL,(PEA3F)		;velikost ram v jednotkach 16kB
	LD	H,0
	ADD	HL,HL
	ADD	HL,HL
	ADD	HL,HL
	ADD	HL,HL
	CALL	SFF4C			;hex na dec

;	ZAVER BOOT
;	~~~~~~~~~~

LFF46:	EI				;povoleni preruseni
	XOR	A			;sluzba 0
	LD	C,A
	JP	0D400H			;jp bdos

;	HEX NA DEC PRO BOOT
;	~~~~~~~~~~~~~~~~~~~

SFF4C:	LD	B,0
	LD	DE,3E8H
	CALL	SFF6C
	LD	DE,64H
	CALL	SFF6C
	LD	DE,0AH
	CALL	SFF6C
	INC	B
	LD	DE,1H
	CALL	SFF6C
	LD	HL,CFFD5		;k bytes
	JR	SFF8C			;print

SFF6C:	AND	A
	SBC	HL,DE
	ADD	HL,DE
	JR	NC,LFF7A
	INC	B
	DEC	B
	JR	NZ,LFF7A
	LD	C,020H
	JR	LFF84

LFF7A:	INC	B
	LD	C,02FH
LFF7D:	INC	C
	AND	A
	SBC	HL,DE
	JR	NC,LFF7D
	ADD	HL,DE
LFF84:	PUSH	BC
	PUSH	HL
	CALL	SEAD5			;conout	vypis znak na consoli
	POP	HL
	POP	BC
	RET

;	PRINT
;	~~~~~

SFF8C:	LD	A,(HL)			;print
	INC	HL
	CP	'$'
	RET	Z
	LD	C,A
	PUSH	HL
	CALL	SEAD5			;conout	vypis znak na consoli
	POP	HL
	JR	SFF8C			;print

;	SYSTEM PARAMETR AREA		;prenos 8 na 0000h
;	~~~~~~~~~~~~~~~~~~~~

CFF99:	JP	LEA03			;wboot
	NOP
	NOP
	JP	0DC06H			;bdos

;	TEXT BOOT CP/M
;	~~~~~~~~~~~~~~

CFFA1:	DB	'    '
VFFA5:	DB	'A: Floppy disk drive $'

CFFBB:	DB	'    '
VFFBF:	DB	'E: Memory disk board $'

CFFD5:	DB	' K bytes',0DH,0AH,'$'

CFFE0:	DB	01FH,000H,000H,000H,000H,000H,000H,000H
	DB	008H,009H,00AH,00BH,00CH,00DH,00EH,00FH
	DB	000H,000H,000H,000H,000H,000H,000H,000H
	DB	000H,000H,000H,000H,000H

CFFFD:	DB	000H,000H,000H

