; Parainitiator for XM7 V2 series
; Programmed by Apollo

IROMDR	EQU	$FD10	; INITIATOR ROM DISABLE REGISTER
MSR1	EQU	$FD93	; MODE SELECT REGISTER (BOOT ROM/RAM)

BOOTROM	EQU	$7E00

	ORG	$6000

	LDA	#$01
	STA	MSR1	; BOOT RAM MODE
; TRANSFER BOOT ROM CONTENTS TO BOOT RAM
	LDU	#BOOTROM
	LDX	#$FE00
	LDY	#$1FE
LOOP1	PULU	A
	STA	,X+
	LEAY	<-1,Y
	BNE	LOOP1
; SET RESET VECTOR
	LDD	#$FE00
	STD	$FFFE

	CLR	MSR1	; BOOT ROM MODE

	LEAU	<SUBP_S,PC
	LDX	#$4000
	LDB	#SUBP_E-SUBP_S+1
TFR_L	PULU	A
	STA	,X+
	DECB
	BNE	TFR_L
	JMP	$4000

SUBP_S	EQU	*
	LDA	#$02
	STA	IROMDR	; INITIATOR ROM DISABLE
	JMP	[$FFFE]
SUBP_E	EQU	*

	END
