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 IO.RROMBNK1
				>LDYAI A2osX.QC
				>STYA ROM.PWREDUP
				jsr ROM.SETPWRC

				lda #$01
				sta	GP.MEMTABL+$17		protect ProDOS MLI Page
				ldx #$16

.1				stz GP.MEMTABL,x		Reset ProDOS memory bitmap
				dex
				bne .1

				lda	#$CF				protect zero page, stack and page 1
				sta	GP.MEMTABL

				lda #$8C				Reset 80 col screen ($0C=FF=HOME)
				jsr $C300

				ldx $280				some /PATH/.SYSTEM file passed ?
				beq A2osX.QC.Start2

.2				dex
				lda $280,x
				cmp #'/'
				bne .2

				stx A2osX.QC.BOOT		get /PATH/ in QC.BOOT...

.3				lda $280,x
				sta A2osX.QC.BOOT,x
				dex
				bne .3

				jsr A2osX.QC.SetPFX		cd to QC.BOOT...
				bcs A2osX.QC.Start2

				jsr A2osX.QC.Load
				bcs A2osX.QC.Start2
*--------------------------------------
* $2000 = JMP $xxxx
* $2003 = $EE
* $2004 = $EE
* $2005 = BufSize
* $2006 = PathLen
* $2007... Path
*--------------------------------------
				lda $2000
				cmp #$4C
				bne .8

				lda #$EE
				cmp $2003
				bne .8

				cmp $2004
				bne .8

				ldy $280
				iny
				lda $280,y
				beq .8

				cmp $2005
				bcs .8

				sta $2006
				ldx #0

.4				iny
				lda $280,y
				inx
				sta $2006,x
				cpx $2006
				bne .4

.8				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
				
				lda GP.KVER
				cmp #$8D
				beq .7

				ldy #SYSKERNEL
				lda /SYSKERNEL
				bra .8

.7				ldy #SYSKRNL8M
				lda /SYSKRNL8M

.8				sty TmpPtr1
				sta TmpPtr1+1
				
				ldx $280

				ldy #0

.9				inx
				iny
				lda (TmpPtr1),y
				sta $280,x
				tya
				cmp (TmpPtr1)
				bne .9

				stx $280

				jsr A2osX.QC.Load
				bcs *

				>LDYAI MSG.INIT1OK
				sec
				jsr A2osX.QC.PrintYA

				>DEBUGOA
				jmp $2000
*--------------------------------------
A2osX.QC.SetPFX	jsr MLI
				.DA #MLI.SETPREFIX
				.DA MLISETPREFIX03
				rts
*--------------------------------------
A2osX.QC.Load	>LDYAI MSG.LOAD
				clc
				jsr A2osX.QC.PrintYA

				>LDYAI $280
				clc
				jsr A2osX.QC.PrintYA

				jsr MLI
				.DA #MLI.OPEN
				.DA MLIOPEN03
				bcs .9

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

				jsr MLI
				.DA #MLI.READ
				.DA MLIREAD03

				php
				pha
				jsr MLI
				.DA #MLI.CLOSE
				.DA MLICLOSE03

				pla
				plp
				bcc .8

.9				pha
				>LDYAI MSG.LOAD.KO
				clc
				jsr A2osX.QC.PrintYA
				pla
				jsr ROM.PRBYTE
				jsr ROM.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 ROM.COUT
				iny
				dex
				bne .1

.9				plp
				bcc .99

				jsr ROM.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		.PS "sys/kernel"
SYSKRNL8M		.PS "sys/krnl8m"
*--------------------------------------
MSG.INIT1		.PS "A2osX[Stage1]:Init"
MSG.SETPREFIXOK .PS "Prefix Set: "
MSG.SETPREFIXKO .PS "Insert Vol:"
MSG.LOAD		.PS "Loading : "
MSG.LOAD.KO		.PS " Error $"
MSG.LOAD.OK		.PS " OK."
MSG.INIT1OK		.PS "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
