NEW
  AUTO 3,1
* object code = mli_1
* global page

ofsG	.EQ	H2E00-MLI		offset to global org

H2E00	jmp   mlient1			$2E00-2EFF moved to $BF00
jspare	.EQ	*-ofsG
         jmp   jspare			will be changed to point to dispatcher.
clockv   .EQ	*-ofsG			P8 clock vector
         rts				changed to jmp ($4C) if clock present.
                .DA tclk_in'              clock routine entry address.
p8errv   .EQ	*-ofsG			error reporting hook.
         jmp   syserr1
sysdeath	.EQ	*-ofsG
         jmp   sysdeath1		system failure hook.
p8error  .EQ  *-ofsG			P8 error code
                .DA #00'
drivertbl1 .EQ *-ofsG	device driver table 1
	dc	i2'nodevice'		slot 0 reserved
	dc	i2'nodevice'             s1, d1
	dc	i2'nodevice'             s2, d1
	dc	i2'nodevice'             s3, d1
	dc	i2'nodevice'             s4, d1
	dc	i2'nodevice'             s5, d1
	dc	i2'nodevice'             s6, d1
	dc	i2'nodevice'             s7, d1
drivertbl2 .EQ	*-ofsG			device driver table 2
	dc	i2'nodevice'             slot 0 reserved
	dc	i2'nodevice'             s1, d2
	dc	i2'nodevice'             s2, d2
	dc	i2'nodevice'             s3, d2
	dc	i2'nodevice'             s4, d2
	dc	i2'nodevice'             s5, d2
	dc	i2'nodevice'             s6, d2
	dc	i2'nodevice'             s7, d2
devnum	.EQ	*-ofsG			most recent accessed device
                .DA #00'
numdevs  .EQ	*-ofsG			count (-1) active devices
	dc	h'FF'
devlist  .EQ	*-ofsG			active device list
         dc	h'00000000000000'       up to 14 units may be active
	dc	h'00000000000000'
                .DA #00'
	msb	off
         dc    c'(C)APPLE  '
mlient1	.EQ	*-ofsG
         php
         sei
         jmp   mlicont
aftirq	.EQ	*-ofsG			irq returns here.
         sta   ramin			read/write RAM bank 1
         jmp   fix45			restore $45 after interrupt in LC
oldacc	.EQ	*-ofsG
                .DA #00'
afbank	.EQ	*-ofsG
         dc	h'00'

* memory map of lower 48k. each bit represents 1 page.
* protected pages = 1, unprotected = 0

memmap   .EQ	*-ofsG			P8 memory bitmap
	dc	h'C000000000000000'
	dc	h'0000000000000000'
                .DA #0000000000000001'

* table of buffer addresses for currently open files.
* these can only be changed thru the mli call setbuf.

buftbl   .EQ	*-ofsG
	dc	h'0000'			file #1
         dc	h'0000'                 file #2
         dc	h'0000'                 file #3
         dc	h'0000'                 file #4
                .DA #0000'                  file #5
         dc	h'0000'                 file #6
         dc	h'0000'                 file #7
         dc	h'0000'                 file #8

* table of interrupt vectors. these can only be changed
* by the mli call allocate_interrupt. values of the registers
* at the time of the most recent interrupt are stored here along
* with the address interrupted.

inttbl   .EQ	*-ofsG			interrupt table
                .DA #0000'			int #1
         dc	h'0000'                 int #2
         dc	h'0000'                 int #3
         dc	h'0000'                 int #4
p8areg   .EQ	*-ofsG			A register savearea
                .DA #00'
p8xreg   .EQ	*-ofsG			X register savearea
	dc	h'00'
p8yreg   .EQ	*-ofsG			Y register savearea
	dc	h'00'
p8sreg   .EQ	*-ofsG			S register savearea
	dc	h'00'
p8preg   .EQ	*-ofsG			P register savearea
	dc	h'00'
