*******************************************************************************
*
*	Bootstrap Loader for Micromation DOUBLER and CP/M 1.4
*
*	Last updated:	OCTOBER 21, 1979
*
*******************************************************************************
	TRUE	EQU	1	!	FALSE	EQU	0
*******************************************************************************
*These parameters may be user defined:

MSIZE		EQU	62	;This value is the same as the parameter
				; passed to MOVCPM
EXTENDED	EQU	FALSE	;Set this TRUE if the CBIOS is extended
				;
*	Note:	If EXTENDED is true then decrement MSIZE by 1
				;
CONTROLLER	EQU	0F800H	;Base address of the DOUBLER
				;
VIDEO		EQU	FALSE	;Set true or false for Micromation Video Board

*******************************************************************************

PROM		EQU	CONTROLLER	;Beginning of DOUBLER routines in PROM
BUFF		EQU	CONTROLLER+400H	;Base of 64 bytes of scratch RAM

IOPAGE		EQU	CONTROLLER+600H
UARTDATA	EQU	IOPAGE+2
UARTSTAT	EQU	IOPAGE++0AH

CBASE		EQU	(MSIZE-16)*1024	;BIAS FOR SYSTEMS LARGER THAN 16K
BDOS		EQU	CBASE+3106H
CCP		EQU	CBASE+2900H	;Console Command Processor base addr
CCPM		EQU	CCP-128		;START OF LOAD TO SKIP BOOT
COLDBOOT	EQU	CBASE+3E00H	;COLD START BOOT
;
;	EQUATES FOR RESERVED ROM LOCATIONS
HOME		EQU	PROM+3
SETTRK		EQU	PROM+9		;SET TRACK
SETSEC		EQU	PROM+0CH	;SET SECTOR NUMBER
SETDMA		EQU	PROM+0FH	;SET DMA FUNCTION
READ		EQU	PROM+12H	;DISK READ

CONTROLBYTE	EQU	BUFF+3
TRACK		EQU	BUFF+4
SECTOR		EQU	BUFF+0AH
DMA		EQU	BUFF+0BH

VIDINIT		EQU	0F800H		;Call to initialize a Video Board

CR		EQU	0DH
LF		EQU	0AH
*******************************************************************************
BEGIN:		ORG	0		;This code begins at 0000 Hex
ŠBOOT:		LXI	SP,CCPM
		CALL	HOME
		LXI	H,CCPM-80H
		SHLD	DMA
RDTRK:		MVI	C,0
RDSEC:		MOV	A,C
		CPI	26
		JZ	NXTTRK
		LXI	D,128
		LHLD	DMA
		DAD	D
		MOV	A,H		;Get the High Order DMA address
		CPI	(MSIZE + EXTENDED) * 1024 / 100H
		JNC	NXTTRK		;Don't read past the top of memory
		INR	C		;Increment the sector count
		CALL	SETSEC
		PUSH	B		;Save the Sector number
		SHLD	DMA
RELP		DI
		CALL	READ
		EI
		JNZ	BOOT
		POP	B
		JMP	RDSEC
NXTTRK		LDA	TRACK
		ORA	A
		JNZ	INIT
		MVI	C,1
		CALL	SETTRK
		JMP	RDTRK

INIT		LXI	H,UARTSTAT	;HARDWARE UART INITIALIZATION
		MVI	M,0EH		;USED FOR THE 8251 UART
		PUSH	B		;JUST FILLER FOR 4MHZ OPERATION
		MVI	M,40H
		POP	B		;MORE FILLER
		MVI	M,0EEH
		XRA	A
		STA	4		;SET CURRDRIVE TO A:
		MVI	M,27H		;Don't forget this instruction
IF VIDEO
		CALL	VIDINIT		;The Video screen must be
ENDIF					;initialized before signon
		LXI	D,SIGNON
		MVI	C,9
		CALL	BDOS
		JMP	COLDBOOT

SIGNON:				;This message printed during COLDBOOT
	DB	CR,LF
	DB	(MSIZE+EXTENDED) / 10 + 30H	;First digit of system size
	DB	(MSIZE+EXTENDED) MOD 10 + 30H	;Second digit
IF not EXTENDED
	DB	'k CP/m Version 1.4$'
ENDIFŠIF EXTENDED
	DB	'k CP/m	Ver 1.4	Extended$'
ENDIF
*******************************************************************************

LAST	EQU	$	;This address must not be over 80 hex
