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 64
A2osX.QC.ROOT	.BS 64

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

				ldx $280
				beq A2osX.QC.Start2

.2				dex
				lda $280,x
				cmp #'/'
				bne .2
				
				stx A2osX.QC.BOOT
				
.3				lda $280,x
				sta A2osX.QC.BOOT,x
				dex
				bne .3

				jsr A2osX.QC.SetPFX
				bcs A2osX.QC.Start2
				
				jsr A2osX.QC.Load
				bcs A2osX.QC.Start2
				
				jmp $2000

A2osX.QC.Start2	sec
				>LDYAI MSG.INIT1
				jsr A2osX.QC.PrintYA

.3				jsr A2osX.QC.SetPFX
				bcc .4

				>LDYAI MSG.SETPREFIXKO
				clc
				jsr A2osX.QC.PrintYA
				>LDYAI A2osX.QC.BOOT
				sec
				jsr A2osX.QC.PrintYA
				>DEBUG
				bra .3

.4				>LDYAI MSG.SETPREFIXOK
				clc
				jsr A2osX.QC.PrintYA
				>LDYAI A2osX.QC.BOOT
				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

				ldx $280

				ldy #0

.7				inx
				iny
				lda SYSKERNEL,y
				sta $280,x
				cpy SYSKERNEL
				bne .7
				
				stx $280

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

A2osX.QC.JMP	>DEBUGOA
				jmp $2000
*--------------------------------------
A2osX.QC.SetPFX	jsr MLI
				.DA #MLISETPREFIX
				.DA MLISETPREFIX03
				rts
*--------------------------------------
A2osX.QC.Load	>LDYAI MSG.LOAD
				clc
				jsr A2osX.QC.PrintYA
				
				>LDYAI $280
				clc
				jsr A2osX.QC.PrintYA
	
				jsr MLI
				.DA #MLIOPEN
				.DA MLIOPEN03
				bcs .9

				lda MLIOPEN03+5
				sta MLIREAD03+1
				sta MLICLOSE03+1

				jsr MLI
				.DA #MLIREAD
				.DA MLIREAD03

				php
				pha
				jsr MLI
				.DA #MLICLOSE
				.DA MLICLOSE03

				pla
				plp
				bcc .8

.9				pha
				>LDYAI MSG.LOAD.KO
				clc
				jsr A2osX.QC.PrintYA
				pla
				jsr PRBYTE
				jsr CROUT

				sec
				rts
				
.8				>LDYAI MSG.LOAD.OK
				sec
				jsr A2osX.QC.PrintYA
				clc
				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
*--------------------------------------
MLISETPREFIX03	.DA #1
				.DA A2osX.QC.BOOT
*--------------------------------------
MLIOPEN03		.DA #3
				.DA $280
				.DA $C00
				.BS 1
*--------------------------------------
MLIREAD03		.DA #4
				.BS 1
				.DA $2000
				.DA $9F00				Max .SYSTEM file len
				.BS 2
*--------------------------------------
MLICLOSE03		.DA #1
				.BS 1
*--------------------------------------
SYSKERNEL		>PSTR "sys/kernel"
*--------------------------------------
MSG.INIT1		>PSTR "A2osX[Stage1]:Init"
MSG.SETPREFIXOK >PSTR "Prefix Set: "
MSG.SETPREFIXKO >PSTR "Insert Vol:"
MSG.LOAD		>PSTR "Loading : "
MSG.LOAD.KO		>PSTR " Error $"
MSG.LOAD.OK		>PSTR " OK."
MSG.INIT1OK		>PSTR "A2osX[Stage1]:Complete."
*--------------------------------------
				.LIST ON
QC.FREE			.EQ $1300-*
				.LIST OFF
				.EP
*--------------------------------------
MAN
SAVE USR/SRC/A2OSX.S.QC
LOAD USR/SRC/A2OSX.S
ASM