bankid	.EQ	*-ofsG			bank ID byte (ROM/RAM)
	dc	h'01'
intadr   .EQ	*-ofsG			interrupt return address
	dc    h'0000'
p8date   .EQ	*-ofsG			bits 15-9=yr, 8-5=mo, 4-0=day
	dc	h'0000'
p8time   .EQ	*-ofsG			bits 12-8=hr, 5-0=min, low-hi format
	dc	h'0000'
flevel   .EQ	*-ofsG			current file level
	dc	h'00'
bubit    .EQ	*-ofsG			backup bit disable, setfileinfo only
	dc	h'00'
spare1	.EQ	*-ofsG                  used to save acc
	dc	h'00'
newpfxptr .EQ	*-ofsG			appletalk alternate prefix ptr
         dc	h'00'
machid   .EQ	*-ofsG			machine ID byte
	dc	h'00'
rommap   .EQ	*-ofsG			slot ROM bit map
	dc	h'00'
preflag  .EQ	*-ofsG			prefix active flag
	dc	h'00'
mliact   .EQ	*-ofsG			MLI active flag
	dc	h'00'
mliretn  .EQ	*-ofsG			last MLI call return address
	dc	h'0000'
mlix     .EQ	*-ofsG			MLI X register savearea
	dc	h'00'
mliy     .EQ	*-ofsG			MLI Y register savearea
	dc	h'00'

* language card bank switching routines which must reside at $BFA0 because
* workstation software patches this area

HBFA0	.EQ	*-ofsG
	eor   $E000			test for rom enable
         beq   L2EAA                    taken if ram enabled
         sta   romin			read ROM
         bne   L2EB5                    always
L2EAA    lda   bnkbyt2			for alternate ram
         eor   $D000                    test
         beq   L2EB5                    branch if not alternate ram
         lda   altram			else enable alt $D000
L2EB5    pla                            return code
         rti                            re-enable interrupts and return
mlicont	.EQ	*-ofsG
         sec
         ror   mliact                   notify interrupt routines MLI active.
         lda   $E000                    preserve language card/rom orientation
         sta   bnkbyt1                  for proper restoration when mli exits.
         lda   $D000
         sta   bnkbyt2
         lda   ramin			force ram card on
         lda   ramin                    with write allowed
         jmp   xdosmli	
irqexit	.EQ	*-ofsG
         lda   bankid                   determine state of ram card (ROM/RAM)
irqxit0	.EQ	*-ofsG
         beq   L2EE2                    branch if ram card enabled.
         bmi   L2EDF                    branch if alternate $D000 enabled.
         lsr   a                        determine if no ram card present.
         bcc   L2EE7                    branch if rom only system.
         lda   romin1                   enable rom
         bcs   L2EE7                    always taken
L2EDF    lda   altram			enable alternate $D000
L2EE2    lda   #$01                     preset bankid for rom.
         sta   bankid                   (reset if ram card interrupt)
L2EE7	lda	p8areg                  restore acc
         rti                            exit
irqent	.EQ	*-ofsG			this entry only used when rom
         bit	ramin                   was enabled at time of interrupt.
         bit	ramin
         jmp	irqrecev
bnkbyt1	.EQ	*-ofsG
         dc	h'00'
bnkbyt2	.EQ	*-ofsG
	dc	h'00'
	dc	h'00000000'		pad to before $BFFA
         dc	h'04'			gsos compatibility byte ($BFFA)
                .DA #00'			pad
         dc	h'00'			reserved
         dc	h'00'			version # of running interpreter
         dc	h'00'			preserved for System Utilities
kversion .EQ	*-ofsG			kernal version
	dc	h'23'			represents release 2.0.3

* end of obj mli_1
*--------------------------------------
MAN
LOAD USR/SRC/PRODOS.203/PRODOS.S.GP
SAVE USR/SRC/PRODOS.203/PRODOS.S
ASM
