NEW AUTO 3,1 *-------------------------------------- ENVX.PutEnv ldy #$ff .1 iny jsr SHARED.TXTPTR.GetY NAME= beq .9 cmp #'=' bne .1 tya sec skip = adc TXTPTR sta FORPNT lda #0 adc TXTPTR+1 sta FORPNT+1 bra ENVX.SetEnv .9 lda #E.SYN sec rts *-------------------------------------- ENVX.SetEnv jsr ENVX.UnsetEnv .1 jsr ENVX.InitEnvP3 ZPPtr3 -> Env (SETREADAUX) lda #1 sta ZPPtr4 stz ZPPtr4+1 ZPPtr4 = ENVSIZE = 1 .10 lda (ZPPtr3) End of ENV beq .15 jsr ENVX.GetP3LenY jsr ENVX.NextEnvP3Y jsr ENVX.NextEnvP4Y bra .10 .15 ldy #$ff .16 iny jsr SHARED.TXTPTR.GetY beq .17 jsr SHARED.IsIDValid bcc .16 .17 jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VAR ldy #$ff .19 iny jsr SHARED.FORPNT.getY bne .19 jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VALUE lda ZPPtr4 beq .20 inc ZPPtr4+1 .20 ldy #S.PS.ENVPAGECNT lda (pPs),y cmp ZPPtr4+1 bcs .22 env is large enough lda ZPPtr4+1 jsr ENV.Dup.A bcs .9 pha ldy #S.PS.hENV lda (pPs),y jsr K.Freemem AUX pla ldy #S.PS.hENV sta (pPs),y txa dey S.PS.ENVPAGECNT sta (pPs),y bra .1 Start over .22 ldy #$ff .23 iny jsr SHARED.TXTPTR.GetY sta (ZPPtr3),y beq .24 jsr SHARED.IsIDValid bcc .23 .24 lda #'=' sta (ZPPtr3),y jsr ENVX.NextEnvP3Y ldy #$ff .25 iny jsr SHARED.FORPNT.getY sta (ZPPtr3),y bne .25 iny sta (ZPPtr3),y don't forget array ending 0 clc .9 rts *-------------------------------------- ENVX.GetEnv lda TXTPTR beq ENVX.Dump jsr ENVX.FindVar bcs .9 jsr ENVX.NextEnvP3Y Skip NAME= lda FORPNT+1 bne .3 ldy #$ff .1 iny lda (ZPPtr3),y bne .1 iny bne .2 inc .2 sta CLRREADAUX sta CLRWRITEAUX jsr K.getmem sta SETREADAUX sta SETWRITEAUX bcs .99 >STYA FORPNT .3 ldy #$ff .4 iny lda (ZPPtr3),y jsr SHARED.FORPNT.PutY bne .4 >LDYA FORPNT clc rts .9 >LDYAI 0 * sec .99 rts *-------------------------------------- ENVX.Dump sta CLRREADAUX sta CLRWRITEAUX ldy #S.PS.ENVPAGECNT lda (pPs),y sta .1+1 ldy #0 jsr K.getmem sta SETREADAUX sta SETWRITEAUX bcs .9 >STYA FORPNT sty .80+1 sta .81+1 stx .82+1 jsr ENV.InitEnvP3 SETREADAUX .1 ldx #$ff SELF MODIFIED ldy #0 .2 lda (ZPPtr3),y jsr SHARED.FORPNT.PutY iny bne .2 inc ZPPtr3+1 inc FORPNT+1 dex bne .2 .80 ldy #$ff SELF MODIFIED .81 lda #$ff SELF MODIFIED .82 ldx #$ff SELF MODIFIED clc .9 rts *-------------------------------------- ENVX.UnsetEnv jsr ENVX.FindVar bcs . 8 not found, quit jsr ENVX.DelVarP3 Ptr3 -> NAME=VALUE clc rts *-------------------------------------- * ENV.FindVar * In: * TXTPTR -> NAME * Out: * CC: Found * Y = NAME len * TXTPTR -> NAME * ZPPtr3 -> NAME=VALUE * CS: Not Found * TXTPTR -> NAME * ZPPtr3 -> PTR to Ending 0 *-------------------------------------- ENVX.FindVar jsr ENVX.InitEnvP3 Store ENV .1 lda (ZPPtr3) beq .9 end of ENV ldy #$ff .2 iny jsr SHARED.TXTPTR.GetY beq .3 jsr SHARED.IsIDValid bcs .3 cmp (ZPPtr3),y beq .2 bra .4 .3 lda (ZPPtr3),y cmp #'=' bne .4 clc rts .4 jsr ENVX.NextEnvP3 Skip NAME=VALUE bra .1 .9 sec rts *-------------------------------------- * ENV.DelVarP3 * In: * ZPPtr3 -> ENV.NAME to Discard *-------------------------------------- ENVX.DelVarP3 >LDYA ZPPtr3 save actual Ptr >STYA ZPPtr4 jsr ENVX.NextEnvP3 Skip NAME=VALUE .1 ldy #$ff .2 iny lda (ZPPtr3),y Move back CSTRs... sta (ZPPtr4),y bne .2 tya beq .8 we moved back ending \0 jsr ENVX.NextEnvP3Y jsr ENVX.NextEnvP4Y bra .1 .8 rts *-------------------------------------- ENVX.InitEnvP3 sta CLRREADAUX ldy #S.PS.hENV lda (pPs),y sta SETREADAUX jsr K.GetMemPtr >STYA ZPPtr3 Store ENV rts *-------------------------------------- ENVX.NextEnvP3 jsr ENVX.GetP3LenY *-------------------------------------- ENVX.NextEnvP3Y tya ENVX.NextEnvP3A sec adc ZPPtr3 sta ZPPtr3 bcc .8 inc ZPPtr3+1 .8 rts *-------------------------------------- ENVX.GetP3LenY ldy #$ff .1 iny lda (ZPPtr3),y bne .1 rts *-------------------------------------- ENVX.NextEnvP4Y tya sec adc ZPPtr4 sta ZPPtr4 bcc .8 inc ZPPtr4+1 .8 rts *-------------------------------------- * ENV.Dup * In: * A = ENV hMem To Duplicate * Out: * A = hMem to new ENV * X = Page Count *-------------------------------------- ENV.Dup ldy #S.PS.ENVPAGECNT lda (pPs),y ENV.Dup.A sta .8+1 Store target page Count ldy #S.PS.ENVPAGECNT get SOURCE page count lda (pPs),y sta .10+1 ldy #S.PS.hENV lda (pPs),y jsr K.GetMemPtr >STYA .1+1 ldy #0 lda .8+1 jsr K.GetMem bcs .9 >STYA .2+1 Target Buffer phx save hMem jsr Mem.SetOwner Set Ownership ldy #0 .10 ldx #$ff SELF MODIFIED .1 lda $ffff,y SELF MODIFIED .2 sta $ffff,y SELF MODIFIED iny bne .1 inc .1+2 inc .2+2 dex bne .1 .8 ldx #$ff SELF MODIFIED Target Page Count pla hMem clc .9 rts *-------------------------------------- MAN SAVE USR/SRC/SYS/KERNEL.S.ENVX LOAD USR/SRC/SYS/KERNEL.S ASM