NEW
  AUTO 3,1
				.LIST OFF
*--------------------------------------
* ****** START OF MLI QUIT CODE ******
* Load Address :$1000-$12FF
*--------------------------------------
				.PH $1000
*--------------------------------------
* Kernel Stage 1
*--------------------------------------
A2osX.QC.Start	.EQ *
A2osX.QC		cld
				jmp A2osX.QC.Start1
				
A2osX.QC.BOOT	.BS 32
A2osX.QC.ROOT	.BS 32
				
A2osX.QC.Start1	sei
				ldx #$FF
				txs
				cli
				
				bit RROMBNK1
				>LDYAI A2osX.QC
				>STYA POWERUP
				jsr SETPWRC

				lda #$01
				sta	MEMTABL+$17			protect ProDOS MLI Page
				
				
				ldx #$16
				
.1				stz MEMTABL,x			Reset ProDOS memory bitmap
				dex
				bne .1
				
				lda	#$CF				protect zero page, stack and page 1
				sta	MEMTABL

				lda #$8C				Reset 80 col screen ($0C=FF=HOME)
				jsr $C300
				sec
				>LDYAI MSG.INIT1
				jsr A2osX.QC.PrintYA
				sec
				>LDYAI A2osX.QC.BOOT
				jsr A2osX.QC.PrintYA
				sec
				>LDYAI A2osX.QC.ROOT
				jsr A2osX.QC.PrintYA
				
.3				jsr MLI
				.DA #MLISETPREFIX
				.DA MLISETPREFIX00
				bcc .4
				
				>LDYAI MSG.SETPREFIXKO
				jsr A2osX.QC.PrintYA
				
				>LDYAI A2osX.QC.BOOT
				sec
				jsr A2osX.QC.PrintYA

				bra .3
				
.4				>LDYAI MSG.SETPREFIXOK
				sec
				jsr A2osX.QC.PrintYA
				
				ldx A2osX.QC.BOOT
				stx $280					For appending SYS/KERNEL

				stz $2C0,x
				
.5				lda A2osX.QC.BOOT,x
				sta $280,x
				sta $2C0-1,x				BOOT sz for KERNEL 
				dex
				bpl .5

				ldx A2osX.QC.ROOT
				stz $2E0,x
				
.6				lda A2osX.QC.ROOT,x
				sta $2E0-1,x				ROOT sz for KERNEL
				dex
				bpl .6

				jsr A2osX.QC.KLoad
				bcs *
				
.8				>LDYAI MSG.INIT1OK
				sec
				jsr A2osX.QC.PrintYA

*				>LDYAI GO.Reset
*				>STYA POWERUP
*				bit RROMBNK1
*				jsr SETPWRC
				
				>DEBUGOA
				jmp $2000
*--------------------------------------
A2osX.QC.KLoad	>LDYAI MSG.KLOAD
				clc
				jsr A2osX.QC.PrintYA

				ldx $280

				ldy #0
				
.2				inx
				iny
				lda SYSKERNEL,y
				sta $280,x
				cpy SYSKERNEL
				bne .2
				
				stx $280
				
				>LDYAI $280
				clc
				jsr A2osX.QC.PrintYA				
				
				jsr MLI
				.DA #MLIOPEN
				.DA MLIOPENK
				bcs .9
				
				lda MLIOPENK+5
				sta MLIREADK+1
				sta MLICLOSEK+1

				jsr MLI
				.DA #MLIREAD
				.DA MLIREADK

				php
				pha
				
				jsr MLI
				.DA #MLICLOSE
				.DA MLICLOSEK

				pla
				plp
				bcc .8
				
.9				pha
				>LDYAI MSG.KLOAD.KO
				clc
				jsr A2osX.QC.PrintYA
				pla
				jsr PRBYTE
				sec
.8				rts		
*--------------------------------------
A2osX.QC.PrintYA
				php
				>STYA TmpPtr1
				lda (TmpPtr1)
				tax
				beq .9

				ldy #1
				
.1				lda (TmpPtr1),y
				ora #$80
				jsr COUT
				iny
				dex
				bne .1
				
.9				plp
				bcc .99
				
				jsr CROUT
.99				rts				
*--------------------------------------
MLISETPREFIX00	.DA #1
				.DA A2osX.QC.BOOT
*--------------------------------------
MLIOPENK		.DA #3
				.DA $280
				.DA $C00
				.BS 1
*--------------------------------------
MLIREADK		.DA #4
				.BS 1
				.DA $2000
				.DA $8000
				.BS 2
*--------------------------------------
MLICLOSEK		.DA #1
				.BS 1
*--------------------------------------
SYSKERNEL		>PSTR "SYS/KERNEL"
*--------------------------------------
MSG.INIT1		>PSTR "A2osX[Stage1]:Init"
MSG.SETPREFIXOK >PSTR "Set Prefix OK"
MSG.SETPREFIXKO >PSTR "Insert Vol:"
MSG.KLOAD		>PSTR "Loading Kernel:"
MSG.KLOAD.KO	>PSTR "Error While Loading Kernel."
MSG.INIT1OK		>PSTR "A2osX[Stage1]:Complete."
*--------------------------------------
				.BS $1300-*
				.EP
*--------------------------------------
MAN
SAVE USR/SRC/A2OSX.S.QC
LOAD USR/SRC/A2OSX.S
ASM
